[CentOS] vgrename, lvrename

Mon Sep 13 11:47:29 UTC 2010
Robert Heller <heller at deepsoft.com>

At Sun, 12 Sep 2010 22:40:52 -0600 CentOS mailing list <centos at centos.org> wrote:

> 
> 
> 
> On Sat, Sep 11, 2010 at 2:55 PM, Robert Heller <heller at deepsoft.com> wrote:
> 
> > At Sat, 11 Sep 2010 13:45:55 -0600 CentOS mailing list <centos at centos.org>
> > wrote:
> > Note: in the case of mkinitrd, you will need to rebuild your initrd if
> >  you expect to actually boot the machine after renaming the volume group
> > and logical volumes. You'll need to *manually* mount the root and /boot
> > (at least) someplace (eg under /sysroot), then chroot there. Don't
> > forget to fix /etc/fstab and /boot/grub/grub.conf (root=...).
> 
> 
> Googling got me the command:
>    /sbin/mkinitrd -f /boot/initrd-$(uname -r).img $(uname -r)
> 
> Unfortunately this resulted in:
> 
>    error opening /sys/block: No such file or directory
>    error opening /sys/block: No such file or directory
> 
> The renamed root lvm filesystem is mounted on /mnt/root
> the /boot is in /dev/sda1 and mounted on /mnt/root/boot
> 
> before doing the chroot, I tried
> 
>    sudo cp -a /sys/block /mnt/root/sys

Wrong!

Do this:
     mount --bind /sys /mnt/root/sys
     mount --bind /dev /mnt/root/dev
     mount --bind /proc /mnt/root/proc
     chroot /mnt/root
     /sbin/mkinitrd -f /boot/initrd-<actual KV>.img <actual KV>
     exit
     umount /mnt/root/sys
     umount /mnt/root/dev
     umount /mnt/root/proc

Note: you don't want to use 'uname -r' while running the LiveCD, since
the it might not be the kernel your system wants to boot (in fact it
wasn't as you discovered).  Look in /boot/grub/grub.conf and see
*exactly* which kernel your system is booting. Replace <actual KV> with
whatever you find in /boot/grub/grub.conf -- this will rebuild the
*correct* initrd. Yes, more *careful* typing, but that is what you need
to do.

> 
> Even though it was done with root privilege I got a lot of read permission
> errors,
> but a lot stuff did copy, maybe I got what I need.
> did the mkinitrd, no errors
> 
> Lets try booting from the hard drive.
> 
> Hmm there's a splash screen, that's a good sign.
> 
> No Joy. It's not booting and complaining about not finding stuff with the
> old names.
> 
> Did I screw up the grub.conf edits.  Just checked they are ok.
> 
> It finds the volume groups with the new names
> then complains about the old names:
> 
>    Volume group "VolGroup00" not found
> Unable to access resume device (/dev/VolGroup00/LogVol01)
> 
> Hmm. That's the old name of the swap device.
> 
> There's at least one more piece of the puzzle that's missing.
> 
> Lets boot up the Live CD again.  And take a closer look at fstab.  Looks
> good to me.
> 

-- 
Robert Heller             -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software        -- Linux Installation and Administration
http://www.deepsoft.com/  -- Web Hosting, with CGI and Database
heller at deepsoft.com       -- Contract Programming: C/C++, Tcl/Tk