Linux LVM Logical Volume configuration increase hard disk expansion example

Source: Internet
Author: User
Tags uuid hex code

Centos LVM is a mechanism for managing disk partitions in a Linux environment, a logical layer that is built on top of hard disks and partitions, under the file system, and improves disk partition management flexibility. RHEL5 the default installed partition format is the LVM logical volume format, it should be noted that the/boot partition cannot be created based on LVM and must be independent.

Create Logical Volume PV

PVCREATE/DEV/SDA1/DEV/SDB1 (sda1 sdb1 hex code:8e is LVM) PVs Pvdisplay

Create Group VG

Vgcreate Group name/DEV/SDA1/DEV/SDB1 VGS Vgdisplay

Create Logical Volume LV

Lvcreate-l 5000m-n Logical Volume group name LVS Lvdisplay

MKFS.EXT4 && Mount

LVM increases Drive capacity

The SDC1 hex code:8e is the Linux LVM

Vgextend Group name/DEV/SDC1

Lvextend-l +10.25g/dev/Group name/Logical volume name

resize2fs/dev/Group name/Logical volume name

Example

1. View the hard disk partition situation
#fdisk-L
Note: Suppose the device file named/dev/sdb for a new hard drive
2. Start partitioning
#fdisk/dev/sdb
3. View command Help information
Command (M for help): M
4. View existing partitioned tables
Command (M for help): P
disk/dev/sdb:500.0 GB, 500097376256 bytes
255 heads, Sectors/track, 60800 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 * 1 60800 488375968 7 hpfs/ntfs
Note: You can see that the hard drive already has a partition and all the cylinders are allocated
5. Delete the original partition
Command (M for help): D
6. View the partition table again
Command (M for help): P
disk/dev/sdb:500.0 GB, 500097376256 bytes
255 heads, Sectors/track, 60800 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
7. New partitions
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
8. Select the partition type (primary, extended, partition), partition
P
1
9. Set the column range of the partition, where start and end are default, direct return
10. View the partition table
Command (M for help): P
disk/dev/sdb:500.0 GB, 500097376256 bytes
255 heads, Sectors/track, 60800 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 1 60800 488375968+ Linux
11. Change the type of partition
Command (M for help): t
Selected partition 1
Hex code (type L to list codes): L
Note: If you have more than one partition, you will be prompted to select the partition
1
0 Empty 1e Hidden W95 FAT1 old Minix BF Solaris
2
1 FAT12 NEC DOS bayi minix/old Lin C1 drdos/sec (fat-
3
2 Xenix root Plan 9 swap/so Linux c4 drdos/sec (fat-
4
3 Xenix usr 3c partitionmagic c6 drdos/sec (fat-
5
4 FAT16 <32m Venix 80286-OS/2 hidden c:c7 Syrinx
6
5 Extended PPC PReP Boot Linux Extended da non-fs data
7
6 FAT16 SFS NTFS Volume set db cp/m/CTOs/.
8
7 Hpfs/ntfs 4d qnx4.x NTFS Volume set de Dell Utility
9
8 AIX 4e qnx4.x 2nd part Linux plaintext DF bootit
10
9 AIX Bootable 4f qnx4.x 3rd part 8e Linux LVM E1 DOS Access
11
A os/2 Boot manag ontrack DM amoeba E3 DOS r/o
12
b W95 FAT32 Ontrack DM6 Aux, Amoeba BBT e4 SpeedStor
13
C W95 FAT32 (LBA) cp/m 9f bsd/os EB BeOS FS
14
E W95 FAT16 (LBA) Ontrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
15
F W95 Ext ' d (LBA) OnTrackDM6 a5 FreeBSD ef EFI (fat-12/16/
16
OPUS ez-drive a6 OpenBSD f0 linux/pa-risc b
17
One Hidden FAT12 Golden Bow A7 NeXTSTEP F1 SpeedStor
18
Compaq Diagnost 5c Priam edisk A8 Darwin UFS f4 SpeedStor
19
Hidden FAT16 <3 speedstor A9 NetBSD F2 DOS Secondary
20
Hidden FAT16 the GNU HURD or Sys ab Darwin boot fb VMware VMFS
21st
Hidden hpfs/ntf Novell Netware b7 BSDI FS FC VMware Vmkcore
22
The AST smartsleep Novell Netware b8 bsdi swap fd Linux RAID auto
23
1b Hidden W95 FAT3 disksecure mult bb Boot Wizard hid Fe lanstep
24
1c Hidden W95 FAT3 pc/ix be Solaris boot ff BBT
12. Set the disk format to Linux LVM
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
13. View the partition table again
Command (M for help): P
disk/dev/sdb:500.0 GB, 500097376256 bytes
255 heads, Sectors/track, 60800 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 1 60800 488375968+ 8e Linux LVM
14. Save, quit Fdisk
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
If an error occurs, use the partprobe instruction to overload the partition table
15. View the hard disk partition situation
#fdisk-L
disk/dev/sdb:500.0 GB, 500097376256 bytes
255 heads, Sectors/track, 60800 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 1 60800 488375968+ 8e Linux LVM
16. View the physical volumes already on the system
#pvdisplay
---physical volume---
PV Name/dev/sda2
VG Name VolGroup00
PV Size 297.99 gb/not usable 20.87 MB
Allocatable Yes (but full)
PE Size (KByte) 32768
Total PE 9535
Free PE 0
Allocated PE 9535
PV UUID OA2RNU-TZ2C-N1W0-AKCV-9UNE-CTDP-38DFQD
17. Establish a physical volume
#pvcreate/DEV/SDB1
Writing physical volume data to disk "/DEV/SDB1"
Physical volume "/DEV/SDB1" successfully created
18. Add a new physical volume to a volume group
#vgextend VOLGROUP00/DEV/SDB1
Volume Group "VolGroup00" successfully extended
19. Add the new space to the original logical volume
#lvextend-l+500g/dev/volgroup00/logvol00
20. Activate the expandable LVM partition
#resize2fs-P/dev/volgroup00/logvol00
21. If not expansion, you can increase the logical volume
#lvcreate-L 200g-n lvol0 VolGroup00
Logical volume "lvol0" created
22. Delete logical Volumes
#lvremove/dev/mapper/volgroup00-lvol0
23. View a logical volume that already exists
#lvdisplay
---Logical volume---
LV name/dev/volgroup00/logvol00
VG Name VolGroup00
LV UUID ipf0gk-3xxu-vn0i-cxbm-zkld-xuju-mde02z
LV Write Access Read/write
LV Status Available
# open 1
LV Size 48.81 GB
Current LE 1562
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:0
---Logical volume---
LV name/dev/volgroup00/logvol02
VG Name VolGroup00
LV UUID RYBA0Q-5B8T-BOWA-SSPK-PRAI-QSIX-KCEWWI
LV Write Access Read/write
LV Status Available
# open 1
LV Size 49.91 GB
Current LE 1597
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:1
---Logical volume---
LV NAME/DEV/VOLGROUP00/LOGVOL03
VG Name VolGroup00
LV UUID Czznk0-vsuk-vatj-vbam-pdjs-1yzt-a6bpgk
LV Write Access Read/write
LV Status Available
# open 1
LV Size 195.31 GB
Current LE 6250
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:2
---Logical volume---
LV name/dev/volgroup00/logvol01
VG Name VolGroup00
LV UUID ZVLPEL-DJ8Y-A0XG-4H7Q-ZPAA-XUXY-0LN7QW
LV Write Access Read/write
LV Status Available
# open 1
LV Size 3.94 GB
Current LE 126
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:3
24. Official New Logical Volume
#lvcreate-L 500g-n LogVol04 VolGroup00
25. Formatting new Logical volumes
#mkfs. ext3/dev/mapper/volgroup00-logvol04
26. Mount Logical Volume
#mount/dev/mapper/volgroup00-logvol04/data
27. Edit/etc/fstab Set up the new logical volume mount, add the following line
/dev/volgroup00/logvol04/data ext3 Defaults 1 2
28. Test Mount
Mount-a
29. View and Delete physical volumes
View Mount Status
#df-H
/dev/mapper/volgroup00-logvol04
296G 245M 281G 1%/backup
Unloading
#umount/backup
Delete Logical Volume
#lvremove/DEV/MAPPER/VOLGROUP00-LOGVOL04
View physical Volumes
#pvdisplay
---physical volume---
PV Name/dev/sda2
VG Name VolGroup00
PV Size 297.99 gb/not usable 20.87 MB
Allocatable Yes (but full)
PE Size (KByte) 32768
Total PE 9535
Free PE 0
Allocated PE 9535
PV UUID OA2RNU-TZ2C-N1W0-AKCV-9UNE-CTDP-38DFQD
---physical volume---
PV NAME/DEV/SDB1
VG Name VolGroup00
PV Size 465.75 gb/not usable 1.66 MB
Allocatable Yes
PE Size (KByte) 32768
Total PE 14904
Free PE 5304
Allocated PE 9600
PV UUID Avekz2-t5ko-jsn0-pvuh-h8dj-gv0o-zqfbol
To remove a physical volume from a volume group
#vgreduce VOLGROUP00/DEV/SDB1
Delete Physical Volume
#pvremove/DEV/SDB1
This allows you to reformat the disk

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.