Loading... > 操作前进入root,以免发生一些奇怪的问题 首先安装 `cloud-utils` ```bash apt-get install cloud-utils ``` > 推荐重启 > > reboot ```bash # 查看磁盘信息 root@Quark-N:~# fdisk -l Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 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 Disklabel type: dos Disk identifier: 0x41efd092 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 49152 131071 81920 40M 83 Linux /dev/mmcblk0p2 131072 2588671 2457600 1.2G 83 Linux /dev/mmcblk0p3 2588672 19455999 16867328 8G 83 Linux Disk /dev/mmcblk1: 14.7 GiB, 15758000128 bytes, 30777344 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 Disklabel type: dos Disk identifier: 0x41efd092 Device Boot Start End Sectors Size Id Type /dev/mmcblk1p1 49152 131071 81920 40M 83 Linux /dev/mmcblk1p2 131072 2588671 2457600 1.2G 83 Linux /dev/mmcblk1p3 2588672 30777343 28188672 13.5G 83 Linux Disk /dev/mmcblk1boot1: 4 MiB, 4194304 bytes, 8192 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/mmcblk1boot0: 4 MiB, 4194304 bytes, 8192 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 ``` ```bash root@Quark-N:~# parted -l Error: /dev/mmcblk1boot0: unrecognised disk label Model: Generic SD/MMC Storage Card (sd/mmc) Disk /dev/mmcblk1boot0: 4194kB Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags: Model: MMC 016GB0 (sd/mmc) Disk /dev/mmcblk1: 15.8GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 25.2MB 67.1MB 41.9MB primary fat16 2 67.1MB 1325MB 1258MB primary ext4 3 1325MB 15.8GB 14.4GB primary ext4 Error: /dev/mmcblk1boot1: unrecognised disk label Model: Generic SD/MMC Storage Card (sd/mmc) Disk /dev/mmcblk1boot1: 4194kB Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags: Model: SD SU16G (sd/mmc) Disk /dev/mmcblk0: 15.9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 25.2MB 67.1MB 41.9MB primary fat16 2 67.1MB 1325MB 1258MB primary ext4 3 1325MB 9961MB 8636MB primary ext4 ``` 可以看到 `/dev/mmcblk0`的 `/dev/mmcblk0p3`只有8G,这是原版镜像的默认分区信息,我的SD卡有14G空余 ```bash # 通过 growpart 增大分区3 root@Quark-N:~# growpart /dev/mmcblk0 3 CHANGED: partition=3 start=2588672 old: size=16867328 end=19456000 new: size=28527583,end=31116255 ``` ```bash # 检查扩容是否成功 root@Quark-N:~# parted -l /dev/mmcblk0 Error: /dev/mmcblk1boot0: unrecognised disk label Model: Generic SD/MMC Storage Card (sd/mmc) Disk /dev/mmcblk1boot0: 4194kB Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags: Model: MMC 016GB0 (sd/mmc) Disk /dev/mmcblk1: 15.8GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 25.2MB 67.1MB 41.9MB primary fat16 2 67.1MB 1325MB 1258MB primary ext4 3 1325MB 15.8GB 14.4GB primary ext4 Error: /dev/mmcblk1boot1: unrecognised disk label Model: Generic SD/MMC Storage Card (sd/mmc) Disk /dev/mmcblk1boot1: 4194kB Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags: Model: SD SU16G (sd/mmc) Disk /dev/mmcblk0: 15.9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 25.2MB 67.1MB 41.9MB primary fat16 2 67.1MB 1325MB 1258MB primary ext4 3 1325MB 15.9GB 14.6GB primary ext4 ``` 可以看到3号分区完成扩容 继续扩容文件系统 ```bash # 创建临时目录 root@Quark-N:~# mkdir /tmp/d ``` ```bash # 挂载目录 root@Quark-N:~# mount /dev/mmcblk0p3 /tmp/d ``` ```bash root@Quark-N:~# resize2fs -f /dev/mmcblk0p3 resize2fs 1.42.13 (17-May-2015) Filesystem at /dev/mmcblk0p3 is mounted on /tmp/p3; on-line resizing required old_desc_blocks = 33, new_desc_blocks = 55 The filesystem on /dev/mmcblk0p3 is now 14263788 (1k) blocks long. ``` 重启 `reboot` 完成~ 最后修改:2024 年 03 月 09 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