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 edited the 'grub.conf' file of my linux system and changed the 'timeout' value in it and added some other line so as to solve the timeout issue of 'xm console guest' command. I was fool to assume that this 'timeout' parameter in grub.conf is actually related to 'xm console timeout and change it to very large value. So it led me to a big problem. Now when I rebooted my linux machine, it just hangs at boot screen even after manually selecting the Kernel to boot.

So basically I want to undo the changes I did in grub.conf file while booting or through grub. Or somehow force the system to boot once and undo the changes afterwards. I am not able to do it. One way to do it it to boot from the Linux CD in rescue mode and undo it, but I can not do it as it is a virtual machine on XEN and I can't find a way to boot it from external CD.

Is there any way to resolve the mess I created?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

You can mount the diskfile on the host using losetup

sudo losetup -o32256 /dev/loop0 /path/to/harddiskimage.xm
sudo mount /dev/loop0 /media/mydisk

The -o refers to the offset for the boot sector. This is normally 32256 but can change if, for example, you have multiple partitions on the guest.

To make sure what your offset is, you can do the following:

sudo losetup -d /dev/loop0
sudo losetup /dev/loop0 /path/to/harddiskimage.xm
sudo fdisk -ul /dev/loop0

It will show the number of Units and sector/track. Just multiply these two to get the offset.

Once you are done, editing the grub.conf in the mounted folder, you can unmount it:

sudo umount /dev/loop0
sudo losetup -d /dev/loop0
share|improve this answer
    
Or just use kpartxfor finding out those pesky partitions inside the disk file. :-) –  Janne Pikkarainen Oct 20 '11 at 8:08

You can edit the boot options right from the grub menu before selecting an option. I believe you press "e" to edit the entry. You can then change the options for that boot to something different.

Once you are booted into the system, you can edit your grub.conf file again.

share|improve this answer
    
Or this. Sometimes, I tend to miss the obvious... :-) –  Bart De Vos Oct 10 '11 at 14:54

I do not know the procedure mentioned by 'Bart De Vos' works or not as I have not tried it because I found a procedure which definately works. Approcah is similar of mounting the filesytem of guest and then editing it.

Please follow the below steps to mount the image file:

  1. First fire vgscan command on dom-0, it will give you logical volumes that are currently active on the dom-0. Now you can safely assume that this volume number shown by the command is of your dom-0 machine and not of any guest.

  2. Now execute kpartx -av /var/lib/xen/images/$machine_name.img This command will map loops for the image file of VM and activate the VolumeGroup of guest VM.

  3. Now again fire vgscan command, you will see one more VolGroup other than what you have seen in step 1. Now you can be sure that this is the volumegroup of your guest VM.

  4. Now you should know the logical volumes in a VolumeGroup to successfully mount it. For this fire the command vgchange -ay /VolGroup00(Newly created volumegroup in step 2)/

  5. Now execute command lvs, this will give you logical volumes in VolGroup.

  6. Now create a mount point and mount any Logical volume you want to mount as follows

    mount /dev/VolGroup00/LogVol00 $mount_path

  7. Now you can access any directory of Guest VM through this way and modify any configuration you want. Once you are done you can follow reverse procedure like

    a) Umount $mount_path

    b) vgchange -an VolGroup00

    c) kpartx -d /var/lib/xen/images/$machine_name.img

And you are done

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.