树莓派linux系统识别u盘启动,U盘安装树莓派系统,利用U盘启动Raspberry

编程知识 更新时间:2023-04-14 13:52:46

树莓派的系统一般是安装在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盘安装系统。

三、扩展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).

然后重启系统 sudo reboot。

重启完成后,使用 sudo resize2fs /dev/sda2 命令进行实际的空间拓展,等待命令执行完成,再次重启系统,即完成了U盘空间的拓展。

更多推荐

树莓派linux系统识别u盘启动,U盘安装树莓派系统,利用U盘启动Raspberry

本文发布于:2023-04-12 01:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/b511b3e559e7dc6665acc37655b68917.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统   树莓派   linux   Raspberry

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 69160文章数
  • 14阅读数
  • 0评论数