200字
openwrt热扩容-efi分区
2026-07-17
2026-07-17

openwrt热扩容-efi分区

第一步:进入 parted 交互界面

执行命令进入交互模式:

parted /dev/nvme0n1

进入后严格按顺序输入,每输完一行按回车:

1、输入 print 回车

弹出 GPT 空间警告时,输入 Fix 回车

系统会自动修复 GPT 分区表,识别完整的 13.4GB 磁盘空间,此操作不触碰任何现有数据

2、输入 resizepart 3 回车

弹出 “分区正在使用,是否继续” 的警告时,输入 yes 回车

ext4 原生支持挂载状态下扩容,此操作安全

3、提示输入结束位置时,输入 100% 回车

表示将第 3 分区向后扩展到磁盘最末尾,占满所有空闲空间

4、输入 quit 回车,退出 parted 工具

操作参考如下过程,我的是16g的ssd-nvme

root@FJ-FZ-Router1:~# parted /dev/nvme0n1
GNU Parted 3.6
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Warning: Not all of the space available to /dev/nvme0n1 appears to be used, you can fix the GPT to use all of the
space (an extra 23150047 blocks) or continue with the current setting? 
Fix/Ignore? fix                                                           
Model: INTEL MEMPEK1J016GAL (nvme)
Disk /dev/nvme0n1: 14.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
128     17.4kB  262kB   245kB                      bios_grub
 1      262kB   134MB   134MB   fat16              legacy_boot
 2      134MB   403MB   268MB
 3      403MB   2550MB  2147MB  ext4

(parted) resizepart 3                                                     
Warning: Partition /dev/nvme0n1p3 is being used. Are you sure you want to continue?
Yes/No? yes                                                               
End?  [2550MB]? 100%                                                      
(parted) quit                                                             
Information: You may need to update /etc/fstab.

第二步:刷新内核分区表

让系统内核实时识别新的分区大小:

partprobe /dev/nvme0n1

第三步:在线扩容 ext4 文件系统

分区表扩大后,文件系统还不能识别新空间,执行在线扩容:

resize2fs /dev/nvme0n1p3

root@FJ-FZ-Router1:~# partprobe /dev/nvme0n1                         
root@FJ-FZ-Router1:~# resize2fs /dev/nvme0n1p3
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/nvme0n1p3 is mounted on /overlay; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/nvme0n1p3 is now 3418043 (4k) blocks long.

第四步:验证扩容结果

df -h /

执行后即可看到根分区总容量从 1.9G 扩容到约 13G,扩容完成。