Operating System - HP-UX
1832350 Members
2566 Online
110041 Solutions
New Discussion

Re: Change logical volume name

 
SOLVED
Go to solution
Juan Gonzalez_2
Frequent Advisor

Change logical volume name

Is there a way to change the logical volume name without losing the data on the disk. Like for example we have /dev/vg21/lvol1 I want to change it to /dev/vg21/rice. What I do not want is to restore the data from backup. Can I do a vgexport -m create a map file then do a vgimport but with a different logical volume?
6 REPLIES 6
Patrick Wallek
Honored Contributor
Solution

Re: Change logical volume name

This should work, though I have never tried it.

Using your /dev/vg21/lvol1 to /dev/vg21/rice as an example:

1) Unmount whatever dir /dev/vg21/lvol1 is mounted to.

# umount /whatever

2) Rename the LV

# cd /dev/vg21
# mv lvol1 rice
# mv rlvol1 rrice

Note that in this step you MUST mv BOTH the lvol1 and rlvol1 files. Be SURE that you include the leading 'r' in the new name for the rlvol1 to rrice (2 r's in this rice).

3) Modify /etc/fstab to change the name the lvol that is mounted from /dev/vg21/lvol1 to /dev/vg21/rice

# cp /etc/fstab /etc/fstab.back
# vi /etc/fstab

4) Remount the LV

# mount /whatever
Con O'Kelly
Honored Contributor

Re: Change logical volume name

Hi Juan

You can change the name of a Logical Volume using the following steps:

1. Umount the Filesystem
2. mv /dev/vg21/lvol1 /dev/vg21/rice
3. mv /dev/vg21/rlvol1 /dev/vg21/rrice
4. Edit /etc/fstab
5. Mount filesystem

Note that you cannot rename a Volume Group without recreating it.

Cheers
Con
steven Burgess_2
Honored Contributor

Re: Change logical volume name

Hi

The above is also in the knowledge base

http://www5.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000062941034

HTH

Steve
take your time and think things through
Sunil Sharma_1
Honored Contributor

Re: Change logical volume name

Hi,

as other says that method will work and alternatively you can use following method.
it's bit lenthy.

1. unmount file system
2. note down the Major and minor number of lvol1/rlvol1.
3. delete device file for lvol1 and rrlvol1.
4. recreate device file name rice rrice with same major and minor numbers using mknod.
5. change fstab and rmount it.

Sunil
*** Dream as if you'll live forever. Live as if you'll die today ***
Jakes Louw
Trusted Contributor

Re: Change logical volume name

Sunil is on the right track, but you don't need to unmount:

Get the minor number for the lvol you want to rename: let's say 0x1a0000,

mknod /dev/vgxx/rnewlvol c 64 0x1a0000
mknod /dev/vgxx/newlvol b 64 0x1a0000

Now test this:
lvdisplay -v /dev/vgxx/newlvol

Compare this to an lvdisplay of the old lvol. It will be the same.
Now you have the option to use the new name without any funny business. You can delete the old names (using rm, not lvremove!) once you are happy that you do not use the old lvol name anywhere where you have not changed it to the new (like in /etc/fstab, scripts, Omniback, etc).
Trying is the first step to failure - Homer Simpson
Juan Gonzalez_2
Frequent Advisor

Re: Change logical volume name

Thanks for the good information Patrick and Con. The other ways to rename the logical volume that were mentioned will distroy the data on the disk, not good.