Learn how to rename volume group in Linux or Unix. Understand what happens in background when you change volume group name of existing VG.
Volume group can be renamed with easy vgrename command Linux. But first we will see how it can be done without vgrename command so that step by step you will understand what actually happens in background while VG name changes.
- Stop all user/app access to all mount points within VG using fuser
- Un-mount all LV using umount
- De activate VG using vgchange
- Export VG using vgexport
- Create new name folder and group file using mknod
- Import VG with new name in command options using vgimport
- Activate VG using vgchange
- Mount all LV using mount
- Edit related entries in /etc/fstab with new name
See below output for above mentioned steps (HPUX console).
# fuser -cku /data
# umount /data
# lvremove /dev/vg01/lvol1
The logical volume "/dev/vg01/lvol1" is not empty;
do you really want to delete the logical volume (y/n) : y
Logical volume "/dev/vg01/lvol1" has been successfully removed.
Volume Group configuration for /dev/vg03 has been saved in /etc/lvmconf/vg01.conf
# vgchange -a n /dev/vg01
Volume group "/dev/vg01" has been successfully changed.
# vgexport -v -m /tmp/vg01.map vg01
Beginning the export process on Volume Group "/dev/vg01".
/dev/dsk/c0t1d0 vgexport:Volume Group “/dev/vg01” has been successfully removed.
# mkdir /dev/testvg
# mknod /dev/testvg/group c major 0xminor
# vgimport -v -m /tmp/vg01.map /dev/testvg list_of_disk
vgimport: Volume group “/dev/testvg” has been successfully created.
Warning: A backup of this volume group may not exist on this machine.
Please remember to take a backup using the vgcfgbackup command after activating the volume group
# vgchange -a y testvg
Volume group “/dev/testvg” has been successfully changed.
# mount /dev/testvg/lvol1 /data
In above step by step process you can see how VG changes its name. We are changing its VG related file and directory and then we import it using old configuration but new name.
In Linux we have one command which does all this stuff in background for you. vgrename is command which used to rename VG in Linux. You have to supply old VG name and required new name.
# vgrename /dev/vg01 /dev/testvg
Volume group "/dev/vg01" successfully renamed to "/dev/testvg"
# vgrename vg01 testvg
Volume group "vg01" successfully renamed to "testvg"
Keep in mind, this command also requires de-activated VG to work. So this is not online process. It supports below options :
- -f : Forcefully rename
- -v : Verbose mode