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
- Un-mount all LV using
- De activate VG using
- Export VG using
- Create new name folder and group file using
- Import VG with new name in command options using
- Activate VG using
- Mount all LV using
- Edit related entries in /etc/fstab with new name
See below output for 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 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