尽可能小的备份树莓派,以及烧录后如何重新扩展主分区

备份

推荐使用这个脚本来一键式备份:https://github.com/zlj-zz/RaspberryBackup

包括检测和下载需要的工具,备份系统,压缩镜像。

扩展主分区

  1. 将烧录镜像的 SD 插到电脑中, 系统为 ubuntu,识别为 /dev/sdc2,会自动挂载,我电脑挂载到 /media/ubuntu/rootfs

  2. 取消挂载 sudo umount /media/ubuntu/rootfs

  3. 可能提示设备 busy,结束使用磁盘的程序 sudo fuser -m -i -v -k /media/ubuntu/rootfs, 然后重新取消挂载

  4. 重新分区 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.
    
    
  5. 检查分区信息 e2fsck -f /dev/sdc2

  6. 调整分区大小 resize2fs -p /dev/sdc2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值