yocto编译后的wic镜像,在刷机后,仍有很大部分emmc未使用,下面将未使用的emmc扩展到文件系统挂载分区。
root@imx8dxmek:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 4.2G 2.6G 1.4G 66% /
devtmpfs 239M 4.0K 239M 1% /dev
tmpfs 401M 0 401M 0% /dev/shm
tmpfs 401M 9.9M 391M 3% /run
tmpfs 401M 0 401M 0% /sys/fs/cgroup
tmpfs 401M 4.0K 401M 1% /tmp
tmpfs 401M 176K 401M 1% /var/volatile
tmpfs 81M 8.0K 81M 1% /run/user/0
/dev/mmcblk0p1 84M 32M 52M 39% /run/media/mmcblk0p1
root@imx8dxmek:~#
root@imx8dxmek:~# fdisk -l
Disk /dev/mmcblk0: 14.69 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: 0x4f0e416d
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 16384 186775 170392 83.2M c W95 FAT32 (LBA)
/dev/mmcblk0p2 196608 9386045 9189438 4.4G 83 Linux //记录一下即将需要扩展的分区的起始扇区
root@imx8dxmek:~# fdisk /dev/mmcblk0
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.
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-30777343, default 2048): 196608 //分区起始扇区
Last sector, +/-sectors or +/-size{K,M,G,T,P} (196608-30777343, default 30777343):
Created a new partition 2 of type ‘Linux’ and of size 14.6 GiB.
Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: n
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@imx8dxmek:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 4.2G 2.6G 1.4G 66% /
devtmpfs 239M 4.0K 239M 1% /dev
tmpfs 401M 0 401M 0% /dev/shm
tmpfs 401M 9.9M 391M 3% /run
tmpfs 401M 0 401M 0% /sys/fs/cgroup
tmpfs 401M 4.0K 401M 1% /tmp
tmpfs 401M 176K 401M 1% /var/volatile
tmpfs 81M 8.0K 81M 1% /run/user/0
/dev/mmcblk0p1 84M 32M 52M 39% /run/media/mmcblk0p1
root@imx8dxmek:~#
root@imx8dxmek:~# resize2fs /dev/mmcblk0p2 //更新分区大小
resize2fs 1.45.3 (14-Jul-2019)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
[ 1649.348256] EXT4-fs (mmcblk0p2): resizing filesystem from 1148679 to 3822592 blocks
old_desc_blocks = 1, new_desc_blocks = 2
[ 1649.517462] EXT4-fs (mmcblk0p2): resized filesystem to 3822592
The filesystem on /dev/mmcblk0p2 is now 3822592 (4k) blocks long.
root@imx8dxmek:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 2.6G 11G 20% /
devtmpfs 239M 4.0K 239M 1% /dev
tmpfs 401M 0 401M 0% /dev/shm
tmpfs 401M 9.9M 391M 3% /run
tmpfs 401M 0 401M 0% /sys/fs/cgroup
tmpfs 401M 4.0K 401M 1% /tmp
tmpfs 401M 176K 401M 1% /var/volatile
tmpfs 81M 8.0K 81M 1% /run/user/0
/dev/mmcblk0p1 84M 32M 52M 39% /run/media/mmcblk0p1
root@imx8dxmek:~#