Disk management-LVM

Source: Internet
Author: User

Disk management-LVM

LVM is short for Logical Volume Manager. It is a mechanism for managing disk partitions in Linux, LVM is a logical layer built on hard disks and partitions to improve disk partition management flexibility. Next, we will use the experiment to learn more about the use of LVM.

Linux Tutorial: Use LVM logical volume manager to manage flexible storage

Configure LVM (logical volume management) in CentOS 6.3)

Linux LVM simple tutorial

Linux LVM (Logical Volume Manager) Study Notes

RHCE certification notes: LVM lab

Linux System Management-LVM case

1. Prepare the experiment environment. Add an unused disk/dev/sdb, use fdisk to separate two 5g partitions from the disk, and set its partition type to 8e.

[Root @ localhost ~] # Fdisk-l/dev/sdb

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Sector size (logical/physical): 512 bytes/512 bytes

I/O size (minimum/optimal): 512 bytes/512 bytes

Disk identifier: 0x0f199ec4

Device Boot Start End Blocks Id System

/Dev/sdb1 1 654 5253223 + 8e Linux LVM

/Dev/sdb2 655 1308 5253255 8e Linux LVM


2. Create a physical volume:

[Root @ localhost ~] # Pvcreate/dev/sdb1

Physical volume "/dev/sdb1" successfully created

[Root @ localhost ~] # Pvcreate/dev/sdb2

Dev_is_mpath: failed to get device for 8:18

Physical volume "/dev/sdb2" successfully created

[Root @ localhost ~] # Pvscan

PV/dev/sda2 VG vg0 lvm2 [59.99 GiB/7.99 GiB free]

PV/dev/sdb1 lvm2 [5.01 GiB]

PV/dev/sdb2 lvm2[ 5.01 GiB]

Total: 3 [70.01 GiB]/in use: 1 [59.99 GiB]/in no VG: 2 [10.02 GiB]


3. Create a volume group based on the physical volume and add/dev/sdb1 to the volume group.

[Root @ localhost ~] # Vgcreate test/dev/sdb1

Volume group "test" successfully create

[Root @ localhost ~] # Vgscan # You can see that the volume group test has been created successfully.

Reading all physical volumes. This may take a while...

Found volume group "test" using metadata type lvm2

Found volume group "vg0" using metadata type lvm2


4. Create a 4G logical volume test1 in the volume group test

[Root @ localhost ~] # Lvcreate-L 4G-n test1 test

Logical volume "test1" created

[Root @ localhost ~] # Lvscan

ACTIVE '/dev/test/test1' [4.00 GiB] inherit # test1 has been created successfully

ACTIVE '/dev/vg0/root' [20.00 GiB] inherit

ACTIVE '/dev/vg0/swap' [2.00 GiB] inherit

ACTIVE '/dev/vg0/usr' [10.00 GiB] inherit

ACTIVE '/dev/vg0/var' [20.00 GiB] inherit


5. Next, you can format test1 according to the common partition, and mount and use

[Root @ localhost ~] # Mkfs. ext4/dev/test/test1

Mke2fs 1.41.12 (17-May-2010)

......

This filesystem will be automatically checked every 34 mounts or

180 days, whichever comes first. Use tune2fs-c or-I to override.

[Root @ localhost ~] # Mkdir/test

[Root @ localhost ~] # Mount/dev/test/test1/test/

[Root @ localhost ~] # Df-h

Filesystem Size Used Avail Use % Mounted on

/Dev/mapper/vg0-root 20G 428 M 19G 3%/

Tmpfs 246 M 0 246 M 0%/dev/shm

/Dev/sda1 194 M 30 M 155 M 16%/boot

/Dev/mapper/vg0-usr 9.9G 2.3G 7.2G 24%/usr

/Dev/mapper/vg0-var 20G 361 M 19G 2%/var

/Dev/mapper/test-test1 4.0G 136 M 3.7G 4%/test # logical volume created successfully


6. Put a file under/test to test whether the file can be used.

[Root @ localhost test] # echo "lv test"> a.txt

[Root @ localhost test] # cat a.txt

Lv test

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.