LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to rename a vol group? (http://www.linuxquestions.org/questions/linux-general-1/how-to-rename-a-vol-group-433993/)

binary_0011 04-11-2006 03:56 AM

How to rename a vol group?
 
[root@localhost dev]# vgrename stuff store
Volume group "stuff" still has active LVs

as you can see, the LVs are still active and I can't change the name.

How do I stop it so that I can change the name of the VG?

Thanks.

uselpa 04-11-2006 09:07 AM

IIRC I did `lvchange -an` the logical volumes first, then `vgrename`, then `lvchange -ay` again.

haertig 04-11-2006 09:37 AM

uselpa listed the correct procedure. You will probably need to unmount any mounted logical volumes before these commands will work however. I usually do this type of low level stuff from runlevel 1, so filesystem unmounting is easier (no pesky users or processes holding the filesystems open). Also, as opposed to running "lvchange -an" on each logical volume, you can do "vgchange -an" on the volume group and hit all the logical volumes at once. Then after you've renamed, run "vgchange -ay" to activate all the logical volumes with one command.

Don't forget to modify your /etc/fstab entries to reflect the new name of the volume group.

binary_0011 04-12-2006 01:23 AM

Thanks, it worked.

fenerli 08-22-2007 12:32 AM

Quote:

Originally Posted by haertig (Post 2194767)
uselpa listed the correct procedure. You will probably need to unmount any mounted logical volumes before these commands will work however. I usually do this type of low level stuff from runlevel 1, so filesystem unmounting is easier (no pesky users or processes holding the filesystems open). Also, as opposed to running "lvchange -an" on each logical volume, you can do "vgchange -an" on the volume group and hit all the logical volumes at once. Then after you've renamed, run "vgchange -ay" to activate all the logical volumes with one command.

Don't forget to modify your /etc/fstab entries to reflect the new name of the volume group.

I did go to runlevel 1, and still cannot unmount the logical volumes. When I say 'umount -a' it says 'umount: /: device is busy' and of course, as you mentioned, when I try to do vgchange -an w/o unmounting, it complains. Can you please help with this?

Thanks.

syg00 08-22-2007 12:37 AM

Do your work from a liveCD that has LVM support.

fenerli 08-22-2007 12:52 AM

Quote:

Originally Posted by syg00 (Post 2866520)
Do your work from a liveCD that has LVM support.

Ok, I will try this. Thank you.

fenerli 08-23-2007 12:14 AM

Ok, here is what I did:

- I first edited /etc/fstab to change all "VolGroup00"s to "vg00"s
- I booted with Knoppix 5.1 live cd
- vgrename VolGroup00 vg00 --> success
- Reboot --> I get kernel panic. It says it cannot find VolGroup00. It does the same thing when I edit the kernel arguments to contain root=/dev/vg00/LogVol00 instead of root=/dev/VolGroup00/LogVol00, it does not work.

Thank you in advance for your help

fenerli 08-23-2007 05:42 PM

Quote:

Originally Posted by fenerli (Post 2867611)
Ok, here is what I did:

- I first edited /etc/fstab to change all "VolGroup00"s to "vg00"s
- I booted with Knoppix 5.1 live cd
- vgrename VolGroup00 vg00 --> success
- Reboot --> I get kernel panic. It says it cannot find VolGroup00. It does the same thing when I edit the kernel arguments to contain root=/dev/vg00/LogVol00 instead of root=/dev/VolGroup00/LogVol00, it does not work.

Thank you in advance for your help

Does anyone know what I should do now?

Thank you.

cojo 08-24-2007 12:14 AM

how far did you get before it give you kernel panic? Can you paste your grub.conf and fstab?

tofino_surfer 08-24-2007 12:42 AM

edit initrd init file contents to change vg references
 
Hello,

You need to change the contents of the nash init file inside your initrd ramdisk to remove references to your old volume names. There are typically three. The initrd file is ( on Fedora at least ) a compressed loopback filesystem. You need to:

1. gunzip initrd-2.6....img
2. mkdir ramdisk
3. mount -t ext2 -o loop initrd-2.6...img ramdisk
4. cd ramdisk

There will be a nash script which is called init in Fedora and linuxrc on other distros. In my init file there are three references to VolGroup00. These and possibly all others will need to be changed.

echo Scanning logical volumes
lvm vgscan --ignorelockingfailure
echo Activating logical volumes
lvm vgchange -ay --ignorelockingfailure VolGroup00
resume /dev/VolGroup00/LogVol01
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro /dev/VolGroup00/LogVol00

Please change these references in a text editor, umount ramdisk, and recompress (gzip) the edited image. You will also need to, if you haven't already, change all references to the old volume name in the /dev directory. These may have been changed by the rename command.

Let me know if this works.

fenerli 08-24-2007 05:40 PM

Quote:

Originally Posted by tofino_surfer (Post 2868801)
Hello,

You need to change the contents of the nash init file inside your initrd ramdisk to remove references to your old volume names. There are typically three. The initrd file is ( on Fedora at least ) a compressed loopback filesystem. You need to:

1. gunzip initrd-2.6....img
2. mkdir ramdisk
3. mount -t ext2 -o loop initrd-2.6...img ramdisk
4. cd ramdisk

There will be a nash script which is called init in Fedora and linuxrc on other distros. In my init file there are three references to VolGroup00. These and possibly all others will need to be changed.

echo Scanning logical volumes
lvm vgscan --ignorelockingfailure
echo Activating logical volumes
lvm vgchange -ay --ignorelockingfailure VolGroup00
resume /dev/VolGroup00/LogVol01
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro /dev/VolGroup00/LogVol00

Please change these references in a text editor, umount ramdisk, and recompress (gzip) the edited image. You will also need to, if you haven't already, change all references to the old volume name in the /dev directory. These may have been changed by the rename command.

Let me know if this works.

Wow! Thank you very much for the detailed explanations. I appreciate them. For the last couple days, I did not have time to work on it. I will let you know when I try these.

tofino_surfer 08-27-2007 09:17 AM

old method of accessing intird posted in previous message
 
Hello,

In my previous message I stated that the initrd file was a compressed loopback filesystem. This was the old method which may be still in use in some distros. The new method in Fedora and other distros is a compressed cpio archive. To access this you need a temporary editing directory in which you will extract the cpio archive contents.


1. mdkir initrd-edit && cd initrd-edit
2. gzip -dc /boot/initrd-2.6...img | cpio -i -c
3. edit contents of directory, specifically init or linuxrc nash script

To repackage the initrd ( or initramfs )

1. cd /initrd-edit
2. find . | cpio --quiet -c -o >../newinitrd
3. cd ..
4. gzip -9 <newinitrd >initrd-2.6...img
5. copy the new initrd image to /boot

As I don't know which distro you use you will have to check which method of initrd creation yours uses. Have a look at the mkinitrd or mkinitramfs bash script ( usually in /sbin ) or simply gunzip the initrd file and look at its file type.

[root@localhost ~]# file initrd*
initrd-2.6.15-1.2054_FC5smp.img: ASCII cpio archive (SVR4 with no CRC)

Let me know if this works.

fenerli 08-27-2007 11:59 PM

Quote:

Originally Posted by tofino_surfer (Post 2872183)
Hello,

In my previous message I stated that the initrd file was a compressed loopback filesystem. This was the old method which may be still in use in some distros. The new method in Fedora and other distros is a compressed cpio archive. To access this you need a temporary editing directory in which you will extract the cpio archive contents.


1. mdkir initrd-edit && cd initrd-edit
2. gzip -dc /boot/initrd-2.6...img | cpio -i -c
3. edit contents of directory, specifically init or linuxrc nash script

To repackage the initrd ( or initramfs )

1. cd /initrd-edit
2. find . | cpio --quiet -c -o >../newinitrd
3. cd ..
4. gzip -9 <newinitrd >initrd-2.6...img
5. copy the new initrd image to /boot

As I don't know which distro you use you will have to check which method of initrd creation yours uses. Have a look at the mkinitrd or mkinitramfs bash script ( usually in /sbin ) or simply gunzip the initrd file and look at its file type.

[root@localhost ~]# file initrd*
initrd-2.6.15-1.2054_FC5smp.img: ASCII cpio archive (SVR4 with no CRC)

Let me know if this works.

Thank you very much, I could not look into this because I found some problem with the MoBo :) I am getting a replacement. When I get it, I will work on this too. Thank you again for detailed answers.

Agrouf 08-28-2007 01:07 AM

Or you can just use mkinitrd from the live CD to regenerate initrd.


All times are GMT -5. The time now is 07:41 PM.