root@orangepi5:~# sudo dd if=/dev/mmcblk1 of=/dev/sda bs=4M 306+0 records in 306+0 records out 1283457024 bytes (1.3 GB, 1.2 GiB) copied, 31.7812 s, 40.4 MB/s 311+0 records in 311+0 records out 1304428544 bytes (1.3 GB, 1.2 GiB) copied, 37.4343 s, 34.8 MB/s 316+0 records in 316+0 records out 1325400064 bytes (1.3 GB, 1.2 GiB) copied, 42.0409 s, 31.5 MB/s
Welcome to fdisk (util-linux 2.37.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
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): p #查看当前容量 Disk /dev/mmcblk1: 58.25 GiB, 62542315520 bytes, 122152960 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: 5916F58E-4D47-4B12-B663-32607503A1C0 Device Start End Sectors Size Type /dev/mmcblk1p1 61440 585727 524288 256M Linux extended boot /dev/mmcblk1p2 585728 30932991 30347264 14.5G Linux filesystem Command (m for help): d #先删除分区 Partition number (1,2, default 2): 2 #/dev/mmcblk1p2,分区号是 2 Partition 2 has been deleted. Command (m for help): n #新建分区,选择主分区就行,p Partition number (2-128, default 2): 2 #/dev/mmcblk1p2,分区号还是 2 First sector (2048-122152926, default 585728): #起始扇区 参考上面的start,这里默认即可 Last sector, +/-sectors or +/-size{K,M,G,T,P} (585728-122152926, default 122152926): #结尾扇区,这里默认即可 Created a new partition 2 of type 'Linux filesystem' and of size 58 GiB. Partition #2 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: y #如果旧的分区有签名信息,移除 The signature will be removed by a write command. Command (m for help): p #查看新分区信息,可以看到,58G 已经完全分配 Disk /dev/mmcblk1: 58.25 GiB, 62542315520 bytes, 122152960 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: 5916F58E-4D47-4B12-B663-32607503A1C0 Device Start End Sectors Size Type /dev/mmcblk1p1 61440 585727 524288 256M Linux extended boot /dev/mmcblk1p2 585728 122152926 121567199 58G Linux filesystem Filesystem/RAID signature on partition 2 will be wiped. Command (m for help): w #写入 The partition table has been altered. Syncing disks.
接下来重启香橙派 reboot,重启之后更新文件系统大小:
1 2 3 4 5 6
root@orangepi5:~# sudo resize2fs /dev/mmcblk1p2 resize2fs 1.46.5 (30-Dec-2021) Filesystem at /dev/mmcblk1p2 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 4 The filesystem on /dev/mmcblk1p2 is now 15195899 (4k) blocks long.