备份
推荐使用这个脚本来一键式备份:https://github.com/zlj-zz/RaspberryBackup
包括检测和下载需要的工具,备份系统,压缩镜像。
扩展主分区
-
将烧录镜像的 SD 插到电脑中, 系统为 ubuntu,识别为
/dev/sdc2
,会自动挂载,我电脑挂载到/media/ubuntu/rootfs
-
取消挂载
sudo umount /media/ubuntu/rootfs
-
可能提示设备 busy,结束使用磁盘的程序
sudo fuser -m -i -v -k /media/ubuntu/rootfs
, 然后重新取消挂载 -
重新分区 fdisk
-
sudo fdisk /dev/sdc
Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p # p 查看信息 Disk /dev/sdc: 29.6 GiB, 31719424000 bytes, 61952000 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: 0x340bfd6e Device Boot Start End Sectors Size Id Type /dev/sdc1 8192 532479 524288 256M c W95 FAT32 (LBA) /dev/sdc2 532480 23443455 22910976 10.9G 83 Linux Command (m for help): d # d 删除分区 Partition number (1,2, default 2): 2 Partition 2 has been deleted. Command (m for help): n # n 新建分区 Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (2-4, default 2): First sector (2048-61951999, default 2048): 532480 # 要和原来的磁盘柱一致 Last sector, +sectors or +size{K,M,G,T,P} (532480-61951999, default 61951999): Created a new partition 2 of type 'Linux' and of size 29.3 GiB. Command (m for help): p Disk /dev/sdc: 29.6 GiB, 31719424000 bytes, 61952000 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: 0x340bfd6e Device Boot Start End Sectors Size Id Type /dev/sdc1 8192 532479 524288 256M c W95 FAT32 (LBA) /dev/sdc2 532480 61951999 61419520 29.3G 83 Linux Command (m for help): wp # 保存退出 The partition table has been altered.
-
-
检查分区信息
e2fsck -f /dev/sdc2
-
调整分区大小
resize2fs -p /dev/sdc2