Bug 640961 - Document that grub-install might be needed for old Linux guests after virt-resize
Summary: Document that grub-install might be needed for old Linux guests after virt-re...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-10-07 11:28 UTC by Richard W.M. Jones
Modified: 2011-07-14 19:18 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-14 19:18:20 UTC
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2010-10-07 11:28:03 UTC
Description of problem:

I tried to use virt-resize to expand a RHEL 5 guest:

# lvrename /dev/vg_pin/RHEL5Xenbrewx64 /dev/vg_pin/RHEL5Xenbrewx64preresize
  Renamed "RHEL5Xenbrewx64" to "RHEL5Xenbrewx64preresize" in volume group "vg_pin"
# lvcreate -n RHEL5Xenbrewx64 -L 16G /dev/vg_pin  Logical volume "RHEL5Xenbrewx64" created
# virt-list-filesystems /dev/vg_pin/RHEL5Xenbrewx64preresize 
/dev/VolGroup00/LogVol00
/dev/sda1
# virt-list-partitions /dev/vg_pin/RHEL5Xenbrewx64preresize 
/dev/sda1
/dev/sda2
# virt-resize /dev/vg_pin/RHEL5Xenbrewx64preresize /dev/vg_pin/RHEL5Xenbrewx64 --expand=/dev/sda2 --lv-expand=/dev/VolGroup00/LogVol00
Summary of changes:
/dev/sda1: partition will be left alone
/dev/sda2: partition will be resized from 9.9G to 15.9G
/dev/sda2: content will be expanded using the 'pvresize' method
/dev/VolGroup00/LogVol00: LV will be expanded to maximum size
/dev/VolGroup00/LogVol00: content will be expanded using the 'resize2fs' method
Copying /dev/sda1 ...
[############################################################################]
Copying /dev/sda2 ...
[############################################################################]
Expanding /dev/sda2 using the 'pvresize' method
Expanding /dev/VolGroup00/LogVol00 using the 'resize2fs' method
# virsh start RHEL5Xenbrewx64Domain RHEL5Xenbrewx64 started

At this point the guest was stuck at:

  Booting from Hard Disk...
  GRUB 

(with a space after GRUB).

Version-Release number of selected component (if applicable):

libguestfs 1.5.21.

Comment 1 Richard W.M. Jones 2010-10-07 11:31:28 UTC
Disk dumps show that the bootloader has been copied over fine.

The first partition starts at sector 64 on the resized disk,
was sector 63 on the original disk.  This is expected, but
could this be the cause of the failure?  Maybe the old version
of grub can't boot from the aligned sector?

Comment 2 Richard W.M. Jones 2010-10-07 11:35:09 UTC
Interesting -- I was able to recover the new system
by rerunning grub-install from guestfish.  I didn't
expect that this would work, but it did.

This suggests that we could add a --grub-install option
to virt-resize.  It would need to mount up / and /boot
and run the $g->grub_install ("/", "/dev/sda") command.

-----
# guestfish -i -a /dev/vg_pin/RHEL5Xenbrewx64

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for a list of commands
      'man' to read the manual
      'quit' to quit the shell

Operating system: Red Hat Enterprise Linux Server release 5.5 (Tikanga)
/dev/VolGroup00/LogVol00 mounted on /
/dev/vda1 mounted on /boot

><fs> help grub-install 
NAME
    grub-install - install GRUB

SYNOPSIS
     grub-install root device

DESCRIPTION
    This command installs GRUB (the Grand Unified Bootloader) on "device",
    with the root directory being "root".

    Note: If grub-install reports the error "No suitable drive was found in
    the generated device map." it may be that you need to create a
    "/boot/grub/device.map" file first that contains the mapping between
    grub device names and Linux device names. It is usually sufficient to
    create a file containing:

     (hd0) /dev/vda

    replacing "/dev/vda" with the name of the installation device.

><fs> cat /boot/grub/device.map 
# this device map was generated by anaconda
(hd0)     /dev/vda

><fs> grub-install / /dev/vda

Comment 3 Richard W.M. Jones 2010-10-16 13:39:53 UTC
Simple change to virt-resize, targeting this
at libguestfs 1.6.

Comment 4 Richard W.M. Jones 2010-10-18 13:36:24 UTC
I decided to just document this:

https://www.redhat.com/archives/libguestfs/2010-October/msg00033.html


Note You need to log in before you can comment on or make changes to this bug.