Monday, November 2, 2026

Install Tumbleweed via Agama Installer and automated detection of HDMI ports (bare metal)

UPDATE as of 11/03/26  

Reproduced with no issues on SATA SSD ( the same Intel Haswell Xeon box ).  I have to notice that Agama installer in phase of deployment packages on target drive demonstrates extremely high speed. Thin XFS LVM  Provisioning and Libvirt hooks implementation may be done only in post installation phase via CLI. 

END UPDATE 

 After booting via USB pen on target box,right after you see the first screen  
for selection of desired OS . You are supposed to press CTRL+ALT+F3 without any other input into the first page of Agama Web UI

You would see in terminal  IP-TARGET of target host and root password.
From another box ( in my case no IP:443 ) launch your browser to https://IP-TARGET. 
This step will bring you to Agama WEB UI and prompt for root "password".
After entering WEB UI environment select OS (Tumbleweed for instance)
manage as usual until creating root account.
You should have SSH trusted pair already generated prior to configuring
root's credentials on target box. I've selected password and SSH public key. 
Cut and paste SSH Public key into corresponding field on Agama Web UI. 
Save and start installation which was initiated remotely from your workstation.
Agama follows standard transactional schema when preparing desired disk layout, 
selection of DE, user's and root's credentials until you press "Install".
Upon reboot installed tumbleweed instance would properly detect HDMI port 
and Monitor of target box. Booting up brought me to text console
with resolution 1920x1080. After logging into text mode terminal
I've just issued /usr/bin/startplasma-wayland and get into

KDE Plasma 6.8.2
environment. I believe that slow WD 596 GB HDD,
as the only one empty drive was just too slow to bring up Plasma itself.

In my case I was ready to log into target box via SSH and run:
$ echo 'hostonly="no"' | sudo tee /etc/dracut.conf.d/00-generic.conf

If you want a small ramdisk but want to force legacy drivers to include anyway

$ echo 'add_drivers+=" nouveau amdgpu radeon i915 "'| \
sudo tee /etc/dracut.conf.d/00-generic.conf

$ sudo cat /etc/dracut.conf.d/00-generic.conf
$ sudo dracut -f --regenerate-all


to rebuild
initrd-7.3.0-1-default with required legacy drivers as after YaST installation.
But resolution of HDMI Monitor/port were already detected by Agama Installer

 





























boris@localhost:~> df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda3      btrfs     140G  7.1G  132G   6% /
devtmpfs       devtmpfs   16G     0   16G   0% /dev
tmpfs          tmpfs      16G     0   16G   0% /dev/shm
efivarfs       efivarfs  256K   94K  158K  38% /sys/firmware/efi/efivars
tmpfs          tmpfs     6.3G  2.0M  6.3G   1% /run
none           tmpfs     1.0M     0  1.0M   0% /run/credentials/systemd-journald.service
tmpfs          tmpfs      16G  8.0K   16G   1% /tmp
/dev/sda3      btrfs     140G  7.1G  132G   6% /.snapshots
/dev/sda3      btrfs     140G  7.1G  132G   6% /srv
/dev/sda3      btrfs     140G  7.1G  132G   6% /home
/dev/sda3      btrfs     140G  7.1G  132G   6% /usr/local
/dev/sda3      btrfs     140G  7.1G  132G   6% /var
/dev/sda3      btrfs     140G  7.1G  132G   6% /root
/dev/sda4      xfs       233G  4.5G  229G   2% /opt
/dev/sda2      ext4      1.8G  105M  1.6G   7% /boot
/dev/sda1      vfat      477M  100M  378M  21% /boot/efi
none           tmpfs     1.0M     0  1.0M   0% /run/credentials/getty@tty1.service
tmpfs          tmpfs     3.2G   72K  3.2G   1% /run/user/1000


Thursday, October 29, 2026

Tuning HDMI Monitors to work flawlessly with OpenSUSE Tumbleweed ( Assisted by Google AI )

   openSUSE defaults to hostonly="yes": openSUSE aggressively optimizes for ramdisk size and boot speed. When you run an openSUSE installer over SSH or text mode, YaST builds an initramfs tailored strictly to the hardware it detected as active during that specific install phase. Since you bypassed the graphical display pipeline during the text/SSH run, openSUSE's Dracut config frequently omits the full-featured open-source video drivers and associated firmware, fallback-loading a basic VESA framebuffer (which locks you at 800x600). 

 You can force openSUSE to match Fedora's robust driver behaviors by purging the restricted flags and forcing Dracut to build a comprehensive, unconstrained ramdisk. 

For instance 

$ cat /proc/cmdline
$ cat /proc/cmdline | grep nomodeset
$ sudo nano /etc/default/grub
$ which dracut

$ echo 'hostonly="no"' | sudo tee /etc/dracut.conf.d/00-generic.conf

If you want a small ramdisk but want to force legacy drivers to include anyway

$ echo 'add_drivers+=" nouveau amdgpu radeon i915 "' | sudo tee /etc/dracut.conf.d/00-generic.conf
$ sudo cat /etc/dracut.conf.d/00-generic.conf
$ sudo dracut -f --regenerate-all

Reboot && Attach modern Monitor via HDMI port


boris@localhost:~> xrandr | grep '*'
WARNING: running xrandr against an Xwayland server. See the xrandr man page for details.
   1920x1080     59.96*+
oris@localhost:~> xdpyinfo | grep 'dimensions:'
  dimensions:    1920x1080 pixels (508x285 millimeters)

For KDE Plasma (Wayland)

boris@localhost:~> kscreen-doctor --outputs
Output: 1 HDMI-A-1 3009548e-124a-4193-b142-47da4d280632
       enabled
       connected
       priority 1
       HDMI
       replication source:
0
       Modes:  1:1920x1080@60.00*  2:1920x1080@59.94  3:1920x1080@60.00!  4:1920x1080@59.94  5:1920x1080@50.00  6:1920x1080@50.00  7:1
