[Libguestfs] libguestfs and md devices

Richard W.M. Jones rjones at redhat.com
Mon Oct 31 17:10:35 UTC 2011


Here's a way to do some tests (assuming libguestfs from git which has
the mdadm package):

  $ rm /tmp/test1.img /tmp/test2.img
  $ truncate -s 1G /tmp/test1.img /tmp/test2.img
  $ ./run ./rescue/virt-rescue -a /tmp/test1.img -a /tmp/test2.img

[At this point you have to switch to another terminal and kill the
rogue 'sed' and/or 'grep' processes launched by libtool --
https://bugzilla.redhat.com/show_bug.cgi?id=729052]

  ><rescue> mdadm --create /dev/md0 -l1 -n2 /dev/vda /dev/vdb 
  ><rescue> blockdev --getsize64 /dev/md0 
  1073729536
  ><rescue> cat /proc/mdstat 
  Personalities : [raid1] 
  md0 : active raid1 vdb[1] vda[0]
        1048564 blocks super 1.2 [2/2] [UU]
        
  unused devices: <none>
  
  ><rescue> mkfs -t ext3 /dev/md0 
  ><rescue> mount /dev/md0 /sysroot
  ><rescue> touch /sysroot/hello-world
  ><rescue> exit

Oddly this allocates all the space on the second disk, but not the
first:

  $ du -sh /tmp/test1.img /tmp/test2.img 
  33M  /tmp/test1.img
  1.0G /tmp/test2.img

Then try it in guestfish (add the -v option for more detail):

  $ ./run ./fish/guestfish -a /tmp/test1.img -a /tmp/test2.img
  ><fs> run
  ><fs> vfs-type /dev/vda
  linux_raid_member

Like you, I don't see any /dev/md0 device (but also I don't see any
weird names either).  Does md need a daemon of some sort?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list