在使用firefly板子时,刷完固件发现根目录竟然只有3G,根本没法再安装其他软件,只能想办法扩容。
firefly@firefly:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 2.9G 2.7G 54M 99% /
devtmpfs 965M 0 965M 0% /dev
tmpfs 966M 0 966M 0% /dev/shm
tmpfs 966M 844K 965M 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 966M 0 966M 0% /sys/fs/cgroup
/dev/mmcblk0p4 100M 16M 84M 17% /boot
/dev/sda1 1.9T 344G 1.5T 19% /home/firefly/2tdisk
tmpfs 194M 16K 193M 1% /run/user/1000
tmpfs 194M 0 194M 0% /run/user/0
tmpfs 194M 4.0K 194M 1% /run/user/109
可以看到根目录只有2.9G,没有空间再安装程序了,但是sd卡实际上是有32G的,那么剩下的空间哪里去了?
使用fdisk可以看到根目录安装在mmcblk0p5
分区上,是mmcblk0
的最后一个分区,1-5个分区加在一起也就3G,剩下的约30G磁盘空间还没有划分分区,那么要解决的方法很简单,就是将p5分区扩展到磁盘末尾位置,抢回剩下的30G空间。
firefly@firefly:~$ sudo fdisk -l
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytesGPT PMBR size mismatch (6299647 != 62521343) will be corrected by w(rite).
Disk /dev/mmcblk0: 29.8 GiB, 32010928128 bytes, 62521344 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: gpt
Disk identifier: F467110E-A6E0-45F6-BB90-69C0101AD66DDevice Start End Sectors Size Type
/dev/mmcblk0p1 64 8063 8000 3.9M Linux filesystem
/dev/mmcblk0p2 16384 24575 8192 4M Linux filesystem
/dev/mmcblk0p3 24576 32767 8192 4M Linux filesystem
/dev/mmcblk0p4 32768 262143 229376 112M EFI System
/dev/mmcblk0p5 262144 6299614 6037471 2.9G Linux filesystemDisk /dev/sda: 1.8 TiB, 2000365289472 bytes, 3906963456 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: gpt
Disk identifier: E8745393-AAF5-4054-A19F-5642AF580F4FDevice Start End Sectors Size Type
/dev/sda1 2048 3906961407 3906959360 1.8T Microsoft basic data
apt install parted
命令来安装。firefly@firefly:~$ sudo parted /dev/mmcblk0
GNU Parted 3.2
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: SD EB1QT (sd/mmc)
Disk /dev/mmcblk0: 32.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags1 32.8kB 4129kB 4096kB loader12 8389kB 12.6MB 4194kB loader23 12.6MB 16.8MB 4194kB trust4 16.8MB 134MB 117MB fat16 boot boot, esp5 134MB 3225MB 3091MB ext2 rootfs(parted) resizepart 5
End? [3225MB]? 29.6G
(parted) q
Information: You may need to update /etc/fstab.
分区5是根目录分区,所以需要使用resizepart 5
来对起进行扩容,由于前面提示Disk /dev/mmcblk0: 32.0GB
, 那么根据文章 提示,为了安全,实际分区尺寸要小于最大尺寸0.2G, 所以这里End```写的是```31.8G
. 另外需要说明的时,parted命令中, p
表示打印分区状况,q
退出。
最终我们要回所有的磁盘空间。
firefly@firefly:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 2.7G 26G 10% /
devtmpfs 965M 0 965M 0% /dev
tmpfs 966M 0 966M 0% /dev/shm
tmpfs 966M 844K 965M 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 966M 0 966M 0% /sys/fs/cgroup
/dev/mmcblk0p4 100M 16M 84M 17% /boot
/dev/sda1 1.9T 344G 1.5T 19% /home/firefly/2tdisk
tmpfs 194M 16K 193M 1% /run/user/1000
tmpfs 194M 0 194M 0% /run/user/0
tmpfs 194M 4.0K 194M 1% /run/user/109
参考链接:
Resizing a Partition + Filesystem on Linux from the CLI