First, the device overview
1.1 Equipment Identity
Devices are in the form of a file after the access system
1.2 Device Name
SATA / SAS / USB | /dev/sda, /dev/sdb | s = SATA, d = disk, a, b represents the first few |
---|---|---|
HERE | /dev/hd0, /dev/hd1 | h=hard |
VIRTIO-BLOCK | /dev/vda, /dev/vdb | v=virtio |
M2(SSD) | /dev/nvme0, /dev/nvme2 | nvme representative Machine |
SD / MMC / EMMC (card) | /dev/mmcblk0, /dev/mmcblk1 | mmc representative Machine |
CD-ROM | /dev/cdrom, /dev/sr0, /dev/sr1 |
1.3 Device View
command | content |
---|---|
fdisk -l | View disk partition (in the case of real systems) |
lsblk | View device usage |
blkid | View device usage and device id (id not find the device can not be mounted) |
df | View equipment is being mounted system |
cat /proc/partitions | View system identification device |
Add a new SATA hard disk in the system
Second, the device mounts
The system has a device id device that can be used by system
conversion parameters from the read-only mount into a read-write
unloading equipment will display the target when the device is busy occupying
Note: The above are temporary mount equipment , you want to permanent mount devices need to edit the device to mount the policy file / etc / fstab
file format of the content to
the device mount point to mount the file system type parameter is detected whether the backup
can be mount
used to view the file system commands type
command mount -a again read the contents of / etc / fstab in
will cause the system fails to restart, you need to follow the prompts to enter the root password in the user interface, comment out the line error, reboot the system when editing equipment policy file error
Third, find a device file
find
Command can be used to find the file device
common parameters are shown in Table
-name | file name |
---|---|
-user | File owner |
-group | File has set |
-type | file type |
-perm | file permission |
-exec | Excuting an order |
-maxdepth | Find the deepest |
-mindepth | Find the most superficial |
-The | or |
-a | and |
-not | Invert Selection |
Fourth, the device partition
Partition the device can more easily manage disk and recover data
partitioning:
Types of | Digit | Partition table size | The number of partitions support | A single partition size |
---|---|---|---|---|
Traditional partitioning (MBR) | 32 | 64 | 4 primary partition, all partitions 16 | 2.2TB |
UEFI(GPT) | 64 | 128 | Without limiting the theory, win the next 128 | 8ZB |
4.1 MBR partitioning
Primary partition | Recording information of the master partition table partitions can be used directly |
---|---|
Extended partition | Master partition table recording partition, not directly, but logical partitions container |
Logical partitions | Extended partitions on partitioning |
When no extended partition, logical partition will not present, occupies the entire hard disk is preferably divided at the extended partition
4.2 MBR partitioning method
fdisk /dev/sda
Common command parameters are as follows
parameter | content |
---|---|
m | help |
d | Delete partition |
l | List all partitions |
n | New Partition |
p | Display Partition |
t | Change the partition type |
w | Save Selection |
q | drop out |
When the device is busy or if other circumstances lead to added after the file has not been generated newly added partition, you need to execute the following command:
partprobe ##同步分区表
Or the command:
partx -d /dev/sda ##清理分区表
partx -a /dev/sda ##重新加载分区表
Add partition or partitions of the
MBR partition can be divided into only three primary partition and an extended partition
Conversion 4.3 MBR partitioning into a GPT mode
Delete all of the above-mentioned manner MBR partition divided
Five, swap partition
Role 5.1 swap partition
All program data is in memory, when memory usage exceeds the limit, the system will not operate properly at runtime. To make the system more stable, as a part of the space division of a memory buffer on the hard drive - if the memory usage exceeds the limit, the kernel will idle memory data stored in the swap, when the program needs the data in the swap area, then the kernel the data swap partition back to the process of memory processing.
5.2 swap partition size recommendations
memory size | recommended swap partition size | When turn HIBERNATE swap partition size recommendations |
---|---|---|
The following 2GiB | Twice as much physical memory | Three times the physical memory |
2-8GiB | 等于物理内存 | 物理内存两倍 |
8-64GiB | 至少4GiB | 物理内存的1.5倍 |
64GiB以上 | 至少4GiB | HIBERNATE不开启 |
5.3 临时创建swap分区
新建一个分区
更改分区类型
同步分区表
格式胡以及激活分区
在激活分区时指定优先级,优先级的范围为0-32767,数字越大优先级越高
5.4 永久创建swap分区
需要更改/etc/fstab中的内容
再次激活分区并查看分区
5.5 删除swap分区
六、磁盘配额
6.1 磁盘配额的作用
指定用户能够写入指定设备的最大额度
6.2 磁盘配额的临时设定方法
新建一个分区
格式化新加的分区
设定指定用户wang的配额参数为20M
上图中各部分内容的含义
Filesystem | 设备名称 |
---|---|
blocks | 用户已经创建的数据 |
soft | 软限 |
hard | 硬限 |
inodes | 用户已经创建的文件个数 |
soft | 软限 |
hard | 硬限 |
6.2 磁盘配额的永久设定方法
编辑文件/etc/fstab
6.3 关闭磁盘配额
编辑文件/etc/fstab,将写入的配额参数去掉
关闭配额并进行测试
七、逻辑卷(LVM)
一些需要了解的名词
名词 | 解释 |
---|---|
pv(物理卷) | 被处理过的物理分区 |
pe(物理扩展) | 设定的存储最小单元,LVM是由整数个pe组成的 |
vg(物理卷组) | 捆绑pv到一个组中 |
lv(逻辑卷) | 分配最终的使用设备 |
7.1 lvm设备建立
建立物理分区并设定分区类型为lvm
对物理卷,物理卷组,逻辑卷以及挂载点/qqdata进行监控
创建pv,vg并设定pe大小为2M,即设定好以后的lvm大小是2的整数倍
lvcreate -L 100M -n wanglv wangvg
语句中-L 指定lvm大小,-n指定名称
在监控界面看到的情况
7.2 当vg中容量充足时lvm设备的拉伸
Stretching the device
file system is stretched. May use the device or the mount point rhel7 stretching in the file system can only add mount point rhel8
7.3 When the stretching device lvm insufficient capacity in vg
Plus a new type of partition lvm
monitoring interface to see the results of tensile
Note: xfs file system does not support the reduction can only be stretched, if the beginning of the design may need to be considered to reduce the need to use ext file format
using a command to change the file system
mkfs.ext4 /dev/wangvg/wanglv
Reduce the size of the
file device but the device has not been reduced down
Delete 7.4 lvm equipment
Deletion step:
1, umount /qqdata/
unloading apparatus
2, lvremove /dev/wangvg/wanglv
is removed LV
. 3, vgremove wangvg
remove the VG
. 4, pvremove /dev/sda2
remove the PV
. 5, the partition is removed