Direct mount/Uninstall of LVM partition tutorial in Linux

Source: Internet
Author: User
Tags uuid

The LVM is shorthand for Logical Volume Manager (Logical Volume management), a mechanism for managing disk partitions in a Linux environment that is implemented by Heinz Mauelshagen on the Linux 2.4 kernel. The latest version is: Stable version 1.0.5, development version 1.1.0-rc2, and LVM2 development version. A common and difficult problem that Linux users encounter when installing Linux operating systems is how to properly assess the size of each partition to allocate appropriate hard disk space. Normal disk partition management is not able to change the size of the logical partition, when a logical partition is not stored in a file, this file because of the upper file system is limited, also can not span multiple partitions to store, so also can not be placed on other disks. When a partition is exhausted, the solution is usually to use symbolic links, or to adjust the size of the partition tool, but this is only a temporary solution, does not fundamentally solve the problem. With the advent of Linux logical volume management functions, these problems are solved, users can easily adjust the size of each partition without downtime.

How to have a USB disk containing the LVM partition. I want to access these LVM partitions in Linux. How can I mount an LVM partition on Linux?

In LVM, the physical storage that creates a logical partition is a traditional partition (for example,/DEV/SDA2,/DEV/SDB1). These partitions must be initialized to "physical volume PV" and labeled with a volume label (e.g. "Linux LVM") to enable them to be used in LVM. Once the partition is marked by an LVM partition, you cannot mount the mount command directly.

If you try to mount an LVM partition (such as/DEV/SDB2), you will get the following error.

$ mount/dev/sdb2/mnt mount:unknown filesystem type ' Lvm2_member '


To properly mount the LVM partition, you must mount the logical volume created in the partition. Here's how to do it.

First, check the available volume groups with the following command:

$ sudo pvs PV VG Fmt Attr psize pfree/dev/sdb2 vg_ezsetupsystem40a8f02fadd0 lvm2 a--237.60g 0


The name of the physical volume and the name of the volume group are under the PV and VG columns respectively. In this case, there is only one group "vg_ezsetupsystem40a8f02fadd0" that is created under DEV/SDB2.

Next, check the logical volumes that exist in the volume group and use the Lvdisplay command:

$ sudo lvdisplay

Use Lvdisplay to display information about the available volumes (such as device name, volume name, volume size, and so on).

$ sudo lvdisplay/dev/vg_ezsetupsystem40a8f02fadd0
---Logical volume---
LV Path/dev/vg_ezsetupsystem40a8f02fadd0/lv_root
LV Name Lv_root
VG Name vg_ezsetupsystem40a8f02fadd0
LV UUID Imygta-p2rv-2smu-5ugq-g99d-a0cb-m31eet
LV Write Access Read/write
LV creation host, Time Livecd.centos, 2015-03-16 18:38:18-0400
LV Status Available
# Open 0
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 252:0


The image above can be seen with the names of two logical volumes: Lv_root and Lv_home

If you want to mount a specific logical volume, use the following "LV Path" device name (such as:/dev/vg_ezsetupsystem40a8f02fadd0/lv_home).

$ sudo mount/dev/vg_ezsetupsystem40a8f02fadd0/lv_home/mnt

You can use the Mount command to check the mount status without any parameters, which displays all mounted file systems.

$ mount

If you want to mount the logical volume automatically at each startup and add the following line to the/etc/fstab, you can specify the file system type (such as EXT4) of the volume, which can be found from the output of the Mount command.

/dev/vg_ezsetupsystem40a8f02fadd0/lv_home/mnt EXT4 Defaults 0 0

The logical volume is now mounted to/mnt at each startup.


manually mount an LVM partition (volume group)

[Inbi@debian ~] #fdisk-L
... Slightly
#查看系统检测到的硬盘个数, and their zoning.
[Inbi@debian ~] #vgscan
Reading all physical volumes. This could take a while ...
Found Volume Group "VolGroup00" using metadata type LVM2
Found Volume Group "VolGroup00" using metadata type LVM2
#查找系统中存在的LVM卷组, and displays a list of the found volume groups.
[Inbi@debian ~] #lvscan
Lvscan '/dev/volgroup00/logvol00 ' [465.76 GB] Inherit
ACTIVE '/dev/volgroup00/logvol00 ' [465.76 GB] Inherit
#查看卷组激活状态, and what logical volumes are in the volume group.
[Inbi@debian ~] #vgdisplay VolGroup00 | More
... Slightly
#显示所有名为VolGroup00卷组的详细信息, remember that you will be mounting the VG UUID for the volume group.
[Inbi@debian ~] #vgrename o236o6-mgaq-erkg-k6ch-12zs-8nwx-ccqpg3 vg001
#卷组重命名, only inactive volume groups can be renamed!
#为什么要重命令? One of the two volume group names cannot be mounted.
[Inbi@debian ~] #vgscan
.. Slightly
#看看是否已重命名.
[Inbi@debian ~] #vgchange-ay/dev/vg001
#激活卷组 vg001
[Inbi@debian ~] #lvscan
#查看是否已激活
[Inbi@debian ~] #mount-T ext3/dev/vg001/logvol00/mnt
#把卷组的一个逻辑卷挂载到 the/mnt directory.

uninstalling LVM Volume groups

[Inbi@debian ~] #umount/mnt
#卸载挂载到 the partition of the/MNT directory.
[Inbi@debian ~] #vgchange-an/dev/vg001
#把卷组修改成不激活状态.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.