[树莓派] - u盘做系统盘

[树莓派] - u盘做系统盘

 

 

参考资料:

http://bbs.elecfans.com/jishu_450347_1_1.html

http://www.hx99.net/OS/Linux/201507/36835.html

 

目的

TF卡的性能较弱,读写速度更不上。并且价格比同性能的U盘要贵。

故使用U盘代替作为rootfs

 

使用工具

18G以上U盘一个,我使用东芝的USB3.0接口U盘。(U盘太多了,没其他用)

232M大小TF卡一张(我用了128M的,使用树莓派B+,SD卡的用同样大小代替)

3、电源,网线,(串口线有最好)

4、树莓派一个(额,废话)

 

相关附件下载

win98boot.zip 

hpupgsh.zip

Win32diskimager(自己应该有的)

 

 

操作教程

 

1U盘准备

下载Raspbian,解压缩使用win32diskimager将解压后的IMG文件写入到U盘,这个过程完全和官方写入到SD卡一样,只不过SD卡换成了U盘。

 

2SD卡准备

解压hpupgsh.zip,得到“惠普U盘存储格式化工具 V2.2.3 汉化版.exe

win98boot.zip解压到地址win98boot

使用管理员身份用“惠普U盘存储格式化工具 V2.2.3 汉化版.exe”格式化SD卡并写入BOOT文件,boot的地址选择win98boot

格式选择FAT32

 

3、最后准备

选中你刚才解压缩生成的目录。

在制作好的u盘里,找到

cmdline.txt文件,用windows记事本打开,修改

root=/dev/mmcblk0p2为

root=/dev/sda2,保存退出记事本,再把所有文件复制到SD卡里。

然后把U盘插在树莓派上开机

 

4、扩展U盘的空间

 

1)查看目录结构

pi@raspberrypi:~$ lsblk -o name,kname,uuid
NAME        KNAME     UUID
sda         sda       
├─sda1      sda1      
└─sda2      sda2      
mmcblk0     mmcblk0   
└─mmcblk0p1 mmcblk0p1 

2)查看文件系统大小,现在rootfs2.9G

pi@raspberrypi:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          2.9G  2.4G  334M  89% /
/dev/root       2.9G  2.4G  334M  89% /
devtmpfs        214M     0  214M   0% /dev
tmpfs            44M  236K   44M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            88M     0   88M   0% /run/shm
/dev/mmcblk0p1  117M   19M   98M  17% /boot


3)执行下面的命令(fdisk的使用方法,这里不再赘述)

pi@raspberrypi:~$ sudo fdisk /dev/sda

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (2048-60929279, default 2048): 122880
Last sector, +sectors or +size{K,M,G} (122880-60929279, default 60929279): 
Using default value 60929279

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 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)
Syncing disks.

4)重启树莓派

 

pi@raspberrypi:~$ sudo  reboot

5)执行resize2fs

pi@raspberrypi:~$ sudo resize2fs /dev/sda2
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/sda2 is now 7600800 blocks long.


6)再次查看大小,rootfs变为29G

pi@raspberrypi:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           29G  2.4G   25G   9% /
/dev/root        29G  2.4G   25G   9% /
devtmpfs        214M     0  214M   0% /dev
tmpfs            44M  236K   44M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            88M     0   88M   0% /run/shm
/dev/mmcblk0p1  117M   19M   98M  17% /boot



总结

 

花了3个小时实验成果,爱折腾挺好的,开心就好!!

猜你喜欢

转载自blog.csdn.net/u010398378/article/details/50044829