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.
We have seen how to create VG in the past and how to export/import VG. We are going to use these commands to rename VG. Below steps needs to be followed –
- Stop all user/app access to all mount points within VG using
fuser
- Un-mount all LV using
umount
- Deactivate VG using
vgchange
- Export VG using
vgexport
- Create a new name folder and group file using
mknod
- Import VG with a new name in command options using
vgimport
- Activate VG using
vgchange
- Mount all LV using
mount
- Edit related entries in /etc/fstab with a new name
See below output for the above-mentioned steps (HPUX console).
# fuser -cku /data
/data: 223412c(user1)
# 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"
OR
# 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 :
-f
Forcefully rename-v
Verbose mode
A User from Japan says
Hey, Shrikant, thanks for the tutorial!
One quick note about volume group renaming on an active LVM—is it for sure not possible?
I mean, I’m running my OS in an LVM, so it’s active for sure, but I was able to rename the VGs and LVs containing it without a problem…
Additionally, the changes showed up in my disk manager and partition editor immediately! How convenient.
Thanks!