The opening words
Linux provides us with a lot of disk management tools. These tools allow us to view disk usage and partitions.
Report disk space usage
Here are du
some of the options for a command:
Options | description |
---|---|
-h or --human-readable |
Size of the display format for human-readable. |
-s or --summarize |
Just specify the size of the directory. |
du [OPTION]
Assessment file space usage
Here is the df
command:
Options | description |
---|---|
-h or --human-readable |
Size of the display format for human-readable. |
-i or --inodes |
Inodes display rather than a block. |
-l or --local |
Display local file information. |
-P or --portability |
To POSIX-style show, held in the same row. |
-T or --print-type |
Displays the file system type. |
df [OPTION]
Fast equipment list
We can use the lsblk
command to list the block device:
lsblk
View Subdivision
We can /proc/partitions
be all partitions output file:
cat /proc/partitions
Change or view ext {2 | 3 | 4} file system label
Display device label:
e2label device
Change the device label:
e2label device label
Pouring ext {2 | 3 | 4} file system information
Here are dumpe2fs
some of the options for a command:
Options | description |
---|---|
-h |
Show details superblock. |
dumpe2fs [OPTION] device
Adjusting ext {2 | 3 | 4} tunable filesystem
Here are tune2fs
some of the options for a command:
Options | description |
---|---|
-c # |
After adjusting the number # of each self-test loading behavior, 0 or -1 means disable function. |
-i # |
# Days after self-test loading behavior sizing adjustment. |
-j |
Adjustment disk from ext2 to ext3, reversible, but does not affect existing data. |
-l |
Show details superblock. |
-L LABEL |
Change the disk label. |
-m |
The remaining percentage is adjusted superuser. |
-o OPTION(acl 或 ^acl) |
Adjust the default mount point. |
-r |
The remaining adjustment block. |
tune2fs [OPTION] device
View / Print block device attributes
Here are blkid
some common options for a command:
Options | description |
---|---|
-i or --info |
The I / O limit (i.e. I / O topology) information. |
-k or --list-filesystems |
Display all known file systems and RAID. |
-L LABEL or --label LABEL |
Find device according to LABEL. |
-U UUID or --uuid UUID |
Find device according to UUID. |
blkid [OPTION] device
Linux file system check and repair
Here are fsck
some common options for a command:
Options | description |
---|---|
-t FSTYPE |
Specify the file system type. |
-a |
Auto repair. |
fsck [OPTION] device
Repair XFS
File System
xfs_repair
Check Linux ext {2 | 3 | 4} File System
Here are e2fsck
some common options for a command:
Options | description |
---|---|
-f |
Mandatory inspection. |
-p |
Auto repair. |
e2fsck [OPTION] device
Multi-disk partition table
Here are fdisk
some common options for a command:
Options | description |
---|---|
-l or --list |
When you create a partition here is fdisk
some of the common commands command:
Options | description |
---|---|
d |
Delete the partition. |
l |
Display type supports. |
n |
Create a partition, e: extended partition, p: primary partition, + NG (N number GB), + NM (N th MB), + NK (N number KB), + N (N number Byte). |
p |
显示磁盘分区,包括等待的。 |
q |
退出但不保存操作。 |
t |
编辑分区类型。 |
w |
保存后退出。 |
fdisk [OPTION] device
多 GUID 分区表
gdisk
多磁盘分区
这里是 parted
命令的一些常见选项:
选项 | 描述 |
---|---|
-l 或 --list |
显示所有块设备的分区布局。 |
parted [OPTION] [device]
通知系统分区表变更
partprobe
构建 Linux 文件系统
这里是 mkfs
命令的一些常见选项:
选项 | 描述 |
---|---|
-b BLOCKSIZE |
指定块大小,默认情况是 4096,可用选项有:1024、2048 或 4096。 |
-E |
用户指定的额外文件系统属性。 |
-i # |
指定每个 inode 的字节空间,默认情况是 8192,值必须是块的二次幂。 |
-L LABEL |
指定分区标签。 |
-m # |
指定超级用户的余下百分比。 |
-N # |
指定 inode 数量。 |
-t FSTYPE |
FSTYPE 可以是 ext2、ext3、ext4 或 xfs。等价于 mkfs.ext2、mkfs.ext3、mkfs.ext4、mkfs.xfs。 |
mkfs
创建 ext{2|3|4} 文件系统
这里是 mkfs
命令的一些常见选项:
选项 | 描述 |
---|---|
-b BLOCKSIZE |
指定块大小,默认情况是 4096,可用选项有:1024、2048 或 4096。 |
-i # |
指定每个 inode 的字节空间,默认情况是 8192,值必须是块的二次幂。 |
-j |
创建 ext3 文件系统。 |
-L LABEL |
指定分区标签。 |
-m # |
指定超级用户的余下百分比。 |
-N # |
指定 inode 数量。 |
-O FEATURE: |
以赋予的特性来创建。 |
-t FSTYPE |
FSTYPE 可以是 ext2、ext3、ext4。 |
mke2fs
挂在文件系统
这里是 mount
命令的一些常见选项:
选项 | 描述 |
---|---|
-a |
挂载在 /etc/fstab 文件中定义的所有文件系统。 |
-n |
停止追加设备详情至 /etc/mtab 文件。 |
-o |
指定额外挂载选项,也就是文件系统启用的属性,多个选项以逗号隔开。 |
-r |
只读挂载,通常用于光碟(CD)。 |
-t FSTYPE |
指定设备文件系统类型,默认情况挂载将调用 blkid 以识别类型。 |
-w |
读写挂载。 |
默认显示所有挂载的设备,默认追加挂载的设备详情至 /etc/mtab
文件:
mount [device] [mountpoint]
卸载文件系统
这里是 umount
命令的一些常见选项:
选项 | 描述 |
---|---|
-n 或 --no-mtab |
卸载而不写入 /etc/mtab 文件中。 |
umount [OPTION] [device]
检查挂在的设备
cat /proc/mounts
# 或
cat /etc/mtab
检查使用文件或套接字的进程
这里是 fuser
命令的一些常见选项:
选项 | 描述 |
---|---|
-k |
终止所有使用指定文件或目录的进程。 |
-m |
列出所有使用指定挂载点的进程。 |
-km |
终止所有使用指定挂载点的进程。 |
-v |
查看进程。 |
fuser [OPTION]
列出打开的文件
lsof
创建交换区
这里是 mkswap
命令的一些常见选项:
选项 | 描述 |
---|---|
-c 或 --check |
检查快设备以找到坏块后再创建交换区。 |
-L 或 --label |
为设备指定标签。 |
-U 或 --uuid |
指定使用的 UUID。默认行为是生成 UUID。 |
mkswap [OPTION] device [SIZE]
启用或禁用分页及交换设备与文件
这里是 swapon
命令的一些常见选项:
选项 | 描述 |
---|---|
-a 或 --all |
在 /etc/fstab 文件中定义的所有交换设备。 |
-L 或 --label |
分区标签。 |
-s 或 --summary |
显示交换使用率概述,与 cat /proc/swap 等价。 |
swapon [OPTION] [file]
swapoff [-a]
文件系统静态信息
这里是 /etc/fstab
文件的字段定义:
字段 | 描述 |
---|---|
第一个 | 设备名、标签、UUID、伪文件系统(proc、tmpfs、sysfs)。 |
第二个 | 挂载点、交换是交换设备挂载点。 |
第三个 | 文件系统类型。 |
第四个 | 挂载点选项,默认情况是指默认选项,多个选项(default、noauto、user、owner、nofail) |
第五个 | 倾倒频率,0(无备份)、1(日备)、2(隔日备)。 |
第六个 | 检查文件系统,0(无自检测)、1(先自测)、2(次自测)。 |
使块或字符成为特殊文件
这里是 mknod
命令的一些常见选项:
选项 | 描述 |
---|---|
-m MODE 或 --mode=MODE |
这里是 mknod
命令的一些类型:
类型 | 描述 |
---|---|
b |
块(缓冲)特殊文件,必须指定 MAJOR 及 MINOR。 |
c 、u |
字符(未缓冲)特殊文件,必须指定 MAJOR 及 MINOR。 |
p |
必须省略 FIFO、MAJOR 及 MINOR。 |
mknod [OPTION] TYPE [MAJOR MINOR]
拷贝文件
dd if=data_source of=target bs=block_size count=block_amount
备份磁盘主引导记录(MBR)
dd if=/dev/sda of=/mnt/usb/mbr.backup bs=512 count1
恢复磁盘主引导分区(MBR)
dd if=/mnt/usb/mbr.backup of=/dev/sda bs=512 count=1
创建虚拟光盘
cat /dev/cdrom > /root/compact_disc.iso
性能糟糕的交换空间
free -m
dd if=/dev/zero of=/var/swapfile bs=1M count=2014
mkswap /var/swapfile
free -m
以十六进制、十进制、八进制或 ASCII 形式显示文件内容
这里是 mknod
命令的一些常见选项:
选项 | 描述 |
---|---|
-b 或 --one-byte-octal |
单字节八进制显示。 |
-c 或 --one-byte-char |
单字节字符显示。 |
-C 或 --canonical |
典型的十六进制加 ASCII 显示。 |
-d 或 --two-bytes-decimal |
两字节十进制显示。 |
-x 或 --two-bytes-hex |
两字节十六进制显示。 |
hexdump [OPTION] file
我所撰写的英文版本
引用
- DF(1)
- DU(1)
- LSBLK(8)
- E2LABEL(8)
- DUMPE2FS(8)
- TUNE2FS(8)
- BLKID(8)
- FSCK(8)
- xfs_repair(8)
- E2FSCK(8)
- FDISK(8)
- GDISK
- PARTED(8)
- PARTPROBE(8)
- MKFS(8)
- MKE2FS(8)
- MOUNT(8)
- UMOUNT(8)
- FUSER(1)
- LSOF(8)
- MKSWAP(8)
- SWAPON(8)
- FSTAB(5)
- MKNOD(1)
- DD(1)
- HEXDUMP(1)
参见
上一篇:
想看手册的其他内容?请访问该手册的所属专栏:《Linux 管理员手册:既简单又深刻》