280x1024@75.03  8:1280x1024@60.02  9:1280x960@60.00  10:1280x720@60.00  11:1280x720@59.94  12:1280x720@50.00  13:1024x768@75.03  14:102
4x768@70.07  15:1024x768@60.00  16:800x600@75.00  17:800x600@72.19  18:800x600@60.32  19:720x576@50.00  20:720x480@60.00  21:720x480@59
.94  22:640x480@75.00  23:640x480@72.81  24:640x480@60.00  25:640x480@59.94  
       Custom modes: None
       Geometry: 0,0 1920x1080
       Scale: 1
       Rotation: 1
       Overscan: 0
       Vrr: incapable
       RgbRange: unknown
       HDR: incapable
       Wide Color Gamut: incapable
       ICC profile: none
       Color profile source: sRGB
       Color power preference: prefer efficiency and performance
       Brightness control: supported, set to 100% and dimming to 100%
       Color resolution: unknown
       Allow EDR: unsupported
       Sharpness control: unsupported
       Automatic brightness: unsupported
       Auto Rotate Policy: incapable
       Adaptive backlight modulation: unsupported

























Friday, October 23, 2026

Convertion F45 Server to Thin XFS LVM Provisioning with Libvirt-Hooks based on BTRFS-XFS Setup ( Assisted by Google AI )

UPDATE as of 10/30/26  

See Tuning HDMI Monitors to work flawlessly with OpenSUSE Tumbleweed 

END UPDATE 

                                        
 Converting a server (such as a high-density virtualization platform) to Thin XFS LVM Provisioning with Libvirt-Hooks solves the fundamental performance bottlenecks and management complexities inherent in running virtual machines on top of a native or hybrid Btrfs storage architecture.
While Btrfs excels at features like transparent compression, file-level subvolumes, and data scrubbing, its structural design makes it highly inefficient for heavy virtual machine disk (.qcow2 or .img) storage. Moving to a thin-provisioned LVM layer running XFS-orchestrated dynamically via Libvirt event hooks - provides enterprise-grade predictability, raw block speed, and automated lifecycle management.

The core issue with openSUSE Tumbleweed is problem with native HDMI Monitors support. OverlayFS may be setup on F45 Server on top of mixed BTRFS/XFS layout as shown below and you would have an option with Btrfs low level CLI (mv,snaphot commands) to rollback the main instance to previous safe state via Overlay instances available as options provided by Grub submenu. However, BTRFS support on F45 will stay as experimental feature vs Enterprise grade solutions provided by Suse flavors headless servers.

Final disk layout ( bare metal case )

root@server45fedora:~# hostnamectl
     Static hostname: server45fedora
           Icon name: computer-desktop
             Chassis: desktop
   Chassis Asset Tag: To be filled by O.E.M.
          Machine ID: c97053a998854caa9178705b31914bc3
             Boot ID: 17bfefb60d0b4623a61b0bc44157819b
        Product UUID: af95be8a-eace-8515-aaa1-00d861d9318b
    Operating System: Fedora Linux 45 (Server Edition)
         CPE OS Name: cpe:/o:fedoraproject:fedora:45
      OS Support End: Wed 2027-11-24
OS Support Remaining: 1y 1month
              Kernel: Linux 7.2.11-300.fc45.x86_64
        Architecture: x86-64
     Hardware Vendor: Micro-Star International Co., Ltd.
      Hardware Model: MS-7C37
     Hardware Serial: To be filled by O.E.M.
    Hardware Version: 3.0
    Firmware Version: H.60
       Firmware Date: Wed 2019-11-06
        Firmware Age: 6y 11month 2w 3d
root@server45fedora:~# findmnt -t btrfs
TARGET   SOURCE                   FSTYPE OPTIONS
/        /dev/nvme0n1p4[/@-0]     btrfs  rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@-0
├─/.snapshots
│        /dev/nvme0n1p4[/snapshots]
│                                 btrfs  rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/snapsho
├─/etc/libvirt/qemu
│        /dev/nvme0n1p4[/@qemu]   btrfs  rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=267,subvol=/@qemu
├─/home  /dev/nvme0n1p4[/@home]   btrfs  rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@home
├─/var/cache
│        /dev/nvme0n1p4[/@cache]  btrfs  rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@cache
└─/var/log
         /dev/nvme0n1p4[/@log]    btrfs  rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@log
