In general, the server will have multiple hard disks, one hard disk partition to install the operating system, and a number of hard disk partitions for storage use. Now test the addition of multiple hard disk partitions, using LVM for dynamic disk allocation.
1. New Drive View
Fdisk-l
You can see the new two-block HDD SDB and SDC
2. Partitioning the hard drive
fdisk /dev/sdb============ parameter Description: a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition #删除分区 g create a new empty GPT partition table #创建新的空GPT分区表 G create an IRIX (SGI) partition table #创新新的IRIX分区表 l list known partition types #列出已知的分区类型 m print this menu #打印帮助 n add a new partition # Add New Partition o create a new empty dos partition table #创建New empty DOS Partition table p print the partition table #打印分区表 q quit without saving changes #不保存退出 s create a new empty sun disklabel t change a partition ' s system id #更改分区系统id u change display/entry units v verify the partition table #检查分区表 w write table to disk and exit #保存退出 x extra functionality (experts only) #额外功能
Input: n indicates new partition
Input: N
Means to create a new partition
Input: P
Represents creating a basic partition (P is the base partition and E is an extended partition)
Select the partition number, 1~4, use 1 by default, press ENTER directly.
Select the starting point of the partition, using the default, press ENTER directly.
Select the end of the partition, use the default, and press ENTER directly.
Partition complete.
In the same way, the SDC hard drive is partitioned
3. Change the partition number
We need to change the partition type to a Linux LVM volume to create LVM.
Input: T
Enter T to change the partition number
Input: L
Uppercase L means view all numbers
Fdiks/dev/sdb
Choose 8e here
Input 8e
4. Save exit
Input W, and similarly to SDC partitioning
5.LVM Basic Concepts
Basic Logical Volume Management concepts:
PV (physical Volume)-Physical volume
The physical volume is at the very bottom of the logical volume management, which can be a partition on the actual physical hard disk, or it can be an entire physical hard disk or a raid device .
VG (Volumne Group)-volume group
A volume group is built on a physical volume, and a volume group must include at least one physical volume, which can be dynamically added to the volume group after the volume group is established. A logical volume management system can have only one volume group, or multiple volume groups.
LV (Logical Volume)-Logical Volume
The logical volume is built on top of the volume group, and unallocated space in the volume group can be used to create new logical volumes that can be dynamically scaled and scaled down after the logical volume is established. Multiple logical volumes in a system can belong to the same volume group or to a different number of volume groups
PE (physical Extent)-Physical block
LVM uses a 4MB PE block by default, while the LV of LVM can contain up to 65,534 PE (LVM1 format), so the default LVM's LV maximum capacity is 4m*65534/(1024m/g) =256g. PE is the smallest storage block of the entire LVM, that is to say, our data are processed by writing to PE. To put it simply, this PE is a bit like the block size of the file system. So adjusting PE will affect the maximum capacity of LVM! However, after the CentOS 6.x, because of the direct use of LVM2 's various formatting features, so this limit no longer exists.
6. Create PV
PVCREATE/DEV/SDB1 #以分区创建逻辑卷pvcreate/DEV/SDC1
7. Create VG
Input: Vgcreate vg_group/dev/xvdb1
The vg_group here is the name of the VG group and can be customized
Vgcreate VG_GROPU/DEV/SDB1/DEV/SDC1 #=. = The word is wrong, do not care about these details
8. View VG
Vgdisplay vg_group-v
9. Create the LV
Lvcreate-l 59g-n vg_1 vg_gropu #vg可用空间为59.9g========-l back is the size to be assigned to the LV-n new one name for the vg_1 of the LV used VG is Vg_gropu
View status when you are finished creating
Lvdisplay vg_gropu-v
You can see that the LV has been created
10. Formatting the LV
To view the file type of the system
Df-th
You can see that the system partition is in XFS format.
We can format the LV in EXT4 format.
Formatting LV
Mkfs.ext4/dev/vg_gropu/vg_1
Edit the/etc/fstab file to create a disk boot auto mount
Vim/etc/fstab
This time to mount the vg_1 under/usr/local
Add a row at the end of the file
First column: Disk to be mounted
Second column: mount point
Third column: File type
Fourth column: Mount option, refer to man mount for details. Some common options are listed below:
Auto: The system mounts automatically, Fstab is this option by default
Ro:read-only
Rw:read-write
DEFAULTS:RW, suid, Dev, exec, auto, Nouser, and async.
Fifth column: For the dump option, set whether to let the Backup program dump backup file system, 0 is ignored, 1 is backup.
Sixth column: For the fsck option, tell the FSCK program in what order to check the file system, 0 is ignored
Note: Don't write it wrong! Otherwise, the partition table is corrupted
12. Re-mount
Mount-a
To see if the mount was successful
Df-h
You can see the Mount success
Linux learning-Adding multiple hard disks and LVM configurations