virt-rescue is a useful “rescue tool” (like a rescue CD) for virtual machines.
New in libguestfs ≥ 1.17.36 is the
virt-rescue --scratch[=N] option which lets you create scratch disks to play with.
Firstly it’s useful for playing around with Linux utilities that you might not normally get to use, such as mdadm and btrfs. For example, suppose you want to try spanning a btrfs filesystem over 4 devices. This is now simple and you don’t even need root:
$ virt-rescue --scratch=4 ><rescue> mkfs.btrfs /dev/vda /dev/vdb /dev/vdc /dev/vdd ><rescue> mount /dev/vda /sysroot ><rescue> btrfs filesystem show Label: none uuid: da1693d6-a89f-4cb6-8405-d277869e289b Total devices 4 FS bytes used 28.00KB devid 1 size 10.00GB used 2.02GB path /dev/vda devid 2 size 10.00GB used 2.00GB path /dev/vdb devid 3 size 10.00GB used 1.01GB path /dev/vdc devid 4 size 10.00GB used 1.01GB path /dev/vdd
Secondly it’s a way to get a second temporary disk attached to an ordinary guest while you’re rescuing it, for example if you need to temporary copy some data off the guest while you’re fixing it.
# virt-rescue -d Fedora16 --scratch ><rescue> fdisk /dev/vdb (use fdisk and mkfs to partition the scratch disk and then use it for temporary data)