I needed to check the integrity of the file systems on several xen domU guests while the guests were shutdown, ie. I needed to do it from the dom0.
I use LVM logical volumes for the block devices for the guests disks named $host-disk0
. These are stored in a volume group named vg_guests
. I use kpartx to access the partitions on the block device.
Each guest disk has a small physical partition for /boot
; the rest of the disk is allocated to a 2nd partition which is used as an LVM volume group named vg_$host
.
Here's a script I knocked up to do the job:
for host in host1 host2 host3 ; do # create devices from the LVs kpartx -av /dev/mapper/vg_guests-$host--disk* # Activate the VGs for the host for vg in $(vgs --noheadings | grep $host | awk '{print $1}' ) ; do echo Activating $vg vgchange -ay $vg done # check the file systems for p in $(/dev/mapper/vg_$host* | grep -v swap); do e2fsck -p $p done # Deactivate the VGs for vg in $(vgs --noheadings | grep $host | awk '{print $1}' ) ; do echo De-activating $vg vgchange -an $vg done # Remove the devices kpartx -dv /dev/mapper/vg_guests-$host--disk0 done |