Learn how to rename the volume group in Linux or Unix. Understand what happens in the background when you change the volume group name of existing VG.
A 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 the background while VG name changes.
- Stop all user/app access to all mount points within VG using
- Un-mount all LV using
- Deactivate VG using
- Export VG using
- Create a new name folder and group file using
- Import VG with a new name in command options using
- Activate VG using
- Mount all LV using
- Edit related entries in /etc/fstab with a new name
See below output for the above-mentioned steps (HPUX console).
# fuser -cku /data
# umount /data
# 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 the 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 the new name.
In Linux, we have one command which does all this stuff in the background for you.
vgrename is a command which used to rename VG in Linux. You have to supply the old VG name and required a 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 an online process. It supports the below options :