fdisk
1 | ❯ sudo fdisk /dev/nvme0n1 -l |
创建新分区
分配未使用的分区
Command (m for help): F
Unpartitioned space /dev/nvme0n1: 1.09 TiB, 1195919875584 bytes, 2335781007 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Start End Sectors Size
1571248128 3907029134 2335781007 1.1T
Command (m for help): n
Partition number (8-128, default 8):
First sector (1571248128-3907029134, default 1571248128):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1571248128-3907029134, default 3907029134): +80G
Created a new partition 8 of type 'Linux filesystem' and of size 80 GiB.
uuid
1 | ❯ sudo blkid /dev/nvme0n1p8 |
mkfs.ext4
1 | ❯ sudo mkfs.ext4 /dev/nvme0n1p8 |
删除
1 | ❯ sudo fdisk /dev/sdb |
Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): p
Disk /dev/sdb: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model:
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F4388C00-21CE-418F-86AA-3A1CD95B1CF3Device Start End Sectors Size Type
/dev/sdb6 304701440 500117503 195416064 93.2G Linux filesystem
/dev/sdb7 167002112 194111487 27109376 12.9G Linux filesystemPartition table entries are not in disk order.
Command (m for help): d
Partition number (6,7, default 7): 6Partition 6 has been deleted.
Command (m for help): d
Selected partition 7
Partition 7 has been deleted.Command (m for help): p
Disk /dev/sdb: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model:
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F4388C00-21CE-418F-86AA-3A1CD95B1CF3Command (m for help): w
The partition table has been altered.
Syncing disks.
创建
1 | ❯ sudo fdisk /dev/sdb |
Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition number (1-128, default 1): 1
First sector (34-500118158, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-500118158, default 500118158): +120G
Created a new partition 1 of type ‘Linux filesystem’ and of size 120 GiB.
Command (m for help): n
Partition number (2-128, default 2): 2
First sector (251660288-500118158, default 251660288):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (251660288-500118158, default 500118158):
Created a new partition 2 of type ‘Linux filesystem’ and of size 118.5 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
挂载
1 | sudo mkfs.ext4 /dev/sdb1 |
/etc/fstab
1 | $ cat /etc/fstab | grep -A 1 /mnt/data |
脚本挂载,u盘怕误拨导致无法开机
1 | ❯ sudo ln -s /etc/rc.local /opt/tools/init/rc.local |
gparted
1 | sudo apt-get install gparted |
smartctl
测试硬盘健康状态
1 | #debian |
1 | ❯ sudo smartctl -i /dev/sdb1 |
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-6.1.0-0.deb11.7-amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF INFORMATION SECTION ===
Vendor: ACASIS
Product:
Revision: 1214
Compliance: SPC-4
User Capacity: 256,060,514,304 bytes [256 GB]
Logical block size: 512 bytes
Physical block size: 4096 bytes
LU is resource provisioned, LBPRZ=0
Logical Unit id: 0x3000000000063700
Serial number: 000000000F37
Device type: disk
Local Time is: Sat Nov 4 09:01:21 2023 CST
SMART support is: Unavailable - device lacks SMART capability.