如何将配好的树莓派系统制作成系统镜像

设备要求:

  1. ubuntu18/20. (Windows和Mac-OS建议使用虚拟机镜像)
  2. sudo apt-get install gparted

步骤:

  1. 找到Micro SD卡的Path.
    # 1. 找到SD卡
    lsblk

      

    # 2. 或者使用其他命令:
    sudo fdisk -l   # 列出磁盘
    

      

     根据内存大小可以找到,例如我的内存卡大小是64G,所以我的在sde.所以Path为  /dev/sde.

  2. 克隆自己的Micro SD卡成镜像.
    sudo dd if=/dev/sdb of=/your/path/to/customOS.img
    

      这个使用了gparted工具。if代表的是Input file的路径,对应的是Micro SD卡的路径。of代表的是output file. 系统镜像的后缀是.img. 另外,这个过程需要花费一定的时间,看起来是死机了。稍等一下。注意防止电脑休眠。

  3. 缩小镜像.
    # 1. 安装缩小工具,pyShrink.
    wget  https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh 
    chmod +x pishrink.sh 
    sudo mv pishrink.sh /usr/local/bin
    
    # 2. 缩小镜像。
    sudo pishrink.sh /your/path/to/CustomOS.img /your/path/to/CustomOS-shrink.img
    

      第二步制作的镜像跟你的SD卡一样大,所以要释放一些空间。比如原来64G,所以要缩小到实际使用大小(64g-->14g)。

     

 

posted @ 2024-04-02 09:56  张幼安  阅读(214)  评论(0编辑  收藏  举报