To mount an LVM volume or partition on Linux, you will first need to have the LVM utilities installed. You can install them using the package manager of your distribution. For example, on Ubuntu, you can use the command sudo apt-get install lvm2
.
Once the LVM utilities are installed, you can use the lvdisplay
command to list the available LVM volumes. You should be able to see the volume you want to mount in the list.
To mount the LVM volume, you will need to create a mount point. This is a directory where the volume will be mounted. For example, you can create a mount point at /mnt/my_volume.
Then, use the command sudo mount /dev/{volume group}/{logical volume} /mnt/my_volume
to mount the volume. Replace {volume group} and {logical volume} with the actual values from the lvdisplay output.
For example, if your volume group is “vg_data” and the logical volume is “lv_data”, the command will look like this:
sudo mount /dev/vg_data/lv_data /mnt/my_volume
It is also worth noting that if you want to mount the LVM partition automatically during boot, you need to add the above command to the /etc/fstab file.
In order to mount an LVM (Logical Volume Management) volume on Linux, you can use the following command:
- First, use the
lsblk
command to check the LVM volume name and path, it will show the volume group name and logical volume name, for example:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 100G 0 part /
└─sda2 8:2 0 8G 0 part [SWAP]
- Use the
vgdisplay
command to check the volume group name and logical volume name
vgdisplay
--- Volume group ---
VG Name myvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <8.00 GiB
PE Size 4.00 MiB
Total PE 2048
Alloc PE / Size 2048 / 8.00 GiB
Free PE / Size 0 / 0
VG UUID g8r1fZ-zUiC-oU6C-U6WQ-1Dd9-9aJZ-8r1fZ
- Use the
lvdisplay
command to check the logical volume name
lvdisplay
--- Logical volume ---
LV Path /dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID g8r1fZ-zUiC-oU6C-U6WQ-1Dd9-9aJZ-8r1fZ
LV Write Access read/write
LV Creation host, time ubuntu, 2020-07-12 18:11:51 +0800
LV Status available
# open 1
LV Size 8.00 GiB
Current LE 2048
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
- Now use the
mount
command to mount the volume.
sudo mount /dev/myvg/mylv /mnt
- To mount the volume automatically at boot, you need to add the following line to the /etc/fstab file
/dev/myvg/mylv /mnt ext4 defaults 0 0
- You can use
df -h
command to check the mounted volume
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 1.9G 99G 2% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 17M 3.9G 1% /dev/shm
tmpfs 3.9G