Wednesday, May 11, 2011

More Fun With Xen

My colleague presented me with a poser: Lost password on Xen guest - What do you do?  What I normally do is, of course, mount the file system, edit the /etc/passwd (shadow file) and restart without a root password - quickly resetting it once back in.  Of course, with all the virtualization - what do you do?  I tried just mounting the /var/lib/xen/vutil.img file - no luck.  Then someone said try 

# losetup -f /var/lib/xen/images/vutil.img

I did but still couldn't get /dev/loop0 to mount.  So I tried another tip - this got me closer:

# kpartx -av /dev/loop0

This created /dev/mapper/loop0p1 and /dev/mapper/loop0p2. I really wanted to immediately mount the root partition so I tried the loop0p2 which was obviously larger.  p1 was probably /boot, I thought - it was.  Eventually, I realized p1 would be useful after all.  Since I couldn't get p2 to mount, I mounted p1, edited the grub.conf to include a single user mode boot option and then ran:

# xm create -c vutil

The -c makes it go directly to the console where the grub menu was displayed.  I picked my new single user mode boot option and "Ta-Dah!"  Whew!  

Thanks a bunch to the Xen Users mailing list.  They gave me a lot of great info (especially that last one).  I'm still not sure why I couldn't mount the file. It may be because I did not create a separate LVM filesystem for my guest.  I'm new to Xen - still have a lot of experimenting to do.

No comments: