瑞芯微ROCK960 RK3399烧录image后扩容rootfs
程序员文章站
2022-04-11 08:25:36
使用parted和resize2fs扩容GPT分区表格式 rootfs ......
问题描述:
rk3399开发板烧录官网提供的ubuntu镜像: ubuntu 16.04 server arm64(下载地址:https://www.96boards.org/documentation/consumer/rock/downloads/ubuntu.md.html),
开发板上电运行查看系统根目录容量已使用96%:
root@rock960:~# df filesystem 1k-blocks used available use% mounted on /dev/root 1515376 1353320 67032 96% / devtmpfs 1951660 0 1951660 0% /dev tmpfs 1952236 0 1952236 0% /dev/shm tmpfs 1952236 49692 1902544 3% /run tmpfs 5120 0 5120 0% /run/lock tmpfs 1952236 0 1952236 0% /sys/fs/cgroup tmpfs 390448 0 390448 0% /run/user/0 root@rock960:~#
再查看磁盘容量,32gb emmc实际可用容量29gb,除去已分区容量还有27.5gb容量未分区:
root@rock960:~# fdisk -l /dev/mmcblk1 disk /dev/mmcblk1: 29.1 gib, 31268536320 bytes, 61071360 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: f464c417-6f1f-4bf8-a1ce-bdb432a3bd1b device start end sectors size type /dev/mmcblk1p1 64 8063 8000 3.9m linux filesystem /dev/mmcblk1p2 16384 24575 8192 4m linux filesystem /dev/mmcblk1p3 24576 32767 8192 4m linux filesystem /dev/mmcblk1p4 32768 262143 229376 112m efi system /dev/mmcblk1p5 262144 3409886 3147743 1.5g linux filesystem root@rock960:~#
因此需要把未分区的27.5gb磁盘空间追加到/dev/mmcblk1p5并扩容rootfs文件系统。解决方法主要用到两个命令:parted和resize2fs。
首先重新分配/dev/mmcblk1p5分区大小到覆盖整个磁盘剩余容量:(注意fdisk不支持gpt分区)
root@rock960:~# parted /dev/mmcblk1 gnu parted 3.2 using /dev/mmcblk1 welcome to gnu parted! type 'help' to view a list of commands. (parted) print model: mmc bjnb4r (sd/mmc) disk /dev/mmcblk1: 31.3gb sector size (logical/physical): 512b/512b partition table: gpt disk flags: number start end size file system name flags 1 32.8kb 4129kb 4096kb loader1 2 8389kb 12.6mb 4194kb loader2 3 12.6mb 16.8mb 4194kb trust 4 16.8mb 134mb 117mb fat16 boot boot, esp 5 134mb 1746mb 1612mb ext4 rootfs (parted) unit s (parted) print model: mmc bjnb4r (sd/mmc) disk /dev/mmcblk1: 61071360s sector size (logical/physical): 512b/512b partition table: gpt disk flags: number start end size file system name flags 1 64s 8063s 8000s loader1 2 16384s 24575s 8192s loader2 3 24576s 32767s 8192s trust 4 32768s 262143s 229376s fat16 boot boot, esp 5 262144s 3409886s 3147743s ext4 rootfs (parted) resizepart 5 100% (parted) print model: mmc bjnb4r (sd/mmc) disk /dev/mmcblk1: 61071360s sector size (logical/physical): 512b/512b partition table: gpt disk flags: number start end size file system name flags 1 64s 8063s 8000s loader1 2 16384s 24575s 8192s loader2 3 24576s 32767s 8192s trust 4 32768s 262143s 229376s fat16 boot boot, esp 5 262144s 61071326s 60809183s ext4 rootfs (parted) q root@rock960:~#
然后进行ext文件系统扩容:
root@rock960:~# resize2fs /dev/mmcblk1p5 resize2fs 1.42.13 (17-may-2015) the filesystem is already 7601147 (4k) blocks long. nothing to do! root@rock960:~#
这时查看根目录下已使用容量已经变成5%
root@rock960:~# df -th filesystem type size used avail use% mounted on /dev/root ext4 31g 1.4g 28g 5% / devtmpfs devtmpfs 2.0g 0 2.0g 0% /dev tmpfs tmpfs 2.0g 0 2.0g 0% /dev/shm tmpfs tmpfs 2.0g 51m 2.0g 3% /run tmpfs tmpfs 5.3m 0 5.3m 0% /run/lock tmpfs tmpfs 2.0g 0 2.0g 0% /sys/fs/cgroup tmpfs tmpfs 400m 0 400m 0% /run/user/0 root@rock960:~#
后续:
tbd
上一篇: SQL 在自增列插入指定数据的操作方法
下一篇: 机器人“报名”厨王争霸赛