How to rename logical volume in Linux and HPUX

Learn how to rename logical volume in Linux or Unix. Understand what happens in the background when you change the logical volume name of existing LVOL.

LVM i.e. logical volume manager is one of the widely used volume managers in Linux and Unix. A logical volume is a portion of the volume group which can be mounted on a mount point. Once mounted, space belonging to that logical volume is available for use to end-user.

In this post, we are going to see step by step how to rename logical volume. In Linux, lvrename is a direct command which does this stuff for you. But first, we will see how it works in the background so that you know the flow and you can rename LV even without lvrename command.

LV renaming procedure follows below flow :

  1. Stop all user/app access to related mount point (on which lvol is mounted) using fuser
  2. Un-mount LV using umount
  3. Rename device names of lvol using mv
  4. Mount LV using mount
  5. Edit /etc/fstab entry related to this lvol using vi

Let’s see an example where we are renaming /dev/vg01/lvol1 which is mounted on /data to /dev/vg01/lvol_one. See the below output for the above-mentioned steps (HPUX console).

# bdf /data
/dev/vg01/lvol1 524288 49360 471256 9% /data
# fuser -cku /data
/data:   223412c(user1)
# umount /data
# mv /dev/vg01/lvol1 /dev/vg01/lvol_one
# mv /dev/vg01/rlvol1 /dev/vg01/rlvol_one
# mount /data
# bdf /data
/dev/vg01/lvol_one    524288    49360   471256  9%   /data

In the above output, you can see how we renamed logical volume just by renaming its device files.

In Linux, we have a single command lvrename which do all the above steps in the background for you. You just need to provide it with old and new lvol names along with the volume group where this lvol belongs. So, the above scenario will have below command –

# lvrename vg01 lvol1 lvol_one
  Renamed "lvol1" to "lvol_one" in volume group "vg01"

You can see in the output that single command renamed lvol1 to lvol_one! This command also supports below option :

  • -t For test
  • -v Verbose mode
  • -f Forceful operation
  • -d debug

2 thoughts on “How to rename logical volume in Linux and HPUX

  1. vishal

    Hi,

    Your information is helpful. I need to know that I need to rename file system /oradata to /oradata_old and use new file /oradata1 lets say. Can I simply change /oradata with mv /dev/mapper/1500g-oradata/oradata /dev/mapper/1500g-oradata/oradata_old. Please share your help on this.

    /dev/mapper/1500g-oradata 1548046564 1065192004 404194976 73% /oradata

    Regards, Vj

    Reply
    1. Shrikant Lavhate Post author

      Hope I understood correctly. You need /oradata to be /oradata1.
      VG name is 1500g and LV name is oradata

      # mkdir /oradata1
      # umount /oradata (Make sure /oradata is not being accesses by anyone with fuser)
      # mount /dev/1500g/oradata /oradata1

      Edit /etc/fstab to make change permanent over reboot.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.