树莓派用U盘来安装系统启动盘系统应用

By 管理员5

2023-05-09 18:27:56

浏览量66113

已赞3

用U盘来安装树莓派系统,利用U盘做系统驱动盘

树莓派的系统一般是安装在SD卡上,但是SD卡比较脆弱,如果频繁的读写数据,会导致SD卡损坏。SD卡的读写速度也比U盘慢。如果我们将树莓派系统安装在U盘中,利用更加强壮、速度更快的U盘启动树莓派,则可以解决使用SD卡遇到的问题。

以下是U盘安装树莓派系统,利用U盘启动Raspberry的教程。

一、准备条件

  • 树莓派一台
  • SD卡一个,容量不用太大,但必须大于128M.
  • U盘一个,8G以上
  • 树莓派系统镜像系统云盘下载

二、安装系统

将树莓派系统写入到U盘中,方法和写入SD卡的方法一样,windows下可以使用win32diskimager(镜像写U盘工具)将系统写入。

格式化SD卡,然后将写好系统的U盘下的内容全部复制到SD卡根目录中。

修改SD卡根目录下的 cmdline.txt 文件。因为U盘现在有2个分区,一个是boot(/dev/sda1)分区,另一个才是root(/dev/sda2)分区。

 将root=/dev/mmcblk0p2修改为root=/dev/sda2

然后,将U盘和SD卡同时插到树莓派上,上电就可以将树莓派从U盘启动了。

启动后可以感受到,树莓派的运行速度快了许多,这是因为我们使用了速度更快的U盘安装系统。

Image

三、扩展U盘空间

U盘安装完系统后,发现虽然我的U盘是32G大小的,但是使用df命令可以看到只有4G大小,使用sudo raspi-config扩展,提示不能自动扩展:

sda2 is not an SD card. Don't know how to expand

这时需要使用fdisk命令手动扩展空间,信息过程如下。带有注释的行是需要输入的信息。

pi@raspberrypi:~ $ **sudo fdisk /dev/sda    #扩展分区**

Welcome to fdisk (util-linux 2.25.2).  
Changes will remain in memory only, until you decide to write them.  
Be careful before using the write command.


Command (m for help): p    #查看现有分区  
Disk /dev/sda: 28.7 GiB, 30752000000 bytes, 60062500 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: 0x2d52e4bb

Device     Boot  Start      End  Sectors  Size Id Type  
/dev/sda1         8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/sda2       137216 60062499 59925284 28.6G 83 Linux


Command (m for help): d    #删除分区2  
Partition number (1,2, default 2): 2    #选择要删除的分区号

Partition 2 has been deleted.

Command (m for help): n        #新建分区  
Partition type  
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p    #选择p,即为主分区  
Partition number (2-4, default 2): 2    #选择要新建的分区号  
First sector (2048-60062499, default 2048): 137216    #输入删除分区前/dev/sda2的起始磁盘柱  
Last sector, +sectors or +size{K,M,G,T,P} (137216-60062499, default 60062499): #默认即可

Created a new partition 2 of type 'Linux' and of size 28.6 GiB.

Command (m for help): p    #查看修改后的分区  
Disk /dev/sda: 28.7 GiB, 30752000000 bytes, 60062500 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: 0x2d52e4bb

Device     Boot  Start      End  Sectors  Size Id Type  
/dev/sda1         8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/sda2       137216 60062499 59925284 28.6G 83 Linux


Command (m for help): wq    #保存退出  
The partition table has been altered.  
Calling ioctl() to re-read partition table.  
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

Shell

Copy

然后重启系统 sudo reboot

重启完成后,使用 sudo resize2fs /dev/sda2

 命令进行实际的空间拓展,等待命令执行完成,再次重启系统,即完成了U盘空间的拓展。


本文章最后由 超级版主2023-11-12 22:05 编辑
发表评论
请先 注册/登录 后参与评论

已有1 发布

默认   热门   正序   倒序
查看更多评论
(3) 分享
分享

扫二维码或复制链接分享该篇文章

取消
已有0次打赏
本站免责声明
1、本站资源,均来自网络或个人用户发布,版权归原作者,所有资源和文章仅限用于学习和研究目的 。
2、不得用于商业或非法用途,否则,一切责任由该用户承担 !

侵权删除请致信 E-Mail:cxg88@qq.com