Rename Linux Volume Groups and Logical Volumes
If you are decided to rename your Linux LVM Volume Groups or Logical Volumes then here is how:
Rename a volume group:
# vgrename /dev/vg_old /dev/vgnewname
Rename a logical volume:
# lvrename /dev/vg_name/lv_old /dev/vg_name/lv_newname
Make sure to modify the respective entries in fstab as well:
# vi /etc/fstab
/dev/mapper/vg_old-lv_old /var ext4 defaults 1 1
to
/dev/mapper/vgnewname-lv_newname /var ext4 defaults 1 1
And if you are renaming your root partition VG or LV, then grub menu file also needs to be modified in order for server to find your vmlinuz kernel image under root directory during boot process:
# vi /boot/grub/menu.lst
Rename a volume group:
# vgrename /dev/vg_old /dev/vgnewname
Rename a logical volume:
# lvrename /dev/vg_name/lv_old /dev/vg_name/lv_newname
Make sure to modify the respective entries in fstab as well:
# vi /etc/fstab
/dev/mapper/vg_old-lv_old /var ext4 defaults 1 1
to
/dev/mapper/vgnewname-lv_newname /var ext4 defaults 1 1
And if you are renaming your root partition VG or LV, then grub menu file also needs to be modified in order for server to find your vmlinuz kernel image under root directory during boot process:
# vi /boot/grub/menu.lst
kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_old-lv_root rd_NO_LUKS rd_LVM_LV=vg_old/lv_root LANG=en_US.UTF-8 rd_LVM_LV=vg_old/lv_swap
to
kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vgnewname-lv_root rd_NO_LUKS rd_LVM_LV=vg_old/lv_root LANG=en_US.UTF-8 rd_LVM_LV=vgnewname/lv_swap
Note: If you forgot to modify these 2 mentioned files menu.list and fstab like me for the first time, you probably receive following kernel panic after reboot your system:
Kernel panic - not syncing: Attempted to kill init!
Pid: 1, comm: init tainted 2.6.32-431.el6.x86_64
Call Trace
After amended those files, you should be able to get rid of that kernel panic error and your system will be booted with new VG or LV names mounted.
Thanks!
ReplyDeleteI changed the VG without restarting the system. After a year i did not know the reason for the kernel panic.