This week's self inflicted issue was renaming a volume group which had the root partition running on it. My system is running RHEL 5.5. A few twists and turns were made. I would imagine that the lvrename steps could occur after the vgrename. But, I decided to document what worked for me and here it is:
Rename Logical Volumes and Volume Groups
current swap situation:
# swapon -s
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 14319608 0 -2
turn off swap
# swapoff -a
# swapon -s
nothing
Rename the logical volumes:
# lvrename VolGroup00 LogVol00 root
# lvrename VolGroup00 LogVol01 swap1
# lvrename VolGroup00 LogVol02 tmp
Turn swap back on:
# swapon -a
# lvscan
ACTIVE '/dev/VolGroup00/root' [119.25 GB] inherit
ACTIVE '/dev/VolGroup00/tmp' [2.94 GB] inherit
ACTIVE '/dev/VolGroup00/swap1' [13.66 GB] inherit
Shutdown the server:
Boot server into a linux rescue shell using the RHEL 5.5. installation DVD (or an iso on a usb key). At the Red Hat splash screen and "boot:" prompt enter
Answer a number of questions
- Language: English [ OK ]
- Keyboard: us [ OK ]
- What type of Media contains the rescue media?: Local CDROM [ OK ]
- Do you want to start the Network Interfaces on this system? [ NO ]
- "Rescue" window. Offers to mount linux installation in rw, read only or not at all. Either way, we will be provided with a shell. As this system's root partition is on a logical volume in the volume group we wish to rename, we must not mount the system. [ SKIP ]
A shell appears. Scan for logical volumes. What you need to see is that the scan found the voloume group you wish to rename e.g.
# lvm vgscan
Found VolGroup00
Make sure logical volumes are inactive:
# lvm lvscan
inactive '/dev/VolGroup00/root' [119.25 GB] inherit
inactive '/dev/VolGroup00/tmp' [2.94 GB] inherit
inactive '/dev/VolGroup00/swap1' [13.66 GB] inherit
Rename the volume group:
# lvm vgrename VolGroup00 vg00
Volume group "VolGroup00" successfully renamed to "vg00"
Exit the shell and reboot the server. Leave the RHEL Installation DVD in.
# exit
Go back into linux rescue mode
Answer questions 1 to 4 as above. In step 5 choose to mount system in read write mode.
5. "Rescue" window, choose [ CONTINUE ]
Eventually, a shell will appear. The system files are in /mnt/sysimage. chroot into the system:
Label logical volumes:
# e2label /dev/vg00/root /
# e2label /dev/vg00/tmp TMP
# mkswap -L SWAP1 /dev/mapper/vg00-swap1
Setting up swapspace version 1, size = 14663282 kB
LABEL=SWAP1, no uuid
Make a copy of /etc/fstab:
# cp -p /etc/fstab /etc/old/fstab.20100512
Update fstab with correct Labels:
# vim fstab
# diff -uw /etc/old/fstab.20100507 /etc/fstab
--- /etc/old/fstab.20100512 2010-04-13 03:45:12.000000000 -0400
+++ /etc/fstab 2010-05-12 14:45:13.000000000 -0400
@@ -1,8 +1,8 @@
-/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
-/dev/VolGroup00/LogVol02 /tmp ext3 defaults 1 2
+LABEL=/ / ext3 defaults 1 1
+LABEL=TMP /tmp ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
-/dev/VolGroup00/LogVol01 swap swap defaults 0 0
+LABEL=SWAP1 swap swap defaults 0 0
Make a copy of grub.conf
# cp -p /boot/grub/grub.conf /boot/grub/old/grub.conf.20100512
Update grub.conf with updated path to root partition and yet to be made
initrd file -> initrd-2.6.18-194.el5.vgrepair.img
# vim /boot/grub/grub.conf
# diff -uw /boot/grub/old/grub.conf.20100512 /boot/grub/grub.conf
--- old/grub.conf.20100512 2010-05-03 11:39:36.000000000 -0400
+++ grub.conf 2010-05-12 15:17:41.000000000 -0400
@@ -4,7 +4,7 @@
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
-# kernel /vmlinuz-version ro
root=/dev/VolGroup00/LogVol00
+# kernel /vmlinuz-version ro root=/dev/vg00/root
# initrd /initrd-version.img
#boot=/dev/sda
default=0
@@ -13,5 +13,9 @@
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-194.el5)
root (hd0,0)
- kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/root # rhgb quiet crashkernel=128M@16M
+ kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/vg00/root rhgb # quiet crashkernel=128M@16M
+ initrd /initrd-2.6.18-194.el5.vgrepair.img
+title Red Hat Enterprise Linux Server (2.6.18-194.el5)
+ root (hd0,0)
+ kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/vg00/root rhgb # quiet crashkernel=128M@16M
initrd /initrd-2.6.18-194.el5.img
Make a new initrd image - to match entry in grub.conf:
# mkinitrd /boot/initrd-2.6.18-194.el5.vgrepair.img 2.6.18-194.el5
This takes some time and there is no output.
Exit from shell:
and from linux rescue
System begins to reboot. When it has finished shutting down services, but before it begins to start them, remove the dvd. At the menu choose the VG Repair kernel (or leave and let the system boot into the default)
Good luck,
TechnoPeasant
------------------
http://technoconfessions.blogspot.com/