LVM (logical volume manager) setup case (on RHEL4)

Source: Internet
Author: User

LVM (logical volume manager) setup case (on RHEL4)

1. LVM setup procedure

1. Prepare a partition

Fdisk/dev/hda (or/dev/SDA) the partition created in this case is/dev/hda15.
2. Create a PV

Pvcreate/dev/hda15 if there are many partitions/dev/hda15,/dev/hda16,/dev/hda17, pvcreae/dev/hda1 [5-7]
3. Create VG (vg_name is the name of VG)

Vgcreate vg_name/dev/hda15
If/dev/hda15,/dev/hda16,/dev/hda17 creates a VG, vgcreate vg_name/dev/hda1 [5-7]
4. Create LV (lv_name is the name of LV)

Lvcreate-N lv_name-L 10 m vg_name
5. format the LV

Mkfs. ext3/dev/vg_name/lv_name
6. Mount the File System

Mount/dev/vg_name/lv_name/LVM
LVM Management

1. Expand LV

When expanding the LV, you must increase the file system size.
1.1 expanded LV

Lvextend-l 20 m/dev/vg_name/lv_name (expanded LV to 20 m space)
Lvextend-L + 20 m/dev/vg_name/lv_name (increase the lv20m space and the current LV space is 30 m)
Increase the file system by 1.2 (this step is easy to neglect)

Assuming that the original file system size is 100 MB, and then 20 mb is added, the new file system is 120 MB.
Ext2online/dev/vg_name/lv_name 120 m
2. Shrink LV

[Assume that the file system is 10 m, the LV is 30 m, and the LV is to be reduced to 20 m.] When narrowing down the LV space, consider the actual file system size, the file may be unavailable.
2.1 reduce the File System (first uninstall the file system)

Umount/LVM
Fsck. ext3/dev/vg_name/lv_name
Resize2fs/dev/vg_name/lv_name 20 m
2.2 zoom out the file system (online operation, no need to uninstall) -- it seems difficult to make the Setting Process

Ext2online/dev/vg_name/lv_name 20 m
2.3 LV reduction

Lvreduce-l 20 m/dev/vg_name/lv_name
3. Expand VG

Vgextend/dev/hda1 [8-9] (the following partitions must be pvcreate before use)
4. You must delete the LV before deleting the VG. Back up data before deleting the LV !!!

4.1 Delete LV

Lvremove/dev/vg_name/lv_name
4.2 Delete VG

Vgremove
Case: Build LVM on RAID5



1. Prepare three shards with the same capacity

/Dev/hda7 509 744 1895638 + FD Linux raid autodetect
/Dev/hda8 745 980 1895638 + FD Linux raid autodetect
/Dev/hda9 981 1216 1895638 + FD Linux raid autodetect
2. Create RAID5

Mdadm -- create/dev/md0 -- level 5 -- raid-devices = 3/dev/hda [7-9]
3. Create
PV
Pvcreate/dev/md0
4. Create VG

Vgcreate vg0/dev/md0
5. Create an LV

Lvcreate-l 1024 M-N opt vg0 (1 GB space)
Lvcreate-l 500 m-N train vg0 (500m space)
6. format the LV

Mkfs. ext3/dev/vg0/OPT mkfs. ext3/dev/vg0/train
7. Create a mount point

CD/
Mkdir opt train
8. Modify the fstab file and add the following two lines to it:

..................
/Dev/vg0/opt/OPT ext3 defaults 1 2
/Dev/vg0/train ext3 defaults 1 2

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.