13. Basic management of storage
1. View of equipment:
fdisk -l 查看磁盘分区情况
lsblk 设备使用情况
blkid 设备管理方式与设备id
df (-h/H) 查看系统中正在挂载的设备
cat /proc/partitions 查看系统中的识别设备
2. Mount the device:
Temporary mount:
mount -------- means to view the mounting situation of the device
mount -o ro ---------read-only mount
mount -o+mount parameter+device
mount -a - ------- means reload the /etc/fstab file immediately
umount + device name or mount directory ---------------- unmount
fuser -kvm device or mount directory ----------- can also mean unmount, " k --Technical progress" "v-show detailed information" "m-show progress"
Permanently mount:
vim /etc/fstab 设备挂载策略文件
3. Search for files in the device:
find command:
find 查找路径 参数
-name 文件名字
-user 文件所有者
-group 文件所有组
-type f d s b l 文件类型
-perm 444(精确查找) /444(或者关系) -444(并且至少关系) 文件权限
-not 条件反选
-maxdepth 查找最大层级
-mindepth 查找最小层级
-cmin 1(1分钟) -1(少于一分钟的文件) +1(多于) 文件最后一次更改时间
-size +100M -100M =100M 文件大小
-a 两个参数表并且关系 默认省略
-o 表示或者关系,两个参数满足一个即可
-exec 执行后面接的命令内容;如: find /mnt -perm -002 -exec chmod o-w {
} \;
The {} in 1028 represents the search result of the find command, and \ is the transfer character;
4. Partition:
4-1: Partition method:
位数 分区表大小 支持分区个数 支持单个分区大小
legacy (MBR)32 64byte 主分区4个;所有分区16个 2.2TB
UEFI (GRT) 64 128byte 理论上无限制,windows上 128 8ZB
MBR partition method:
primary partition —> extended partition —> logical partition
fdisk /dev/sdb Enter the corresponding partition (create a new partition)
Command (m for help): m Get help:
create a new partition: remember to wq to exit and save;
Parted creates partitions non-interactively:
parted /dev/device mklabel msdos
parted /dev/device mkpart primary 1 100
parted rm 2
Synchronize the partition table: udevadm settle; partprobe
Format the device as ** file system: mkfs.xfs (file type) -K /dev/sdb1 (device name)
Initialize the device (delete): dd if=/dev/zero of=/dev/device bs=1M count=1
When the device is busy during uninstallation:
fuser -kvm device or mount point "-k ends the process, -v shows the detailed information -m displays the process"
5.Swap partition:
Function: When the program is running, all data is in RAM. When the RAM usage exceeds the limit, in order to make the system more stable, we divide a part of the space on the hard disk as the memory buffer swap. When the memory usage exceeds the limit, the kernel will save the memory. The idle data is stored in the swap. When the program needs the data in the swap partition, the kernel will return the data in the swap partition to the memory process for processing.
Create swap partition:
activate and close swap partition: don’t forget to format the swap format of the device: mkswap /device
6. Disk quota:
Function: Set the maximum amount that the user can write to the specified device;