linux下硬盘分区和格式化
查看硬盘
- lsblk
$ lsblk
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 499M 0 part
├─sda2 8:2 0 100M 0 part
├─sda3 8:3 0 16M 0 part
├─sda4 8:4 0 118.8G 0 part
├─sda5 8:5 0 595M 0 part
├─sda6 8:6 0 200G 0 part
├─sda7 8:7 0 200G 0 part
└─sda8 8:8 0 411.5G 0 part
nvme0n1 259:0 0 465.8G 0 disk
- fdisk
$ sudo fdisk -l
Disk /dev/nvme0n1: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: KIOXIA-EXCERIA PLUS G2 SSD
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
硬盘分区
$ sudo fdisk /dev/nvme0n1
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 0xdb428e98.
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):
格式化分区
$ sudo mkfs.ext4 /dev/nvme0n1p5
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 43306240 4k blocks and 10829824 inodes
Filesystem UUID: ff01dd54-a623-49b4-8e7a-d1acf109e9d0
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
挂载分区
$ mkdir /home/xxx/ssd_home
$ sudo mount /dev/nvme0n1p5 /home/xxx/ssd_home
修改文件/etc/fstab
可实现自动挂载
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通