U盘安装树莓派系统,利用U盘启动Raspberry

怪蜀黍 2017-05-2919:27:29
评论
1,729

U盘安装树莓派系统,利用U盘启动Raspberry

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

U盘安装树莓派系统,利用U盘启动Raspberry

怪蜀黍
  • 本文由 发表于 2017-05-2919:27:29
  • 转载请务必保留本文链接:https://www.ki66.com/905
树莓派云服务器 树莓派

树莓派云服务器

虽然说树莓派的主战场在物联网和教育,但还是会有人把它用在其他领域。   比如,部署网站。   早在2016年底,Mythic Beasts公司就推出了Raspberry Pi云服务,允许大家...
「教程」树莓派配置WIFI 热点 树莓派

「教程」树莓派配置WIFI 热点

1. 安装配置DNSmasq DNSmasq是一个小巧且方便地用于配置DNS和DHCP的工具,适用于小型网络,它提供了DNS功能和可选择的DHCP功能。它服务那些只在本地适用的域名,这些域名是不会在全...
「教程」树莓派入门(图文) 树莓派

「教程」树莓派入门(图文)

声明:本文参考资料均来自于树莓派官网。 树莓派基础认知: 树莓派基础认知 Raspberrypi有很多种型号,最新的是Raspberry Pi 4 Model B,它还是最快和最容易使用的。 Rasp...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: