Equipment Management Under Linux

First, the device overview

1.1 Equipment Identity

Devices are in the form of a file after the access system
Here Insert Picture Description

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
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

Second, the device mounts

The system has a device id device that can be used by system
Here Insert Picture Descriptionconversion parameters from the read-only mount into a read-write
Here Insert Picture Descriptionunloading equipment will display the target when the device is busy occupying
Here Insert Picture DescriptionHere Insert Picture DescriptionNote: 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
Here Insert Picture Description
can be mountused to view the file system commands type
Here Insert Picture Description
Here Insert Picture Descriptioncommand mount -a again read the contents of / etc / fstab in
Here Insert Picture Descriptionwill 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

findCommand 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

Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

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

Here Insert Picture DescriptionHere Insert Picture Descriptionfdisk /dev/sdaCommon command parameters are as follows
Here Insert Picture Description

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

Here Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture DescriptionWhen 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   ##重新加载分区表

Here Insert Picture Description
Add partition or partitions of the
Here Insert Picture DescriptionHere Insert Picture Description
MBR partition can be divided into only three primary partition and an extended partition
Here Insert Picture Description

Conversion 4.3 MBR partitioning into a GPT mode

Delete all of the above-mentioned manner MBR partition divided
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

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分区

新建一个分区
Here Insert Picture Description更改分区类型
Here Insert Picture DescriptionHere Insert Picture Description同步分区表
Here Insert Picture Description格式胡以及激活分区
Here Insert Picture Description在激活分区时指定优先级,优先级的范围为0-32767,数字越大优先级越高
Here Insert Picture Description

5.4 永久创建swap分区

需要更改/etc/fstab中的内容
Here Insert Picture Description再次激活分区并查看分区
Here Insert Picture Description

5.5 删除swap分区

Here Insert Picture DescriptionHere Insert Picture Description

六、磁盘配额

6.1 磁盘配额的作用

指定用户能够写入指定设备的最大额度

6.2 磁盘配额的临时设定方法

新建一个分区
Here Insert Picture Description格式化新加的分区
Here Insert Picture Description设定指定用户wang的配额参数为20M
Here Insert Picture DescriptionHere Insert Picture Description上图中各部分内容的含义

Filesystem 设备名称
blocks 用户已经创建的数据
soft 软限
hard 硬限
inodes 用户已经创建的文件个数
soft 软限
hard 硬限

Here Insert Picture Description

6.2 磁盘配额的永久设定方法

编辑文件/etc/fstab
Here Insert Picture Description
Here Insert Picture Description

6.3 关闭磁盘配额

编辑文件/etc/fstab,将写入的配额参数去掉
Here Insert Picture Description关闭配额并进行测试
Here Insert Picture Description

七、逻辑卷(LVM)

一些需要了解的名词

名词 解释
pv(物理卷) 被处理过的物理分区
pe(物理扩展) 设定的存储最小单元,LVM是由整数个pe组成的
vg(物理卷组) 捆绑pv到一个组中
lv(逻辑卷) 分配最终的使用设备
7.1 lvm设备建立

建立物理分区并设定分区类型为lvm
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description对物理卷,物理卷组,逻辑卷以及挂载点/qqdata进行监控
Here Insert Picture Description创建pv,vg并设定pe大小为2M,即设定好以后的lvm大小是2的整数倍
Here Insert Picture Descriptionlvcreate -L 100M -n wanglv wangvg语句中-L 指定lvm大小,-n指定名称
Here Insert Picture Description在监控界面看到的情况
Here Insert Picture Description

7.2 当vg中容量充足时lvm设备的拉伸

Stretching the device
Here Insert Picture DescriptionHere Insert Picture Descriptionfile system is stretched. May use the device or the mount point rhel7 stretching in the file system can only add mount point rhel8
Here Insert Picture DescriptionHere Insert Picture Description

7.3 When the stretching device lvm insufficient capacity in vg

Plus a new type of partition lvm
Here Insert Picture DescriptionHere Insert Picture Descriptionmonitoring interface to see the results of tensile
Here Insert Picture DescriptionNote: 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

Here Insert Picture DescriptionReduce the size of the
Here Insert Picture Descriptionfile device but the device has not been reduced down
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

Delete 7.4 lvm equipment

Here Insert Picture DescriptionHere Insert Picture DescriptionDeletion step:
1, umount /qqdata/unloading apparatus
2, lvremove /dev/wangvg/wanglvis removed LV
. 3, vgremove wangvgremove the VG
. 4, pvremove /dev/sda2remove the PV
. 5, the partition is removed

Published 28 original articles · won praise 0 · Views 765

Guess you like

Origin blog.csdn.net/weixin_43834060/article/details/104554901