- ORAganism
- How to rename volume group
- How to rename Logical Volume and Volume Group in Linux
- Rename a Logical Volume
- Rename Volume Group
- HowTo Change The LVM Volume Group Name That Includes The Root Partition
- Contents
- Overview
- State Before The LVM Volume Group Name Change
- Steps To Change The LVM Volume Group Name
- Step 1: Change Volume Group Name
- Step 2: Update The File System Configuration File: «/etc/fstab»
- Step 3: Update The Grub2 Configuration File: «/boot/grub2/grub.cfg»
- Step 4: Rebuild The Kernel initramfs File
- Step 5: Reboot The System
- State After The LVM Volume Group Name Change
- Linux – LVM – Volume Group Operations
ORAganism
I’m not sure exactly when this change happened, but in Oracle [Enterprise] Linux 5 days a default installation would result in the root file system being created as a LVM logical volume (LV) named LogVol00 in a volume group (VG) named VolGroup00. I must confess that I wasn’t paying too much attention to LV and VG default names in the days I was playing with OL5 a lot, but that’s partly because there was nothing to drag my attention to them.
Along comes Oracle Linux 6 and off I go creating VMs, cloning them and then really not liking the fact that the default VG created during the installation, and holding the LV for the root file system, is named vg_ where is the hostname of the original VM I installed. If I clone a VM the next thing I do is change the hostname, which means that I’m left with an inconsistent and somewhat confusing VG name. I think I screwed up one VM before realising that it wasn’t just simply a case of renaming the VG and updating /etc/fstab. I asked a friend who does much more Linux admin how to achieve what I wanted and didn’t take it any further when he said words to the effect of, “Yeah, it’s more complicated than that.”
Update [5th August 2014]
It turns out that renaming the volume group that hold the logical volume the root file system is on is not as complex as I had previously thought. Comments from Brian suggest that there is no need to recreate the initramfs and that it can be done without booting into rescue mode. I’ve just tested Brian suggestions and he’s right. It is as simple as:
- Rename Volume Group
- Update /etc/fstab
- Update /boot/grub/grub.conf
- Reboot
Brian – Thanks a lot for your comments and pointing out unnecessary steps.
This update makes the rest of the post mostly useless, but I’ll leave it all there for context.
End of update [5th August 2014]
Fairly recently I walked into the same situation again, only this time I decided that I wasn’t going to take “more complicated” for an answer :-). I searched, found a few articles that seemed to have logic in their approach and figured I had nothing to lose. I also thought there were some redundant steps in the posts I was following, hence feeling it’s worth blogging my slimmed down approach.
Well, that’s enough preamble. Here’s the details:
1) Boot Into Rescue Mode
For me booting from CD/iso was the easiest way to get into “rescue mode”. To do this select “Rescue installed system” when the welcome screen is presented during the boot process. You will then be prompted with:
Choose a Language – You know better than I what’s the best choice for you. Select it and then OK.
Keyboard Type – Again, pick what you think best matches your keyboard. Then select OK.
Rescue Method – Select “Local CD/DVD”, then OK.
Setup Networking – Select “No”
Rescue – Select “Continue”
Rescue (message about your system being mounted under /mnt/sysimage and use of chroot) – OK.
Rescue (another message about having mounted your system under /mnt/sysimage) – OK.
First Aid Kit quickstart menu – Select “shell Start shell”, then OK.
The above will get you to a prompt so you can actually do what you came here for!
2) Rename Volume Group
The LVM commands you issue are the same as usual, only they need to be prefixed with lvm. I suggest listing the VGs to be sure the state of the system is as you expect, and using more is a good idea as you don’t have a scrollbar, i.e.:
Once you’re happy, rename the VG as below:
You should get a success message after this command.
3) Update All References
Change the root directory to that of your installed system using chroot:
The following files need to be modified to replace references to the old VG name with the new VG name:
There will be multiple references per line in grub.conf, so a bit of “global replace” is in order.
4) Create New Ramdisk Image
Run the following command to make a new initial ramdisk image
Note that the force option is only required because there is already an existing image with the same name. You could use a different name if you want, but you’d need to add an appropriate entry to the grub.conf to reflect this.
If the above command completes without error messages and you didn’t make any errors in the editing of the files earlier then you should be all set… Only one way to find out!
5) Reboot Machine
Exit out of the chroot environment (type “exit”).
Exit out of the shell to return to the “First Aid Kit quickstart menu” (type “exit”).
First Aid Kit quickstart menu – Select “reboot Reboot”, then OK.
At the welcome screen select “Boot from local drive”.
If all goes well then remember to remove the CD/iso from your [virtual] CD drive.
References
The 2 articles that helped me with this are the following, so thanks to the authors:
Update [27th January 2014]
I have just noticed that the default volume group name when installing Oracle Linux 6.5 has changed from “vg_ ” to “VolGroup”.
Источник
How to rename volume group
Published: November 25, 2016 | Modified: June 24, 2020
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).
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.
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
Источник
How to rename Logical Volume and Volume Group in Linux
Rename a Logical Volume
NOTE: To rename a Logical Volume you will have to unmount your partition.
Syntax
# lvrename Volu_Group_Name Old_log_vol_name new_log_vol_name
# lvrename VolGroup work office
Renamed “work” to “office” in volume group “VolGroup”
So now our Logical Volume is renamed.
In case your logical volume was mounted, you will have to remount to make the changes affect.
[root@test2
]# mount /dev/VolGroup/ office /work/
Verify the changes
[root@test2
]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-root 11G 3.3G 7.0G 33% /
tmpfs 495M 72K 495M 1% /dev/shm
/dev/sda1 194M 30M 155M 16% /boot
/dev/mapper/VolGroup-office 1008M 34M 924M 4% /work
Rename Volume Group
# vgdisplay
— Volume group —
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 14.80 GiB
PE Size 4.00 MiB
Total PE 3789
Alloc PE / Size 3295 / 12.87 GiB
Free PE / Size 494 / 1.93 GiB
VG UUID iebYT7-Bukv-7FdP-AEMJ-noFk-INmV-7wX2PI
Syntax
# vgrename old_vol_group_name new_vol_group_name
# vgrename VolGroup NewGroup
Volume group “VolGroup” successfully renamed to “NewGroup”
Verify the changes
[root@test2
]# vgdisplay
— Volume group —
VG Name NewGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 14.80 GiB
PE Size 4.00 MiB
Total PE 3789
Alloc PE / Size 3295 / 12.87 GiB
Free PE / Size 494 / 1.93 GiB
VG UUID iebYT7-Bukv-7FdP-AEMJ-noFk-INmV-7wX2PI
So everything worked as expected. Please let me know your success and failures.
Источник
HowTo Change The LVM Volume Group Name That Includes The Root Partition
Contents
Overview
This page describes the steps needed to change an LVM (Logical Volume Manager) Volume Group name which includes the the Root partition («/«). The problem is that the Root partition LVM Device Mapper is referenced in different configuration files and embedded in the Kernel initramfs.
We will demonstrate the LVM Volume Group name change from «nst_localhost» to «nst20«.
State Before The LVM Volume Group Name Change
The Fedora System Storage Manager utility: ssm is used to display the current storage layout on the example system.
Steps To Change The LVM Volume Group Name
Step 1: Change Volume Group Name
The vgrename utility will be used to change LVM Volume Name from «nst_localhost» to «nst20«:
Step 2: Update The File System Configuration File: «/etc/fstab»
Use an editor (e.g., vi) to change the LVM Volume Group Device Mapper name in the file system configuration file: «/etc/fstab» to the new «nst20» name for the «root» and «swap» Logical Volumes.
Step 3: Update The Grub2 Configuration File: «/boot/grub2/grub.cfg»
Use an editor (e.g., vi) to change the LVM Volume Group Device Mapper name in the file system configuration file: «/boot/grub2/grub.cfg» to the new «nst20» name for the «root» and «swap» Logical Volumes for all relevant entries.
Before (Note: Only one Grub2 menu entry is shown for example purposes. All relevant entries need to be changed.):
Step 4: Rebuild The Kernel initramfs File
The Kernel initramfs image needs to be rebuild to reflect the LVM Volume Group name change. The mkinitrd will be used to accomplish this task which uses the «dracut» tool.
Example for Kernel: 3.12.5-302.fc20.x86_64
Step 5: Reboot The System
After all the above changes have been made, use the systemctl utility to reboot your system:
State After The LVM Volume Group Name Change
The Fedora System Storage Manager utility: ssm is used to display the storage layout on the example system after changing the LVM Volume Group Name and a system reboot has occurred.
Источник
Linux – LVM – Volume Group Operations
How to create new volume group ?
1.List the physical disks which were brought under logical volume manager control using pvcreate command .
3.Verify the new volume group.
4.For detailed volume group information,use below mentioned command.
2.List the available volume group.
3.Rename the volume group using “vgrename” command.
4.Check the volume status .You can see still volume is available for operation.
5.But the volume is still reflecting the old device.This can be removed after remounting the volume.This can be down when you have down time for the server.Please don;t forget to update “fstab” according to the new volume group name.
How to Extend the volume group ?
Volume group can be extend on the fly by adding new disks or LUNS to the existing volume group.
1.List the volume group .
3.Let me choose “sde” to extend volume group “uavg”.
From the above output ,you can see volume group “uavg” has been extended successfully.
4.Check the “pvs” command output. /dev/sde will show as part of “uavg” now.
How to scan a disks for LVM ?
You need to scan a LVM disks whenever there is a hardware changes on your server.Hardware changes may be a newly added or removed disks which will be hotplug disks or new disks added to SAN systems.
How to decrease the volume group size ? or How to remove disks from LVM ?
Disks can be removed from volume group if its not used for any volumes.
1.First find out the disks which we are planning to remove it from volume group is not used for any volumes using below mentioned commands.
From the above commands output,we can see disk “sde” is not used for any volumes (lvs command output) in volume group “uavg” .
2.Check the disk details. From this details you can confirm ,PE (i.e physical extends) are not used in VG. (Total PE=127 & Free PE=127).
3.List the volume group details before removing the physical volume.
4.Now we are ready to remove the “/dev/sde” from volume group “uavg”.
From the above outputs ,you can see #PV reduced to “1” and volume group size also reduced.
How to activate and Deactivate the volume group ?
By default volume group will be in active mode. But some circumstances,you need to put the volume group in disabled mode or inactive mode thus unknown to Linux kernel. Here we will see how to activate and deactivate the volume group.
1.List the volume groups.
2.Deactive the volume group “uavg”
you can not deactivate VG if any opened volumes from that volumegroup. You have to unmount all the volumes from the volume group before deactivating it .You will get below error if any volumes in opened state .
3.Check the volume status.It will be in “Not Available” status.
4.You can activate the volume group use same command with different options.
5.Mount the volume .We are back to normal operation.
How to backup & restore the LVM volumegroup metadata ?
Automatically Metadata backups and archives are created whenever you create new volume group Linux system.By default backup stored in /etc/lvm/backup and archives are stored in /etc/lvm/archive .We can also manually backup the lvm configuration using “vgcfgbackup” command.
1.Run “vgcfgbackup” command to take new configuration backup for volume group “uavg”.
2.You can find the new configuration file under the below mentioned location.
3.To restore the volume group meta data,you below command.
How to export/Move the volume group to other Linux node ?
Complete LVM volume group can be moved from one system to another system using vg commands.Here we will see step by step guide for this migration.
1.Unmount all the volumes from volume group which needs to be migrated.
2.Make the volume group inactive using “vgchange” command to ensure there will no I/O to the VG.
3.Export the volumegroup .
4.You can verify the exported status using “pvscan” command.
5.Now assign the disks from SAN level to the system where you want to import the volume group.
6.Scan the disks and make the disks available for VG import.
Check out the Disks or LUN scanning procedure in Redhat Linux.
7.Import the volume group.
8.Activate the volume group for normal operation.
How to recreate the device files for LVM volumes ?
Due to server crash or other reason, we may loose the LVM device files and volume group directory . In those situation ,you need to recreate what you have lost. LVM provides command called “vgmknodes” which will help you to recreate those missing files.Here is a small experiment.
3.Let me run “vgmknodes” and see whether this command is able to recreate the removed device file and lvm directory .
4.Check whether devices files are created or not.
wow…its recreated.
5.Let me check /etc/lvm directory is created or not .
Awesome…Its recreated.
How to remove the volume group ?
You can remove the volume group using vgremove command.
If any volumes from the volume group in mounted status ,you will get below error .
Un-mount the volume and remove the volume group.
Hope this article shared enough information about LVM2 volume group administration.
You can also split and combine volume groups in LVM2 like veritas volume manager.
Please leave a comment if you have any doubt on this . Share it in social networks to reach all the Linux administrators and beginners.
Thank you for visiting UnixArena.
Источник