How to expand the remaining TF card space?
Description
I used a 64 G TF card to burn the image system. But when compiling
ffmpeg on VisionFive, it indicated that
the TF card space was insufficient. After booting Fedora and running df
-h
, I see that only 12 G for /dev/mmclbk0p4 is
mounted on. Where is the rest? How can I use the remaining space?
SoC
JH7100
SBC
VisionFive
Software
Fedora 33
Cause
Fedora image is 12.6 G after decompression.
When you burned the Fedora system, only12.6 G space was allocated in your TF card while the remaining space was not allocated.
Solution
You can expand the remaining space of TF card in the Fedora system.
Procedure
- Check the disk usage under the current Fedora system. After entering the
command, you can see that the root file system is mounted on the
/dev/mmcblk0p4
partition:
[riscv@fedora-starfive ~]$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.5G 0 3.5G 0% /dev tmpfs 3.6G 0 3.6G 0% /dev/shm tmpfs 1.5G 1.2M 1.5G 1% /run /dev/mmcblk0p4 12G 8.3G 2.9G 75% / tmpfs 3.6G 4.0K 3.6G 1% /tmp /dev/mmcblk0p3 458M 130M 314M 30% /boot /dev/mmcblk0p2 122M 4.5M 118M 4% /boot/efi tmpfs 718M 52K 718M 1% /run/user/985 tmpfs 718M 44K 718M 1% /run/user/1000 [riscv@fedora-starfive ~]$
- Then execute the following command to see that the starting address of
partition #4 is 1320960, which will be used when re-creating partition #4
later.
[riscv@fedora-starfive ~]$ cat /sys/block/mmcblk0/mmcblk0p4/start 1320960 [riscv@fedora-starfive ~]$
- Execute the following command to operate the TF
card:
[riscv@fedora-starfive ~]$ sudo fdisk /dev/mmcblk0 We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for riscv: #Enter user password Welcome to fdisk (util-linux 2.36.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d #Delete partition Partition number (2-4, default 4): 4 #Delete partition #4 Partition 4 has been deleted. Command (m for help): n #Create a new partition Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p # Create primary partition Partition number (1,4, default 1): 4 #Create partition #4 First sector (2048-122138623, default 2048): 1320960 #Enter the starting address of partition #4 Last sector, +/-sectors or +/-size{K,M,G,T,P} (1320960-122138623, default 122138623): #Press "enter" to select default Created a new partition 4 of type 'Linux' and of size 57.6 GiB. Partition #4 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: N #Do not remove the signature Command (m for help): w #Write the above operations to the partition table The partition table has been altered. Syncing disks. [riscv@fedora-starfive ~]$
- After the operation is complete, execute the following command to
reboot:
sudo reboot
- After rebooting, enter the system and execute the
resize2fs
command to adjust the space of the ext file system, so that the system disk can be expanded.[riscv@fedora-starfive ~]$ sudo resize2fs /dev/mmcblk0p4 [sudo] password for riscv: resize2fs 1.45.6 (20-Mar-2020) Filesystem at /dev/mmcblk0p4 is mounted on /; on-line resizing r[ 313.505284] EXT4-fs (mmcblk0p4): resizing filesystem from 2999808 to 15102208 blocks equired old_desc_blocks = 2, new_desc_blocks = 8 [ 315.140090] EXT4-fs (mmcblk0p4): resized filesystem to 15102208 The filesystem on /dev/mmcblk0p4 is now 15102208 (4k) blocks long. [riscv@fedora-starfive ~]$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.5G 0 3.5G 0% /dev tmpfs 3.6G 0 3.6G 0% /dev/shm tmpfs 1.5G 1.2M 1.5G 1% /run /dev/mmcblk0p4 57G 8.3G 49G 15% / tmpfs 3.6G 4.0K 3.6G 1% /tmp /dev/mmcblk0p3 458M 130M 314M 30% /boot /dev/mmcblk0p2 122M 4.5M 118M 4% /boot/efi tmpfs 718M 52K 718M 1% /run/user/985 tmpfs 718M 44K 718M 1% /run/user/1000 [riscv@fedora-starfive ~]$
Now your root file system has been expanded from 12 G to 57 G.