Linux-磁盘管理
参考文献
常见的档案系统
- 传统档案系统:
ext2/minix/MS-DOS/FAT(用vfat模块)
- 日志是档案系统:
ext3/ReiserFS/Windos' NTFS/IBM's JFS/SGI's XFS
- 网络档案系统:
NFS/SMBFS
档案系统的简单操作
- 磁盘与目录的容量:
df, du
- 连结档的介绍:
ln
磁盘的分割、格式化、检验与挂载
- 磁盘分割:
fdisk
- 磁盘格式化:
mke2fs, mkbootdisk, fdformat
- 磁盘检验:
fsck, badblocks, sync
- 磁盘挂载与卸载:
mount, umount
- 磁盘参数修订:
mknod, e2label, tune2fs, hdparm
df
-
磁盘空间查看工具,用于显示文件系统磁盘空间的使用情况
-
命令说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40# df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.
Mandatory arguments to long options are mandatory for short options too.
-a, --all include pseudo, duplicate, inaccessible file systems
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'-BM' prints sizes in units of 1,048,576 bytes;
see SIZE format below
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
-H, --si print sizes in powers of 1000 (e.g., 1.1G)
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (default)
--output[=FIELD_LIST] use the output format defined by FIELD_LIST,
or print all fields if FIELD_LIST is omitted.
-P, --portability use the POSIX output format
--sync invoke sync before getting usage info
--total elide all entries insignificant to available space,
and produce a grand total
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
-x, --exclude-type=TYPE limit listing to file systems not of type TYPE
-v (ignored)
--help display this help and exit
--version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).
FIELD_LIST is a comma-separated list of columns to be included. Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).-a
或--all
: 显示所有的文件系统,包括系统保留的文件系统.-h
或--human-readable
: 以易读的方式显示文件系统容量,例如使用 KB、MB、GB 等单位.-H
或--si
: 与-h
相同,但是使用十进制单位,例如 1000B 代表 1KB.-i
或--inodes
: 显示 inode 的使用情况而不是磁盘空间的使用情况.-k
或--block-size
: 指定块的大小,例如-k 1024
表示使用 1KB 的块.-l
或--local
: 仅显示本地文件系统.-P
或--portability
: 使用 POSIX 输出格式,以便于在不同系统之间进行移植.-t
或--type
: 仅显示指定类型的文件系统,例如-t ext4
仅显示 ext4 文件系统.-T
或--print-type
: 显示每个文件系统的类型.-x
或--exclude-type
: 排除指定类型的文件系统,例如-x tmpfs
排除 tmpfs 文件系统.--sync
: 在输出文件系统信息之前强制同步文件系统.
fdisk
-
磁盘分区工具,用于创建、删除、调整磁盘分区等操作
-
命令说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37holelin@minio-102:~$ fdisk --help
Usage:
fdisk [options] <disk> change partition table
fdisk [options] -l [<disk>] list partition table(s)
Display or manipulate a disk partition table.
Options:
-b, --sector-size <size> physical and logical sector size
-B, --protect-boot don't erase bootbits when creating a new label
-c, --compatibility[=<mode>] mode is 'dos' or 'nondos' (default)
-L, --color[=<when>] colorize output (auto, always or never)
colors are enabled by default
-l, --list display partitions and exit
-o, --output <list> output columns
-t, --type <type> recognize specified partition table type only
-u, --units[=<unit>] display units: 'cylinders' or 'sectors' (default)
-s, --getsz display device size in 512-byte sectors [DEPRECATED]
--bytes print SIZE in bytes rather than in human readable format
-w, --wipe <mode> wipe signatures (auto, always or never)
-W, --wipe-partitions <mode> wipe signatures from new partitions (auto, always or never)
-C, --cylinders <number> specify the number of cylinders
-H, --heads <number> specify the number of heads
-S, --sectors <number> specify the number of sectors per track
-h, --help display this help
-V, --version display version
Available output columns:
gpt: Device Start End Sectors Size Type Type-UUID Attrs Name UUID
dos: Device Start End Sectors Cylinders Size Type Id Attrs Boot End-C/H/S Start-C/H/S
bsd: Slice Start End Sectors Cylinders Size Type Bsize Cpg Fsize
sgi: Device Start End Sectors Cylinders Size Type Id Attrs
sun: Device Start End Sectors Cylinders Size Type Id Flags-b
: 指定扇区大小,例如-b 512
.-c
: 关闭 DOS 兼容模式.-l
: 列出所有磁盘分区的信息.-u
: 指定单位为扇区.-v
: 显示版本信息.-x
: 显示额外的信息.-s
: 显示磁盘分区的大小(以扇区为单位).-t
: 指定分区类型,例如-t 83
表示 Linux 文件系统
mkfs(make filesystem)
-t
:指定要创建的文件系统类型,例如-t ext4
表示创建 ext4 文件系统.-c
:在创建文件系统时检查磁盘坏道.-i
:指定 inode 大小,例如-i 2048
.-I
:指定 inode 大小为默认大小.-L
:给文件系统添加标签,例如-L myfs
.-n
:显示将要执行的操作,但不实际执行.-v
:显示详细的信息.-V
:显示版本信息.
lsblk
-
lsblk命令 用于列出所有可用块设备的信息,而且还能显示他们之间的依赖关系,但是它不会列出RAM盘的信息.块设备有硬盘,闪存盘,CD-ROM等等.lsblk命令包含在
util-linux-ng
包中,现在该包改名为util-linux
.这个包带了几个其它工具,如dmesg
.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32Usage:
lsblk [options] [<device> ...]
List information about block devices.
Options:
-a, --all print all devices # 显示所有设备
-b, --bytes print SIZE in bytes rather than in human readable format # 以bytes方式显示设备大小
-d, --nodeps don't print slaves or holders # 不显示 slaves 或 holders
-D, --discard print discard capabilities
-z, --zoned print zone model
-e, --exclude <list> exclude devices by major number (default: RAM disks) # 排除设备 (default: RAM disks)
-f, --fs output info about filesystems # 显示文件系统信息
-i, --ascii use ascii characters only
-I, --include <list> show only devices with specified major numbers
-J, --json use JSON output format
-l, --list use list format output # 使用列表格式显示
-T, --tree use tree format output
-m, --perms output info about permissions # 显示权限信息
-n, --noheadings don't print headings # 不显示标题
-o, --output <list> output columns
-O, --output-all output all columns
-p, --paths print complete device path
-P, --pairs use key="value" output format
-r, --raw use raw output format # 使用原始格式显示
-s, --inverse inverse dependencies
-S, --scsi output info about SCSI devices
-t, --topology output info about topology
-x, --sort <column> sort output by <column>
-h, --help display this help
-V, --version display version1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46Available output columns:
NAME device name
KNAME internal kernel device name
MAJ:MIN major:minor device number
FSTYPE filesystem type
MOUNTPOINT where the device is mounted
LABEL filesystem LABEL
UUID filesystem UUID
PARTTYPE partition type UUID
PARTLABEL partition LABEL
PARTUUID partition UUID
PARTFLAGS partition flags
RA read-ahead of the device
RO read-only device
RM removable device
HOTPLUG removable or hotplug device (usb, pcmcia, ...)
MODEL device identifier
SERIAL disk serial number
SIZE size of the device
STATE state of the device
OWNER user name
GROUP group name
MODE device node permissions
ALIGNMENT alignment offset
MIN-IO minimum I/O size
OPT-IO optimal I/O size
PHY-SEC physical sector size
LOG-SEC logical sector size
ROTA rotational device
SCHED I/O scheduler name
RQ-SIZE request queue size
TYPE device type
DISC-ALN discard alignment offset
DISC-GRAN discard granularity
DISC-MAX discard max bytes
DISC-ZERO discard zeroes data
WSAME write same max bytes
WWN unique storage identifier
RAND adds randomness
PKNAME internal parent kernel device name
HCTL Host:Channel:Target:Lun for SCSI
TRAN device transport type
SUBSYSTEMS de-duplicated chain of subsystems
REV device revision
VENDOR device vendor
ZONED zone model
示例
1 | # lsblk |
- NAME :这是块设备名.
- MAJ:MIN :本栏显示主要和次要设备号.
- RM :本栏显示设备是否可移动设备.
- SIZE :本栏列出设备的容量大小信息.
- RO :该项表明设备是否为只读.
- TYPE :本栏显示块设备是否是磁盘或磁盘上的一个分区.
- MOUNTPOINT :本栏指出设备挂载的挂载点.
mke2fs
- 当没有指定的时候,
mke2fs
使用ext2
为格式化档案格式,若加入–j
时,则格式化为ext3
这个Journaling
的filesystem
1 | # mke2fs [-bicLj] 装置名称 |
hdparm
1 | # 查看硬盘信息 |
fsck
1 | # fsck [-AtCary] 装置名称 |
mount
1 | # mount [-tonL] 装置名称代号 挂载点 |
-
⽀持UTF-8
1
mount -o iocharset=utf8 /dev/sda5 /mnt/usb
-
禁⽌⽂件与⽬录的访问时间
1
mount -o noatime,nodiratime /dev/drbd0 /mnt
磁盘分区
-
使用
df -h
以及sudo fdisk -l
查看磁盘详情1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65root@minio-102:/home/holelin# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 391M 1.6M 389M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 19G 6.3G 12G 36% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/loop0 92M 92M 0 100% /snap/lxd/24061
/dev/sda2 2.0G 108M 1.7G 6% /boot
/dev/loop1 50M 50M 0 100% /snap/snapd/18357
/dev/loop2 64M 64M 0 100% /snap/core20/1828
tmpfs 391M 0 391M 0% /run/user/1000
root@minio-102:/home/holelin# fdisk -l
Disk /dev/loop0: 91.85 MiB, 96292864 bytes, 188072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 49.86 MiB, 52260864 bytes, 102072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 63.29 MiB, 66359296 bytes, 129608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 20DCA599-D2CA-416E-89E5-02C0BB3FD69E
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 4198399 4194304 2G Linux filesystem
/dev/sda3 4198400 83884031 79685632 38G Linux filesystem
# 此处的/dev/sdb
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# 此处的/dev/sdc
Disk /dev/sdc: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 18.102 GiB, 20396900352 bytes, 39837696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes- 上面的
/dev/sdb
以及/dev/sdc
为需要分区的磁盘
- 上面的
-
切换到
root
权限,执行fdisk /dev/sdb
- 使用
m
命令来进行提示 - 使用先
n
命令再执行p
命令来创建分区,此处只创建一个分区,则全部使用默认 - 使用
w
命令来保存
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84root@minio-102:/home/holelin# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf894433b.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf894433b
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759):
Created a new partition 1 of type 'Linux' and of size 5 GiB.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf894433b
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 10485759 10483712 5G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks. - 使用
-
/dev/sdc
执行上述同样操作 -
都执行完成后,重启服务器
1
reboot now
-
重启完成后,格式化磁盘
1
2
3# 将磁盘格式化为ext4格式
mkfs.ext4 /dev/sdb
mkfs.ext4 /dev/sdc1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27root@minio-102:/home/holelin# mkfs.ext4 /dev/sdb
mke2fs 1.45.5 (07-Jan-2020)
Found a dos partition table in /dev/sdb
Proceed anyway? (y,N) y
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 0a13e2ca-b99f-42e5-a593-1d91a40b0a0b
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
root@minio-102:/home/holelin# mkfs.ext4 /dev/sdc
mke2fs 1.45.5 (07-Jan-2020)
Found a dos partition table in /dev/sdc
Proceed anyway? (y,N) y
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 8661df5c-13f9-493b-a5e6-902cd612a613
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done -
创建命令将其挂载上去
1
2
3root@minio-102:/home/holelin# mkdir -p /opt/bigdata/minio/data{1..2}
root@minio-102:/home/holelin# mount /dev/sdb /opt/bigdata/minio/data1
root@minio-102:/home/holelin# mount /dev/sdc /opt/bigdata/minio/data2 -
查看挂载情况
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15root@minio-102:/opt/bigdata/minio# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 391M 1.6M 389M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 19G 6.3G 12G 36% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda2 2.0G 108M 1.7G 6% /boot
/dev/loop1 50M 50M 0 100% /snap/snapd/18357
/dev/loop0 92M 92M 0 100% /snap/lxd/24061
/dev/loop2 64M 64M 0 100% /snap/core20/1828
tmpfs 391M 0 391M 0% /run/user/1000
/dev/sdb 4.9G 24K 4.6G 1% /opt/bigdata/minio/data1
/dev/sdc 4.9G 24K 4.6G 1% /opt/bigdata/minio/data2 -
(建议)运行命令
cp /etc/fstab /etc/fstab.bak
备份/etc/fstab
文件 -
设置自动挂载
- 编辑
vim /etc/fstab
1
2
3
4
5
6
7
8
9
10
11
12
13
14# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation
/dev/disk/by-id/dm-uuid-LVM-cGmWUVBv33VTllHitivA9iiCMWt8DSieosTgIHWpLhOULK45fGjBSC1JCjWpx9qR / ext4 defaults 0 1
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/ddec6c8f-ad72-404f-84f6-0faea3c5b690 /boot ext4 defaults 0 1
/swap.img none swap sw 0 0
/dev/sdb /opt/bigdata/minio/data1 ext4 defaults 0 0
/dev/sdc /opt/bigdata/minio/data2 ext4 defaults 0 0- 或者直接运行命令
echo /dev/sdc /opt/bigdata/minio/data2 ext4 defaults 0 0 >> /etc/fstab
向/etc/fstab
写入新分区信息
- 编辑
磁盘阵列(Redundant Arrays of Inexpensive Disks,RAID
)
- 通过一个技术(软件或者硬件),将多个较小的磁盘整合为一个较大的磁盘装置,而这个较大的磁盘功能可不止是存储而已,它还有数据保护的功能.整个
RAID
由于选择的等级(level
)不同,而使得整合后的磁盘具有不同的功能,常见的level
有几种: Linear mode
(线性模式)RAID-0
(交错模式,stripe)RAID-1
(映像模式,mirror)RAID-5
/etc/fstab
1 | # /etc/fstab: static file system information. |
-
file system
: 例如/dev/cdrom
或/dev/sdb
,除了使⽤设备名,还可以使⽤设备的UUID或设备的卷标签,例如,LABAL=root
或UUID=7f91104e-8187-4ccf-8215-6e2e641f32e3
-
mount point
: 该字段描述希望的⽂件系统加载的⽬录,对于swap设备,该字段为none -
type
: 定义了该设备上的⽂件系统-
系统可⽤⽂件系统
cat /proc/filesystems
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35nodev sysfs
nodev tmpfs
nodev bdev
nodev proc
nodev cgroup
nodev cgroup2
nodev cpuset
nodev devtmpfs
nodev configfs
nodev debugfs
nodev tracefs
nodev securityfs
nodev sockfs
nodev bpf
nodev pipefs
nodev ramfs
nodev hugetlbfs
nodev devpts
ext3
ext2
ext4
squashfs
vfat
nodev ecryptfs
fuseblk
nodev fuse
nodev fusectl
nodev efivarfs
nodev mqueue
nodev resctrl
nodev pstore
nodev autofs
nodev binfmt_misc
nodev overlay
nodev aufs
-
-
options
选项 含义 defaults
使⽤默认设置. 等于 rw,suid,dev,exec,auto,nouser,async
rw
挂载为读写权限 ro
以只读模式加载该⽂件系统 exec
是⼀个默认设置项,它使在那个分区中的可执⾏的⼆进制⽂件能够执⾏ noexec
⼆进制⽂件不允许执⾏ sync
不对该设备的写操作进⾏缓冲处理,这可以防⽌在⾮正常关机时情况下破坏⽂件系统,但是却降低了计算机速度 async
所有的I/O将以异步⽅式进⾏ user
允许普通⽤户加载该⽂件系统 nouser
只允许root⽤户挂载.这是默认设置. quota
强制在该⽂件系统上进⾏磁盘定额限制 noauto
不再使⽤ mount -a
命令(例如系统启动时)加载该⽂件系统noatime/nodiratime
禁⽌更新访问时间 -
dump
: 该选项被"dump"命令使⽤来检查⼀个⽂件系统应该以多快频率进⾏转储,若不需要转储就设置该字段为0 -
pass
: 该字段被fsck
命令⽤来决定在启动时需要被扫描的⽂件系统的顺序,根⽂件系统"/"对应该字段的值应该为1,其他⽂件系统应该为2。若该⽂件系统⽆需在启动时扫描则设置该字段为0.
smartctl
- SMART (Self-Monitoring, Analysis and Reporting Technology) 是一种内置于存储设备(如硬盘和固态硬盘)中的监控系统,用于检测和报告潜在的硬件故障,以便用户可以在设备完全失败之前采取措施。SMART 技术提供了一组可以监控的属性,这些属性反映了磁盘的健康状况,包括错误率、温度、重新分配的扇区数等等。
SMART
的主要功能
- 监控: 持续监控存储设备的运行情况。
- 分析: 通过内置算法分析监控数据,判断磁盘健康状况。
- 报告: 当检测到潜在问题时,向用户发出警告,建议备份数据并更换硬盘。
常见的 SMART 属性
- Reallocated Sectors Count: 重新分配的扇区数。这通常是一个重要的故障前兆。
- Current Pending Sector Count: 当前等待重新分配的扇区数。
- Power-On Hours: 磁盘通电时间。
- Temperature: 磁盘温度。
- Read Error Rate: 读取错误率。
- Spin Retry Count: 磁盘启动重试次数
示例
1 | sudo smartctl -a /dev/sda |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 HoleLin's Blog!