Linux mount an LVM volume / partition command
-
by cobra_admin
- 84
Ihave some data on second SATA hard disk created by Fedora Linux installer with some data. How do I mount an LVM volume or partition in Linux to access my data? Can you tell me the command to mount LVM partition in Linux?
Introduction: LVM is an acronym for Logical Volume Manager. LVM is a device mapper that provides logical volume management for the Linux kernel. You can access LVM partitions from an external USB hard disk or second hard disk installed in your system. This page shows how to mount an LVM partition or volume on Linux using the CLI.
| Tutorial details | |
|---|---|
| Difficulty level | Intermediate |
| Root privileges | Yes |
| Requirements | Linux terminal |
| Category | System Management |
| OS compatibility | Alma • Alpine • Arch • CentOS • Debian • Fedora • Mint • openSUSE • Pop!_OS • RHEL • Rocky • Stream • SUSE • Ubuntu |
| Est. reading time | 4 minutes |
Here are the command to mount an LVM partition in Linux. If lvm2 not installed on your system, install it as per your Linux distro package manager utility. For example:
Fedora Linux install lvm
Use the dnf command:
$ sudo dnf install lvm2CentOS/RHEL/Oracle Linux install lvm
Type the yum command:
$ sudo yum install lvm2OpenSUSE/SUSE Linux install lvm2
Programs and man pages for configuring and using the LVM2 Logical Volume Manager installed using the zypper command:
$ sudo zypper install lvm2Debian/Ubuntu Linux install lvm
Try apt command or apt-get command:
$ sudo apt install lvm2Arch Linux install LVM2 package
Use the pacman command:
$ sudo pacman -S lvm2Outputs:
resolving dependencies… looking for conflicting packages… Packages (3) libaio-0.3.112-2 thin-provisioning-tools-0.8.5-3 lvm2-2.02.187-1 Total Download Size: 1.82 MiB Total Installed Size: 8.05 MiB :: Proceed with installation? [Y/n]
Alpine Linux install LVM 2
Try the apk command:
# apk update
# apk add lvm2I have the second SATA hard disk (SSD) created by the Fedora Linux installer with essential data. I want to access that data on a new Linux computer. So let us see how to mount an LVM volume or partition in Linux to access the data. Make sure you switch off your Linux computer and add 2nd HDD. Then turn it on. There is no need to turn off the computer for an external USB HDD.
How to mount LVM partition in Linux
The procedure to mount LVM partition in Linux as follows:
Run vgscan command scans all supported LVM block devices in the system for VGs.
Execute vgchange command to activate volume.
Type lvs command to get information about logical volumes.
Create a mount point using the mkdir command.
Mount an LVM volume under Linux using sudo mount /dev/mapper/DEVICE /path/to/mount command.
Let us see all steps in details to mount LVM partition or volume on Ubuntu Linux.
How to mount an LVM volume
Type the following command to find info about LVM devices:
$ sudo vgscanOR
$ sudo vgscan --mknodesAbove output indicates that I have “fedora_localhost-live” LVM group. To activate it run:
$ sudo vgchange -ayOR
$ sudo vgchange -ay fedora_localhost-liveYou can run the following command to list it:
$ sudo lvdisplayOR
$ sudo lvsYou can get good look at using the ls command:
$ ls -l /dev/fedora_localhost-live/Sample outputs:
total 0 lrwxrwxrwx 1 root root 7 Aug 17 15:47 home -> ../dm-1 lrwxrwxrwx 1 root root 7 Aug 17 15:47 root -> ../dm-2 lrwxrwxrwx 1 root root 7 Aug 17 15:47 swap -> ../dm-0
Mount an LVM partition
Create a mount point using the mkdir command:
$ sudo mkdir -vp /mnt/fedora/{root,home}Sample outputs:
mkdir: created directory ‘/mnt/fedora/root’ mkdir: created directory ‘/mnt/fedora/home’
Mount lvm volume using the mount command
Next, mount both home and root logical volume from LV path using the following syntax:
$ sudo mount {LV_PATH} /path/to/mount/point/
$ sudo mount /dev/fedora_localhost-live/home /mnt/fedora/home
$ sudo mount /dev/fedora_localhost-live/root /mnt/fedora/rootVerify it with the help of df command or grep command:
$ df -T
$ df -T | grep -i fedora
$ ls /mnt/fedora/root
$ ls /mnt/fedora/homeClick to enlarge image
Update the /etc/fstab
Update the /etc/fstab file if you want a logical volume to be mounted automatically on Linux system boot. For example, mount lvm2 member partition automatically I added the following two lines:
/dev/mapper/fedora_localhost–live-root /mnt/fedora/root ext4 defaults 0 0 /dev/mapper/fedora_localhost–live-home /mnt/fedora/home ext4 defaults 0 0
Conclusion
You just learned various steps to access an LVM from Linux based system. For more info see this page here and here. Also, read the docs offline using the man command or help command:
$ man vgscan
$ man vgchange
$ man lvsIhave some data on second SATA hard disk created by Fedora Linux installer with some data. How do I mount an LVM volume or partition in Linux to access my data? Can you tell me the command to mount LVM partition in Linux? Introduction: LVM is an acronym for Logical…
Ihave some data on second SATA hard disk created by Fedora Linux installer with some data. How do I mount an LVM volume or partition in Linux to access my data? Can you tell me the command to mount LVM partition in Linux? Introduction: LVM is an acronym for Logical…