root@server45fedora:~# lsblk -f
NAME                               FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
sr0
zram0                              swap        1        zram0 10432693-2e2c-4c5c-8f6e-01f787c76c37                  [SWAP]
nvme1n1  ( Tumbleweed drive )
├─nvme1n1p1                        vfat        FAT32          61BC-A4BF
├─nvme1n1p2                        ext4        1.0            c6a99ff4-3bf8-4d50-809f-db6259935a55
├─nvme1n1p3                        LVM2_member LVM2 001       aMgkVz-72ia-dHzo-8Q2p-haHX-VoKU-bv5Bce
│ ├─vg_suse-tp_suse_kvm_tmeta
│ │ └─vg_suse-tp_suse_kvm-tpool
│ │   ├─vg_suse-tp_suse_kvm
│ │   └─vg_suse-vol_suse_thin      xfs                        0f543732-acde-4d36-bc88-b75e9e8c8cc4
│ └─vg_suse-tp_suse_kvm_tdata
│   └─vg_suse-tp_suse_kvm-tpool
│     ├─vg_suse-tp_suse_kvm
│     └─vg_suse-vol_suse_thin      xfs                        0f543732-acde-4d36-bc88-b75e9e8c8cc4
└─nvme1n1p4                        btrfs                      800c9083-38bd-4fab-b916-0bce438442ab
nvme0n1  ( F45 Server's drive )
├─nvme0n1p1                        vfat        FAT32          E005-797D                               590.9M     1% /boot/efi
├─nvme0n1p2                        ext4        1.0            d2c18aab-3ead-4abe-b1a4-9ef47b6b61a4      1.2G    29% /boot
├─nvme0n1p3                        LVM2_member LVM2 001       EuwX4s-zJJ3-eL0g-IsAi-AmJC-Z7XI-bxomP6
│ ├─vg_fedora-tp_fedora_kvm_tmeta
│ │ └─vg_fedora-tp_fedora_kvm-tpool
│ │   │
│ │   ├─vg_fedora-tp_fedora_kvm
│ │   └─vg_fedora-vol_fedora_thin  xfs                        f13011c1-1835-4347-addc-8f37b23475a6    142.3G     6% /var/lib/libvirt/images
│ └─vg_fedora-tp_fedora_kvm_tdata
│   └─vg_fedora-tp_fedora_kvm-tpool
│     │
│     ├─vg_fedora-tp_fedora_kvm
│     └─vg_fedora-vol_fedora_thin  xfs                        f13011c1-1835-4347-addc-8f37b23475a6    142.3G     6% /var/lib/libvirt/images
└─nvme0n1p4                        btrfs                      ff4229bc-cf09-4b53-8edc-52611c83c4f5    248.9G     8% /var/log
                                                                                                                    /var/cache
                                                                                                                    /home
                                                                                                                    /etc/libvirt/qemu
                                                                                                                    /.snapshots
#########################################################
Convertion XFS partition been setup via Anaconda deployment phase into Thin XFS provisioned LVM  via reinitializing  #########################################################
 
# 1. Ensure the target NVMe partition is completely clean
sudo umount /dev/nvme0n1p3 2>/dev/null
sudo wipefs --all /dev/nvme0n1p3

# 2. Bind the NVMe partition to LVM with 500M metadata room
sudo pvcreate --metadatasize 500M /dev/nvme0n1p3

# 3. Create your dedicated vg_fedora Volume Group container
sudo vgcreate vg_fedora /dev/nvme0n1p3

# 4. Instantiate the Thin Pool (Using 152G to respect 80/20 strategy buffer)
sudo lvcreate -L 152G --chunksize 128K --thinpool tp_fedora_kvm vg_fedora

# 5. Carve out the virtual thin volume named 'vol_fedora_thin'
sudo lvcreate -n vol_fedora_thin -V 152G --thinpool vg_fedora/tp_fedora_kvm

# Format the thin volume enabling fast VFS-level copy-on-write pointer sharing
sudo mkfs.xfs -K -m reflink=1,crc=1 /dev/vg_fedora/vol_fedora_thin


sudo mkdir -p /var/lib/libvirt/images

# Append your optimized thin block map permanently into the layout tables
echo '/dev/vg_fedora/vol_fedora_thin   /var/lib/libvirt/images xfs defaults,noatime,logbufs=8,logbsize=256k 0 0' | sudo tee -a /etc/fstab

# Rebuild systemd configuration targets and mount the new thin pool volume
sudo systemctl daemon-reload
sudo mount -a

##################################################                                     Create the target nested storage hierarchy
##################################################                                                                
 
Apply strict operational permissions for the libvirt engine
sudo chown root:root /var/lib/libvirt
sudo chmod 711 /var/lib/libvirt
sudo chmod 711 /var/lib/libvirt/images

# Apply SELinux context rules for KVM operation on Fedora
sudo semanage fcontext -a -t virt_image_t "/var/lib/libvirt/images(/.*)?" 2>/dev/null || true
sudo restorecon -R -v /var/lib/libvirt/images


System reboot
 
########################################################
Creating /etc/libvirt/hooks/qemu and service lvm-thin-snapshot.service                                                  ########################################################
 
root@fedoraSRV:~# cat /etc/libvirt/hooks/qemu
#!/bin/bash
GUEST_NAME="$1"
ACTION="$2"
PHASE="$3"
STORAGE_DIR="/var/lib/libvirt/images"
BACKUP_DIR="${STORAGE_DIR}/.snapshots_${GUEST_NAME}"
 
[ ! -d "$STORAGE_DIR" ] && exit 0
 
if [ "$ACTION" = "prepare" ] || [ "$ACTION" = "stopped" ]; then
    /usr/bin/systemctl start lvm-thin-snapshot.service &
 
    (
        /usr/bin/sleep 2
        /usr/bin/mkdir -p "$BACKUP_DIR"
 
        for disk_path in "${STORAGE_DIR}"/*"${GUEST_NAME}"*.qcow2; do
            [ ! -f "$disk_path" ] && continue
            disk_file=$(/usr/bin/basename "$disk_path")
            timestamp=$(/usr/bin/date +%Y%m%d_%H%M%S)
 
            /usr/bin/cp --reflink=always "$disk_path" "${BACKUP_DIR}/${disk_file}.snap_${timestamp}"
 
            # FEDORA FIX: Match Fedora execution user account permissions
            /usr/bin/chown qemu:qemu "${BACKUP_DIR}/${disk_file}.snap_${timestamp}" 2>/dev/null
        done
 
        /usr/bin/ls -tp "${BACKUP_DIR}"/* | /usr/bin/grep -v '/$' | /usr/bin/tail -n +6 | /usr/bin/xargs -I {} /usr/bin/rm -- "{}" 2>/dev/null
    ) & disown
 
elif [ "$ACTION" = "define" ] || [ "$ACTION" = "undefine" ]; then
    /usr/bin/systemctl start lvm-thin-snapshot.service &
fi
 
exit 0

 
root@fedoraSRV:~# cat /etc/systemd/system/lvm-thin-snapshot.service
[Unit]
Description=Rotate Pristine LVM Thin Pool Snapshot on Libvirt Changes
After=local-fs.target
 
[Service]
Type=oneshot
User=root
Environment=VG_NAME=vg_fedora
Environment=SNAP_NAME=snap_working_vms
Environment=THIN_VOL=vol_fedora_thin
Environment=IMG_DIR=/var/lib/libvirt/images
 
ExecStart=/bin/bash -c '\
    echo "Current allocated qcow2 image count: $(ls -1 ${IMG_DIR}/*.qcow2 2>/dev/null | wc -l)"; \
    echo "Removing old snapshot if present..."; \
    /usr/sbin/lvremove -f "${VG_NAME}/${SNAP_NAME}" 2>/dev/null || true; \
    echo "Creating pristine baseline snapshot..."; \
    /usr/sbin/lvcreate -s --name "${SNAP_NAME}" "${VG_NAME}/${THIN_VOL}"'
 
[Install]
WantedBy=multi-user.target 
 
################################
Healthy system status verification
################################
root@server45fedora:~# ls -Zla  /var/lib/libvirt/images
total 6730604
drwxr-xr-x. 4 root root system_u:object_r:virt_image_t:s0           112 Oct 23 11:32 .
drwx--x--x. 1 root root system_u:object_r:virt_var_lib_t:s0         118 Sep 28 14:43 ..
-rw-------. 1 qemu qemu system_u:object_r:virt_image_t:s0   21478375424 Oct 23 11:59 ArchPlasma.qcow2
-rw-------. 1 qemu qemu system_u:object_r:virt_image_t:s0   21478375424 Oct 23 11:31 ArchServer.qcow2
drwxr-xr-x. 2 root root system_u:object_r:virt_image_t:s0          4096 Oct 23 11:59 .snapshots_ArchPlasma
drwxr-xr-x. 2 root root system_u:object_r:virt_image_t:s0          4096 Oct 23 11:31 .snapshots_ArchServer 
 
############################################################
FEDORA 45 UNIVERSAL GLOBAL DISASTER RECOVERY ENGINE  (ZERO XML EDITS) 
############################################################ 
 #!/bin/bash

set -e
 
TARGET_MNT="/var/lib/libvirt/images"
VG_NAME="vg_fedora"
THIN_VOL="vol_fedora_thin"
SNAP_NAME="snap_working_vms"
GUEST_NAME="ArchServer" # Simply toggle this variable to match your target VM name
 
echo "=== PHASE 1: RE-ARM IMMUNE STORAGE MATRIX BASELINE ==="
sudo lvremove -f ${VG_NAME}/${SNAP_NAME} 2>/dev/null || true
sudo lvcreate -s --name ${SNAP_NAME} ${VG_NAME}/${THIN_VOL}
sudo lvs ${VG_NAME}
 
echo "=== PHASE 2: CATASTROPHIC DISASTER SIMULATION ==="
sudo virsh destroy ${GUEST_NAME} 2>/dev/null || true
 
echo "==> Waiting for hook script background backup copy to complete..."
while pgrep -f "cp --reflink=always" >/dev/null || systemctl is-active --quiet lvm-thin-snapshot.service; do
    sleep 2
done
echo "==> Hook script finished! Storage layer is quiet."

 
# Dynamically find and corrupt ONLY the disks belonging to the targeted VM
for disk in ${TARGET_MNT}/*"${GUEST_NAME}"*.qcow2; do
    [ ! -f "$disk" ] && continue
    echo "==> Corrupting: $(basename "$disk")"
    sudo dd if=/dev/urandom of="$disk" bs=1M count=500 conv=notrunc
done
 
echo "=== PHASE 3: SYNCHRONOUS WAIT-FOR-EXIT CODE FENCE ==="
sudo systemctl stop virtqemud.socket virtqemud-ro.socket virtqemud-admin.socket virtqemud.service 2>/dev/null || true
sudo pkill -9 qemu 2>/dev/null || true
sudo fuser -kM "${TARGET_MNT}" 2>/dev/null || true
 
echo "==> Executing standard physical unmount loop..."
COUNTER=1
while [ $COUNTER -le 20 ]; do
    if sudo umount ${TARGET_MNT} 2>/dev/null; then
        echo "==> SUCCESS: Filesystem detached cleanly with exit code 0."
        break
    fi
    sleep 3
    COUNTER=$((COUNTER + 1))
done
 
if [ $COUNTER -gt 20 ]; then
    exit 1
fi
 
echo "=== PHASE 4: ATOMIC METADATA MERGE ==="
sudo lvconvert --merge ${VG_NAME}/${SNAP_NAME}


echo "=== PHASE 5: PURGE TRANSIENT GRAPH FILES & FIX SECURITY ==="
sudo mount ${TARGET_MNT}
 
# 1. Force the kernel and storage layers to settle after the merge mount
sudo udevadm settle
sync
 
# 2. ISOLATED CLEANUP: Clear background tokens ONLY for the targeted guest
sudo rm -f ${TARGET_MNT}/*"${GUEST_NAME}"*.lock 2>/dev/null
sudo rm -f /var/run/libvirt/qemu/"${GUEST_NAME}".xml 2>/dev/null
sudo rm -rf /var/cache/libvirt/qemu/"${GUEST_NAME}" 2>/dev/null
sudo rm -rf /var/lib/libvirt/qemu/remembered/"${GUEST_NAME}" 2>/dev/null
 
# 3. FIXED & COMPREHENSIVE XATTR PURGE: Completely strip ALL hidden libvirt security keys
echo "==> Clearing all hidden libvirt security locks from ${GUEST_NAME}..."
for disk in ${TARGET_MNT}/*"${GUEST_NAME}"*.qcow2; do
    [ ! -f "$disk" ] && continue
    # This loops through and aggressively drops any trusted.libvirt keys frozen in the file metadata
    sudo getfattr -m "trusted.libvirt.security" --dump "$disk" 2>/dev/null | grep -oP '^trusted\.libvirt\.security\.[a-z_]+' | while read -r attr; do
        sudo setfattr -x "$attr" "$disk" 2>/dev/null || true
    done
done
 
# 4. TARGETED SECURITY REMAPPING: Process ONLY the targeted VM files
echo "==> Resetting permissions and SELinux contexts strictly for ${GUEST_NAME}..."
for disk in ${TARGET_MNT}/*"${GUEST_NAME}"*.qcow2; do
    [ ! -f "$disk" ] && continue
    sudo chown qemu:qemu "$disk"
    sudo chmod 600 "$disk"
 
    # Restore standard system-defined defaults so Libvirt can assign dynamic labels cleanly
    sudo restorecon -Fv "$disk"
done

 
# Restart systemd cgroup containment tracking profiles safely
sudo systemctl restart systemd-machined
sleep 2
 
# Re-activate the modular listener sockets
sudo systemctl start virtqemud.socket virtqemud-ro.socket virtqemud-admin.socket virtqemud.service
sleep 1
 
echo "=== PHASE 6: POWER ON RECOVERED GUEST ==="
# Verify if the domain state registry dropped during the socket tear-down
if sudo virsh list --all | grep -qw "${GUEST_NAME}"; then
    sudo virsh start ${GUEST_NAME}
else
    echo "==> Re-registering transient XML map for ${GUEST_NAME}..."
    sudo virsh define /etc/libvirt/qemu/"${GUEST_NAME}".xml 2>/dev/null || true
    sudo virsh start ${GUEST_NAME}
fi
 

 

 
 
 

Thursday, October 22, 2026

Thin XFS LVs provisioning and Libvirt hooks for State Isolated KVM Server on Debian forky

Following below is review/verification approach to Thin XFS LVs provisioning and Libvirt hooks proposed by Google AI. This post is an immediate follow up of  https://lxer.com/module/newswire/view/368300/index.html  . Regarding Debian forky OverlayFS BTRFS/XFS setup see https://lxer.com/module/newswire/view/368197/index.html                                                                                          

Version of /etc/libvirt/hooks/qemu for Debian 14 

root@debian14forky:~# cat /etc/libvirt/hooks/qemu
#!/bin/bash
GUEST_NAME="$1"
ACTION="$2"
PHASE="$3"
STORAGE_DIR="/var/lib/libvirt/images"
BACKUP_DIR="${STORAGE_DIR}/.snapshots_${GUEST_NAME}"

[ ! -d "$STORAGE_DIR" ] && exit 0

# --- State Changes Layer: Reflink Clones ---
if [ "$ACTION" = "prepare" ] || [ "$ACTION" = "stopped" ]; then
   # Fire off the automated LVM snapshot service asynchronously
   /usr/bin/systemctl start lvm-thin-snapshot.service &

   (
       /usr/bin/sleep 2
       /usr/bin/mkdir -p "$BACKUP_DIR"

       for disk_path in "${STORAGE_DIR}"/*"${GUEST_NAME}"*.qcow2; do
           [ ! -f "$disk_path" ] && continue
           disk_file=$(/usr/bin/basename "$disk_path")
           timestamp=$(/usr/bin/date +%Y%m%d_%H%M%S)

           # Atomic copy-on-write VFS creation
           /usr/bin/cp --reflink=always "$disk_path" "${BACKUP_DIR}/${disk_file}.snap_${timestamp}"
            
           # Align permissions with Debian virtual user accounts
           /usr/bin/chown libvirt-qemu:kvm "${BACKUP_DIR}/${disk_file}.snap_${timestamp}" 2>/dev/null
       done

       # Keep the last 5 operational states
       /usr/bin/ls -tp "${BACKUP_DIR}"/* | /usr/bin/grep -v '/$' | /usr/bin/tail -n +6 | /usr/bin/xargs -I {} /usr/bin/rm -- "{}" 2>/dev/null
   ) & disown

# --- Domain Mapping Tracking: Define/Undefine ---
elif [ "$ACTION" = "define" ] || [ "$ACTION" = "undefine" ]; then
   /usr/bin/systemctl start lvm-thin-snapshot.service &
fi

exit 0

root@debian14forky:~# cat /etc/systemd/system/lvm-thin-snapshot.service
[Unit]
Description=Rotate Pristine LVM Thin Pool Snapshot on Libvirt Changes
After=local-fs.target

[Service]
Type=oneshot
User=root
Environment=VG_NAME=vg_debian
Environment=SNAP_NAME=snap_working_vms
Environment=THIN_VOL=vol_debian_thin
Environment=IMG_DIR=/var/lib/libvirt/images

ExecStart=/bin/bash -c '\
   echo "Current allocated qcow2 image count: $(ls -1 ${IMG_DIR}/*.qcow2 2>/dev/null | wc -l)"; \
   echo "Removing old snapshot if present..."; \
   /usr/sbin/lvremove -f "${VG_NAME}/${SNAP_NAME}" 2>/dev/null || true; \
   echo "Creating pristine baseline snapshot..."; \
   /usr/sbin/lvcreate -s --name "${SNAP_NAME}" "${VG_NAME}/${THIN_VOL}"'

[Install]
WantedBy=multi-user.target

 
Version of Recovery from simulated disaster for Debian forky

root@debian14forky:~# cat ./virtSetup016_debian
#!/bin/bash
#=============================================================
# DEBIAN 14 PRODUCTION DISASTER RECOVERY ENGINE (SYNCHRONOUS FENCED)
#=============================================================
set -e

TARGET_MNT="/var/lib/libvirt/images"
VG_NAME="vg_debian"
THIN_VOL="vol_debian_thin"
SNAP_NAME="snap_working_vms"
GUEST_NAME="ArchPlasma" # Toggle to "ArchPlasma" when testing the other VM

echo "=== PHASE 1: RE-ARM IMMUNE STORAGE MATRIX BASELINE ==="
# Forcefully clear stale snapshots and index the current healthy file footprint
sudo lvremove -f ${VG_NAME}/${SNAP_NAME} 2>/dev/null || true
sudo lvcreate -s --name ${SNAP_NAME} ${VG_NAME}/${THIN_VOL}
sudo lvs ${VG_NAME}

echo "=== PHASE 2: CATASTROPHIC DISASTER SIMULATION ==="
sudo virsh destroy ${GUEST_NAME} 2>/dev/null || true

# Hook check loop: wait for the asynchronous VFS reflink lifecycle copy to finish
echo "==> Waiting for hook script background backup copy to complete..."
while pgrep -f "cp --reflink=always" >/dev/null || systemctl is-active --quiet lvm-thin-snapshot.service; do
   echo "    [WAIT] Hook script is actively saving safety copies. Stalling 2 seconds..."
   sleep 2
done
echo "==> Hook script finished! Storage layer is quiet."

# Catastrophically corrupt the target virtual disk image with random blocks
sudo dd if=/dev/urandom of=${TARGET_MNT}/${GUEST_NAME}.qcow2 bs=1M count=500 conv=notrunc

echo "=== PHASE 3: SYNCHRONOUS WAIT-FOR-EXIT CODE FENCE ==="
# Sever the monolithic hypervisor interfaces and persistent socket networks
sudo systemctl stop libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket libvirtd.service 2>/dev/null || true
sudo pkill -9 qemu 2>/dev/null || true
sudo fuser -kM "${TARGET_MNT}" 2>/dev/null || true

echo "==> Initiating standard physical unmount loop..."
COUNTER=1
while [ $COUNTER -le 20 ]; do
   echo "    [TRY $COUNTER/20] Testing standard umount..."
   if sudo umount ${TARGET_MNT} 2>/dev/null; then
       echo "==> SUCCESS: Filesystem detached cleanly with exit code 0."
       break
   fi
   echo "    [WAIT] Kernel block maps busy. Stalling 3 seconds for clean flush..."
   sleep 3
   COUNTER=$((COUNTER + 1))
done


if [ $COUNTER -gt 20 ]; then
   echo "ERROR: Kernel refused to release filesystem within 60 seconds. Aborting."
   exit 1
fi

echo "=== PHASE 4: ATOMIC METADATA MERGE ==="
# Because the mount is completely dead, this block merge commits instantly
sudo lvconvert --merge ${VG_NAME}/${SNAP_NAME}

echo "=== PHASE 5: PURGE VOLATILE DESCRIPTORS & RE-ALIGN SECURITY ==="
sudo mount ${TARGET_MNT}

# Clear any deadlocked lock templates and volatile state trackers
sudo rm -f ${TARGET_MNT}/*.lock 2>/dev/null
sudo rm -rf /var/run/libvirt/qemu/* 2>/dev/null
sudo rm -rf /var/cache/libvirt/qemu/* 2>/dev/null

# Re-align user attributes explicitly to Debian's privilege accounts
sudo chown libvirt-qemu:kvm ${TARGET_MNT}/${GUEST_NAME}.qcow2
sudo chmod 600 ${TARGET_MNT}/${GUEST_NAME}.qcow2

# TEMPORARY SECURITY OVERRULE: Bypass stale DAC memory cache issues on ignition
sudo virsh dumpxml ${GUEST_NAME} > /tmp/${GUEST_NAME}_recovery.xml 2>/dev/null || true
if ! grep -q 'seclabel type="none"' /tmp/${GUEST_NAME}_recovery.xml 2>/dev/null; then
   sed -i '/<\/devices>/a \  <seclabel type="none" model="dac"\/>' /tmp/${GUEST_NAME}_recovery.xml 2>/dev/null || true
   sudo virsh undefine ${GUEST_NAME} 2>/dev/null || true
   sudo virsh define /tmp/${GUEST_NAME}_recovery.xml >/dev/null 2>&1 || true
fi
rm -f /tmp/${GUEST_NAME}_recovery.xml

# Restart systemd cgroups and restore daemon listen layers
sudo systemctl restart systemd-machined
sudo systemctl start libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket libvirtd.service

echo "=== PHASE 6: POWER ON RECOVERED GUEST ==="
sudo virsh start ${GUEST_NAME}
echo "==========================================="
sudo virsh list --all


 

Monday, October 19, 2026

Thin XFS LVs provisioning and Libvirt hooks for State Isolated KVM Server on openSUSE Tumbleweed

UPDATE as of 10/21/26  

Please, see  update at the bottom of original post, which allows to avoid in recreating of "snap_working_vms" at user's side 

See also Thin XFS LVs provisioning and Libvirt hooks for State Isolated KVM Server on Debian forky  

END UPDATE 

Following below is review/verification approach to Thin XFS LVs provisioning and Libvirt hooks proposed by Google AI. In case of openSUSE Tumbleweed YaST Installer requires minimal manual CLI intervention due to GUI interface enables thin pools and thin LVs . In case Debian 14 network installation you have an option to associate vg_debian group with physical volume. All command stack is supposed to be executed manually upon instance reboot. 

   Yast Installer and Debian Installer behaves the same way in VENV and on bare metal performing relatively complicated BTRFS/XFS partitioning schema pretty stable. In case of Debian forky OverlayFS BTRFS/XFS setup is required ( see https://lxer.com/module/newswire/view/368197/index.html ). On openSUSE Tumbleweed you are protected by Enterprise grade BTRFS implementation (sudo snapper rollback safe-ID) 

Final disk layout



==============================================
Actually, YaST installer in GUI mode executes
==============================================
# Initialize the partition for LVM ingestion
sudo pvcreate --metadatasize 500M /dev/nvme0n1p3
 
# Instantiate your dedicated vg_suse Volume Group container
sudo vgcreate vg_suse /dev/nvme0n1p3
 
# Carve out a 180G (for instance) Thin Pool reservoir tracking array
sudo lvcreate -L 180G --thinpool tp_suse_kvm vg_suse
 
# Slice out the final Thin Volume utilizing the full pool size
sudo lvcreate -V 180G --name vol_suse_thin --thinpool vg_suse/tp_suse_kvm
You may also decouple @qemu subvolume mounted @/etc/libvirt/qemu in YaST installer partitioning phase via embedded GUI interface.
===================================================
Vol_suse_thin shouldn't be formatted and mounted
Upon reboot to Tumbleweed instance to run manually
===================================================
# Format the thin volume enabling fast VFS-level copy-on-write pointer sharing
sudo mkfs.xfs -K -m reflink=1,crc=1 /dev/vg_suse/vol_suse_thin
 
# Purge the old physical device configuration lines from your system map
sudo sed -i '\/opt/d' /etc/fstab
 
# Append your optimized thin block map permanently into the layout tables
echo '/dev/vg_suse/vol_suse_thin   /opt   xfs defaults,noatime,logbufs=8,logbsize=256k 0 0' | sudo tee -a /etc/fstab
 
# Rebuild systemd configuration targets and mount the new thin pool volume
sudo systemctl daemon-reload
sudo mount -a
 
===================================================
Debian Network installer in GUI mode executes only
===================================================
# Instantiate your dedicated vg_debian Volume Group container
sudo vgcreate vg_suse /dev/nvme0n1p3
# Initialize the partition for LVM ingestion
sudo pvcreate --metadatasize 500M /dev/nvme0n1p3
# Instantiate your dedicated vg_deabin Volume Group container
sudo vgcreate vg_debian /dev/nvme0n1p3
 
The rest CLI stack of commands remains your responsibility
upon reboot
=================================================
When KVM Hypervisor is installed on Tumbleweed ( Debain forky) You are supposed to create Libvirt hook
=================================================
# cat /etc/libvirt/hooks/qemu
#!/bin/bash
GUEST_NAME="$1"
ACTION="$2"
PHASE="$3"
STORAGE_DIR="/opt/libvirt/images"
BACKUP_DIR="${STORAGE_DIR}/.snapshots_${GUEST_NAME}"
 
[ ! -d "$STORAGE_DIR" ] && exit 0
 
if [ "$ACTION" = "prepare" ] || [ "$ACTION" = "stopped" ]; then
   (
       /usr/bin/sleep 2
       /usr/bin/mkdir -p "$BACKUP_DIR"
 
       for disk_path in "${STORAGE_DIR}"/*"${GUEST_NAME}"*.qcow2; do
           [ ! -f "$disk_path" ] && continue
           disk_file=$(/usr/bin/basename "$disk_path")
           timestamp=$(/usr/bin/date +%Y%m%d_%H%M%S)
 
           # Atomic VFS copy-on-write pointer creation
           /usr/bin/cp --reflink=always "$disk_path" "${BACKUP_DIR}/${disk_file}.snap_${timesta
mp}"
           /usr/bin/chown qemu:qemu "${BACKUP_DIR}/${disk_file}.snap_${timestamp}" 2>/dev/null
       done
 
       # Prune older operational states, retaining the last 5 configurations
       /usr/bin/ls -tp "${BACKUP_DIR}"/* | /usr/bin/grep -v '/$' | /usr/bin/tail -n +6 | /usr/bin/xargs -I {} /usr/bin/rm -- "{}" 2>/dev/null
   ) & disown
fi
exit 0
===================================
Expected disklayout on both systems
===================================
boris@fedoraServer091026:~$ ssh boris@192.168.0.30
(boris@192.168.0.30) Password:
Last login: Mon Oct 19 18:04:57 MSK 2026 on tty2
Have a lot of fun...
boris@localhost:~> lsblk -f
NAME                            FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
sr0
vda
├─vda1                          vfat        FAT32          C7FA-229F                               406.3M    20% /boot/efi
├─vda2                          ext4        1.0            ce25d513-c727-41fc-b3d7-d65454842064      1.7G     4% /boot
├─vda3                          LVM2_member LVM2 001       QtA4KW-Basj-r1MV-rGny-gDMX-pFzK-WbtgvK
│ ├─vg_suse-tp_suse_kvm_tmeta
│ │ └─vg_suse-tp_suse_kvm-tpool
│ │   ├─vg_suse-tp_suse_kvm
│ │   └─vg_suse-vol_suse_thin   xfs                        c43d95f3-5e09-46d8-b14a-1790879a27fd     65.4G     9% /opt
│ └─vg_suse-tp_suse_kvm_tdata
│   └─vg_suse-tp_suse_kvm-tpool
│     ├─vg_suse-tp_suse_kvm
│     └─vg_suse-vol_suse_thin   xfs                        c43d95f3-5e09-46d8-b14a-1790879a27fd     65.4G     9% /opt
└─vda4                          btrfs                      59c74873-c215-4123-9212-d7242087e5e9     39.7G    18% /usr/local
                                                                                                                 /srv
                                                                                                                 /var
                                                                                                                 /home
                                                                                                                 /root
                                                                                                                 /etc/libvirt/qemu
                                                                                                                 /.snapshots
                                                                                                                 /
=======================================================
Recovery from emulated qcow2 corruption in libvirt-pool. Default libvirt-pool location is /opt/libvirt/images on thin XFS LV. That is due to limitation of YaST installer.  Debian 14 network installer allows you to mount /var/lib/libvirt/images on thin XFS LV in post installation phase prior of KVM Hypervisor setup.
=======================================================
localhost:~ # cat ArchServerRecovery.sh
#!/bin/bash
set -Eeuo pipefail
 
# Configuration Matrix
VM_NAME="ArchServer"
DISK_PATH="/opt/libvirt/images/ArchServer.qcow2"
VG_NAME="vg_suse"
SNAP_NAME="snap_working_vms"
THIN_VOL="vol_suse_thin"
 
echo "=== PHASE 1: PREPARING CLEAN ENVIRONMENT ==="
echo "Stopping ${VM_NAME}..."
sudo virsh shutdown "$VM_NAME"
 
echo "Waiting for VM to fully power off and release file locks..."
while [ "$(sudo virsh domstate "$VM_NAME" | tr -d '\r\n ')" != "shutoff" ]; do
    sleep 1
done
 
echo "Removing old snapshot if present..."
sudo lvremove -f "${VG_NAME}/${SNAP_NAME}" 2>/dev/null || true
 
echo "Creating pristine baseline snapshot..."
sudo lvcreate -s --name "$SNAP_NAME" "${VG_NAME}/${THIN_VOL}"
sudo lvs "$VG_NAME"
 
echo -e "\n=== PHASE 2: SIMULATING DATA DESTRUCTION DRILL ==="
echo "Injecting 500MB of pure entropy into the qcow2 block architecture..."
sudo dd if=/dev/urandom of="$DISK_PATH" bs=1M count=500 conv=notrunc
sync
 
echo -e "\n=== PHASE 3: OFFLINE BLOCK STORAGE OVERHAUL ==="
echo "Stopping virtualization stack mechanisms..."
sudo systemctl stop virtqemud.service virtqemud.socket
sudo pkill -9 qemu 2>/dev/null || true
 
echo "Unmounting XFS target disk layer..."
sudo umount /opt
 
echo "Executing LVM thin snapshot rollback merge..."
sudo lvconvert --merge "${VG_NAME}/${SNAP_NAME}"
 
echo "Remounting pristine block matrix onto /opt..."
sudo mount /opt
 
echo -e "\n=== PHASE 4: DISK INTEGRITY VERIFICATION ==="
echo "Running validation checks on ${DISK_PATH}..."
 
# Run qemu-img check and capture internal report
if sudo qemu-img check "$DISK_PATH"; then
    echo "вњ… Success: LVM snapshot merge validated. Image is 100% clean."
else
    echo "CRITICAL: Integrity check failed! The disk image remains corrupted." >&2
    exit 1
fi
 
echo -e "\n=== PHASE 5: RUNTIME RESTORATION ==="
echo "Purging leftover runtime lock infrastructure files..."
sudo rm -f /opt/libvirt/images/*.lock 2>/dev/null || true
sudo rm -f /var/run/libvirt/qemu/*.xml 2>/dev/null || true
 
echo "Restarting containment profiling layers..."
sudo systemctl restart systemd-machined
sudo systemctl start virtqemud.socket virtqemud.service
 
echo "Powering on recovered virtual guest domain..."
sudo virsh start "$VM_NAME"
echo "=== DISASTER RECOVERY DRILL COMPLETE ==="

UPDATE as of 10/21/16 

localhost:~ # cat /etc/libvirt/hooks/qemu
#!/bin/bash
GUEST_NAME="$1"
ACTION="$2"
PHASE="$3"
STORAGE_DIR="/opt/libvirt/images"
BACKUP_DIR="${STORAGE_DIR}/.snapshots_${GUEST_NAME}"

[ ! -d "$STORAGE_DIR" ] && exit 0

# --- EXISTING LOGIC: Operational reflink snapshots on state changes ---
if [ "$ACTION" = "prepare" ] || [ "$ACTION" = "stopped" ]; then
    # 🔥 FIX FOR VIRT-MANAGER: Trigger snapshot service for GUI transitions too
    /usr/bin/systemctl start lvm-thin-snapshot.service &

    (
        /usr/bin/sleep 2
        /usr/bin/mkdir -p "$BACKUP_DIR"

        for disk_path in "${STORAGE_DIR}"/*"${GUEST_NAME}"*.qcow2; do
            [ ! -f "$disk_path" ] && continue
            disk_file=$(/usr/bin/basename "$disk_path")
            timestamp=$(/usr/bin/date +%Y%m%d_%H%M%S)

            # Atomic VFS copy-on-write pointer creation
            /usr/bin/cp --reflink=always "$disk_path" "${BACKUP_DIR}/${disk_file}.snap_${timestamp}"
            /usr/bin/chown qemu:qemu "${BACKUP_DIR}/${disk_file}.snap_${timestamp}" 2>/dev/null
        done

        # Prune older operational states, retaining the last 5 configurations
        /usr/bin/ls -tp "${BACKUP_DIR}"/* | /usr/bin/grep -v '/$' | /usr/bin/tail -n +6 | /usr/bin/xargs -I {} /usr/bin/rm -- "{}" 2>/dev/null
    ) & disown

# --- NEW LAYER: Handle LVM Thin Snapshot baseline shifts on VM creation/deletion ---
elif [ "$ACTION" = "define" ] || [ "$ACTION" = "undefine" ]; then
    # Fire off the systemd service asynchronously so libvirt loop is never locked
    /usr/bin/systemctl start lvm-thin-snapshot.service &
fi

exit 0
localhost:~ # cat /etc/systemd/system/lvm-thin-snapshot.service
[Unit]
Description=Rotate Pristine LVM Thin Pool Snapshot on Libvirt Changes
After=local-fs.target

[Service]
Type=oneshot
User=root
Environment=VG_NAME=vg_suse
Environment=SNAP_NAME=snap_working_vms
Environment=THIN_VOL=vol_suse_thin
Environment=IMG_DIR=/opt/libvirt/images

ExecStart=/bin/bash -c '\
    echo "Current allocated qcow2 image count: $(ls -1 ${IMG_DIR}/*.qcow2 2>/dev/null | wc -l)"; \
    echo "Removing old snapshot if present..."; \
    /usr/sbin/lvremove -f "${VG_NAME}/${SNAP_NAME}" 2>/dev/null || true; \
    echo "Creating pristine baseline snapshot..."; \
    /usr/sbin/lvcreate -s --name "${SNAP_NAME}" "${VG_NAME}/${THIN_VOL}"'

[Install]
WantedBy=multi-user.target