Linux mount an LVM volume / partition command
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_volumeIt 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
lsblkcommand to check the LVM volume name and path, it will show the volume group name and logical volume name, for example:
lsblkrnNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTrnsda 8:0 0 100G 0 disk
├─sda1 8:1 0 100G 0 part /
└─sda2 8:2 0 8G 0 part [SWAP]- Use the
vgdisplaycommand to check the volume group name and logical volume name
vgdisplayrn --- Volume group ---
VG Name myvgrn System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/writern VG Status resizablern MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <8.00 GiBrn PE Size 4.00 MiBrn Total PE 2048
Alloc PE / Size 2048 / 8.00 GiBrn Free PE / Size 0 / 0
VG UUID g8r1fZ-zUiC-oU6C-U6WQ-1Dd9-9aJZ-8r1fZ- Use the
lvdisplaycommand to check the logical volume name
lvdisplayrn --- Logical volume ---
LV Path /dev/myvg/mylvrn LV Name mylvrn VG Name myvgrn LV UUID g8r1fZ-zUiC-oU6C-U6WQ-1Dd9-9aJZ-8r1fZrn LV Write Access read/writern LV Creation host, time ubuntu, 2020-07-12 18:11:51 +0800
LV Status availablern # open 1
LV Size 8.00 GiBrn Current LE 2048
Segments 1
Allocation inheritrn Read ahead sectors autorn - currently set to 256
Block device 253:2- Now use the
mountcommand 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 -hcommand to check the mounted volume
df -hrnFilesystem Size Used Avail Use% Mounted onrn/dev/sda1 100G 1.9G 99G 2% /
devtmpfs 3.9G 0 3.9G 0% /devrntmpfs 3.9G 17M 3.9G 1% /dev/shmrntmpfs 3.9G