Linux Server LVM Logical volume configuration process

Source: Internet
Author: User

Linux Server LVM Logical volume configuration process

By using the logical Volume Manager of Linux (Logical Volume Manager, LVM), users can dynamically resize the file system while the system is running, relocate data from one hard drive to another, improve the performance of I/O operations, and provide redundant protection Its snapshot feature allows users to make real-time backups of logical volumes. For the general user, the most used is the ability to dynamically adjust the file system size. This way, you do not have to worry about how to set the partition size, as long as you reserve some free space on the hard disk, and then adjust the partition size dynamically according to the usage of the system. The following is an LVM configuration process implemented in a VMware virtual machine.

Note: The hard disk SDB is the hard disk that is added to the virtual machine .

Create a logical volume

0, Fdisk-l View the partition situation.

1, Fdisk/dev/sdb Create the partition/DEV/SDB1/DEV/SDB2 and add the Mark 8e, and finally to save W.

2, PVCREATE/DEV/SDB1/DEV/SDB2 create physical volume PV.

3. Vgcreate VGDATA/DEV/SDB1/DEV/SDB2 Creates a volume group (VG) named Vgdata, which contains 2 physical volumes.

4, lvcreate-l 100m-n lvdata1 vgdata Create Logical Volume (LV) named Vgdata on volume group lvdata1, size 100M.

5. mkfs.ext4/dev/vgdata/lvdata1 Create the Ext4 file system on the lvdata1.

6. Mount/dev/vgdata/lvdata1/data1 the logical volume LVDATA1 to the/DATA1 directory.

Note: Set the restart Auto Mount method:

(1) View uuid by command bilid.

(2) Add mount information to the/etc/fstab.

Second, expand the logical Volume LVDATA1

1, Lvextend-l +50m/dev/vgdata/lvdata1 The logical volume LVDATA1 increased by 50M.

2, Resize2fs/dev/vgdata/lvdata1

Three, extended volume group Vgdata

1. Create the partition SDB3 and create it as a physical volume PV.

1. Vgextend vgdata/dev/sdb3 adds the partition/dev/sdb3 to the volume group Vgdata.

Iv. How to reduce the space for a logical volume to be used for other logical volumes (for example, to reduce the space of logical volume LVDATA1) when hard disk space is insufficient

1, Umount/data1 unload the logical volume.

2. E2fsck-f/dev/mapper/vgdata-lvdata1 detects the remaining space of the logical volume LVDATA1.

3, resize2fs/dev/mapper/vgdata-lvdata1 50M reduce the file system to 50M.

4, Lvreduce-l 50m/dev/vgdata/lvdata1 to reduce the volume lvdata1 to 50M.

5, mount/dev/vgdata/lvdata1/data1/mount.

V. How to quickly transfer data to other spaces in the same volume group if a piece of disk or partition fails (for example, SDB1 is broken)

1. PVMOVE/DEV/SDB1/DEV/SDB2 transfer data from SDB1 to SDB2.

2, Vgreduce vgdata/dev/sdb1 Remove the partition sdb1 from the Vgdata.

3, PVREMOVE/DEV/SDB1 the physical volume into a normal partition.

4. Manually remove the hard drive or repair the partition with some tools.

Vi. deleting the entire logical volume

1, Umount/data1 unload the logical volume.

2, modify the/etc/fstab inside the logical volume mount information, or the system may not start up.

3, Lvremove/dev/vgdata/lvdata1 Delete the logical volume LVDATA1.

4, Vgremove vgdata Delete the volume group.

5, pvremove/dev/sdb2/dev/sdb3 the physical volume into a normal partition.

6, the modified partition is marked as a common Linux partition mark (83), the last to save W.




This article from the "Galaxy | Computer network" blog, declined to reprint!

Linux Server LVM Logical volume configuration process

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.