Unmount LVM Volumes

In situation where you're done with the volume and wanted to unmount the physical drive, you want to umount it. In this section, the guide shows you how to unmount a LVM volume all the way down to cryptsetup, ready for physical disk detachment.

Unmount all Mounting Points

The first thing to do is to unmount all mounting points for the logical volumes. This can be repetitive task until the logical volumes are free from active mounting.

Checking the Mounting Point

You can check the mounting point effectively using lsblk command:

$ lsblk
sdb                     8:0    0 931.5G  0 disk  
└─sdb1                  8:1    0 931.5G  0 part  
  └─sdb1_crypt        254:0    0 931.5G  0 crypt 
    ├─localstore-data 254:2    0 465.7G  0 lvm   /media/u0/drive1
    └─localstore-core 254:3    0 454.5G  0 lvm   /media/u0/drive2

Unmount The Drive

You can proceed to unmount the drive. Keep in mind that a drive can be mounted in multiple locations so you will need to check with lsblk command again until in produces the following output (which is considered safely unmounted):

$ lsblk
sdb                     8:0    0 931.5G  0 disk  
└─sdb1                  8:1    0 931.5G  0 part  
  └─sdb1_crypt        254:0    0 931.5G  0 crypt 
    ├─localstore-data 254:2    0 465.7G  0 lvm
    └─localstore-core 254:3    0 454.5G  0 lvm

There are various ways to unmount a drive, one way is:

$ umount /media/u0/drive1
OR
$ umount /dev/sdb1_crypt/localstore-data

Close the LVM Volumes

Once unmounted, it's time to close the LVM Volumes in sequence.

Close the Logical Volumes

The first step is to close the logical volumes. To do that, you do:

$ lvchange -an <lvpath>

From the example above, it is:

$ lvchange -an /dev/sdb1_crypt/localstore-data

Repeat for all the logical volumes inside the targeted LVM volume.


Close the LVM Volumes

The first step is to close the logical volumes. To do that, you do:

$ vgchange -an <vg_name>

From the example above, it is:

$ vgchange -an sdb1_crypt


[OPTIONAL] Unlink DM-Map

In some edge cases, you might need to unlink the dm-mapping. This is usually done automatically and is documented just in case for edge cases. You might not need it if it is done automatically. To manually unlink, you do:

$ dmsetup ls
sdb1_crypt (254:0)


$ dmsetup remove sdb1_crypt


Completed LVM Closure

At this point, the LVM Volume is closed completely.

[OPTIONAL] Close LUKS Partition

If your disk is not encrypted by cryptsetup, you may skip this step.

Now that the disk is ready, you may close the encrypted partition using cryptsetup. The step is outside of this guide. Hence, please follow the link below.

That's all for unmounting LVM Volume.