扩展分区
登录Debian后,如需充分利用SD卡上未使用的磁盘空间,请执行以下步骤扩展分区:
- 执行以下命令,列出可使用的磁盘空间:
df -h
输出示例:
root@starfive:~# df -h Filesystem Size Used Avail Use% Mounted on udev 1.7G 0 1.7G 0% /dev tmpfs 390M 1.7M 388M 1% /run /dev/mmcblk1p3 4.8G 3.2G 1.6G 68% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 390M 32K 390M 1% /run/user/111 tmpfs 390M 24K 390M 1% /run/user/0
-
以磁盘名作为参数运行
fdisk
命令。然后根据您的需求,执行以下命令:
- 输入
d
,删除/dev/mmcblk1p3分区; - 输入
n
,创建一个新的分区; - 输入
w
可保存修改。
示例命令和输出:
root@starfive:~# fdisk /dev/mmcblk1 Welcome to fdisk (util-linux 2.38). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. GPT PMBR size mismatch (10485759 != 249737215) will be corrected by write. The backup GPT table is not on the end of the device.This problem will be corrected by write. This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk. Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 has been deleted. Command (m for help): n Partition number (3-128, default 3): 3 First sector (239616-249737182, default 239616): Last sector, +/-sectors or +/-size{K,M,G,T,P} (239616-249737182, default 249735167): Created a new partition 3 of type 'Linux filesystem' and of size 119 GiB. Partition #3 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@starfive:~#
- 输入
- 执行
resize2fs
命令调整/dev/mmcblk1p3分区的大小,以充分利用未使用的块。示例命令和输出:
root@starfive:~# resize2fs /dev/mmcblk1p3 resize2fs 1.46.5 (30-Dec-2021) Filesystem at /d[ 192.744328] EXT4-fs (mmcblk1p3): resizing filesystem from 1280507 to 31186944 blocks ev/mmcblk1p3 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 15 [ 196.934822] EXT4-fs (mmcblk1p3): resized filesystem to 31186944 The filesystem on /dev/mmcblk1p3 is now 31186944 (4k) blocks long.
验证:
执行
df -h
命令以验证分区的新大小,并验证扩展分区(/dev/mmcblk1p3)的步骤是否成功。以下输出表示修改成功:
root@starfive:~# df -h Filesystem Size Used Avail Use% Mounted on udev 1.7G 0 1.7G 0% /dev tmpfs 390M 1.8M 388M 1% /run /dev/mmcblk1p3 118G 3.3G 114G 3% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 390M 32K 390M 1% /run/user/0