Disk management in Linux, LVM logical volume

Disk management 1. Disk classification: mechanical keyboard, solid state note. Two features:
* High availability (not easy to break)
* High IO performance (fast speed)

2. Structure
* Hardware structure: disc, magnetic head (magnetic levitation without contact)
* Data structure:

1. 扇区:每扇区存放512字节
2. 磁道:不同半径同心圆
3. 柱面:相同半径圆柱面

3. Disk interface
*
IDE (parallel port): /dev/hd*
*
STAT (serial port): /dev/sd*
*
SCIC: vda1

4. MBR of the first sector of the hard disk (Master Boot Record)
*
Master boot program: 446 bytes
*
Hard disk partition table: 4 16-byte recording areas, 2 bytes checksum
*
446+4*16 +2=512

5. Check whether the software is installed and the information about the uninstalled software is displayed
yum provides */mkfs.xfs (the red part can be replaced)
6. The specific operation of fdisk hard disk partition (5G)
1.
Shut down and add the hard disk, turn on the hard disk, and reconnect the shell
2.
fdisk- l: view partition information
3.
fdisk: enter the partition interactive command interface
4.
n: create a new partition d: delete a partition p: view partition w: save and exit q: exit without saving
5.
n: create a new partition, p: select master Partition, 1: start position, +1G: select partition size, p: view partition
6.
n: create new partition, p: select primary partition, press Enter to automatically select start position +1G: select partition size, p: view partition size
7.
n: New partition, e: Select as extended partition, press Enter to automatically select start and end position (select all), p: View partition
8.
n: New partition, l: Select as logical partition, press Enter to automatically select start position , +1G: select the partition size, p: view the partition size
9.
n: create a new partition, l: select a logical partition, press enter to automatically select the start position, press enter to automatically select the start and end position, p: view the partition size
10.
w : Save and exit

7. Parted hard disk partition operation (5G)
1.
mklable gpt/msdos: select partition type
2.
mkpart 1 1G p: create a new partition, size 1G and view
3.
mkpart 1G 2G p: create a new partition, size 1G and view
4.
mkpart 2G -1 p: Create a new partition, the size is all the way to the end and view
5.
This partition method has no distinction between primary partition and extended partition

8. blkid /dev/sdb1: view the uuid number of the device
9. Automatic mount settings (/etc/fstab)
mkdir /aaa
mount /dev/sdb2 /aaa
vim /etc/fstab
/dev/sdb2 /aaa xfs default 0 0
/ dev/sdb1 swap swap default 0 0

Insert picture description here
Rescue measures for boot failure after accidental deletion
fdisk /dev/sdb
d
2
wq
shutdown and boot, re-enter the password
vim /etc/fstab
#/dev/sdb2 /aaa xfs default 0 0
wq
reboot

LVM logical volume part

Insert picture description here

1. LVM overview:
*
LVM (logical volume manager): logical volume management
*
Role: dynamically adjust disk capacity to increase flexibility (mostly used for capacity expansion)
*
/boot: partition to store boot files, cannot be created based on LVM

2. Basic concepts:
*
PV (physical volume) physical volume:

       整个硬盘或fdisk创建的分区,包括许多4M的PE(physical extent基本单元/物理单元)
* 

VG (volume group) volume group

Insert picture description here

3. Specific operations after adding the hard disk
Insert picture description here

Note: The uppercase is the name of the custom file

5. Extended logical volume operation
*
lvextand -L +5G /dev/vg0/lv0 (write how much space is added)
*
lvextand -L 30G /dev/vg0/lv0 (write how much space is added after adding)
*
lvextand -l + 1278 /dev/vg0/lv0 (Add the remaining 1278 4M PEs, which is more accurate)

Refresh view method:
*
resize2fs /dev/vg0/lv0 (ex4 format)
*
xfs_growfs /dev/vg0/lv0 (xfs format)
*
df-hT: view mounting information

6. At present, the added disk space is not enough to use and then add the disk when operating
pvcreate /dev/sdd
vgextend vg0 /dev/sdd and
then expand the logical volume

7.inode node

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_39109226/article/details/109303149