Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've found a few tutorials to reset the password on a xen guest using image files, such as this one: http://www.howtoforge.com/forums/showthread.php?t=28779

However I haven't had any luck with examples of modifying this to work with physical disks.

This guest is currently running. I'd appreciate it if you could start from listing the command to shutdown the guest from the host, all the way through to restarting the xen guest after it's root password has been changed.

also, not sure what this means, but on my local machine "xm" is the command used to interact with xen, not xe like I've seen in most tutorials.

Here is the disk line of the xen config file:

disk = [ "phy:/dev/sdb1,xvda,w" ]

Thanks,

-Eric

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Shutdown the guest using something like

xm shutdown <guest>

Check so it is shutdown

xm top

That path hints that it's not an LVM, but a physical disk. This is a job for libguestfs. Make sure you have it installed. First you check what filesystems you have in that block device:

virt-filesystems -a /dev/sdb1

Then you mount the root filesystem:

guestmount -a /dev/sdb1 -m /dev/<whateverhappenstoberoot> --rw /mnt

Change root directory:

chroot /mnt/

Update your passwords

passwd root

And then you restore everything

logout
unmount /mnt/
xm create /etc/xen/vm/<guest>
share|improve this answer
    
Thanks so much! I tried running "yum install 'guestf'" but got back: "No package guestf available." This is on CentOS Any ideas? –  Eric Dec 17 '10 at 10:21
    
CentOS Version is 5.5 –  Eric Dec 17 '10 at 10:33

You can actually get by without installing guestfs tools by doing some manual work instead.

Follow pehrs's advice up to the virt-filesystems command (without including it), then run this:

parted -s /dev/sdb1 unit B print

This should give you a table listing offsets, like this:

Number  Start        End          Size         Type     File system  Flags
 1      32256B       2467583999B  2467551744B  primary  ext2
 2      2467584000B  3981035519B  1513451520B  primary  ext3
 3      3981035520B  3989260799B  8225280B     primary               lba
 4      3989260800B  3997486079B  8225280B     primary

The one you need to mount would probably have an ext3 filesystem on it. You can also check for the right number by running mount in the guest and looking for the device for the / partition.

Take the number from the 'Start' column minus the B and try this:

mkdir /mnt/test
mount -o loop,rw,offset=NUMBER_GOES_HERE /dev/sdb1 /mnt/test

Then proceed with chroot /mnt/test. All the rest stays the same apart from this change from using /mnt to using /mnt/test - I don't like mounting anything directly on top of /mnt.

Reference: http://www.andremiller.net/content/mounting-hard-disk-image-including-partitions-using-linux

share|improve this answer

@Eric The default CentOS repos don't contain the libguestfs tools -- however the epel repository does. In this case, what I'd usually do is set up the epel repository, but then disable it, and only enable it to install specific packages packages.. Like so:

  1. rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  2. disable the repository by setting "enabled=0" in each section of /etc/yum.repos.d/epel.repo
  3. yum –enablerepo=epel install

That said, I'm not sure exactly which of the packages you will need. http://libguestfs.org/ seems to suggest installing "*guestf*", but that will more than likely install much more than you really need.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.