樹莓派4 U盤引導(dǎo)啟動
一、硬件鏡像準(zhǔn)備
1、準(zhǔn)備Micro SD卡(8 or 16GB) 和 USB3.0 U盤1個(大于8G)
2、準(zhǔn)備鏡像
樹莓派官方Raspbian系統(tǒng)眉踱,官網(wǎng)免費下載:點這里
3、準(zhǔn)備燒錄工具
目前balenaEtcher支持各個平臺霜威,推薦使用給這個燒錄(下載地址:點這里)
4谈喳、燒錄
解壓樹莓派鏡像得到2020-02-13-raspbian-buster.img文件,打開燒錄工具選擇image戈泼、分別選擇2個存儲設(shè)備進(jìn)行2次燒錄婿禽,完成后得到2個啟動盤。
二大猛、樹莓派4設(shè)置
1扭倾、將sd卡和U盤分別接到設(shè)備上如圖
2、用SSH連接 或者 樹莓派終端登陸
3挽绩、運行blkid查看設(shè)備信息膛壹,如下面,可以看到新版樹莓派4 SD卡和外置存儲器PARTUUID相同琼牧,所以不需要修改cmdline.txt文件
pi@raspberrypi:~ $ sudo lsblk -o name,label,partuuid
NAME LABEL PARTUUID
sda
├─sda1 boot ea7d04d6-01
└─sda2 rootfs ea7d04d6-02
mmcblk0
├─mmcblk0p1 boot ea7d04d6-01
└─mmcblk0p2 rootfs ea7d04d6-02
4恢筝、運行如下命令刪除sd卡中rootfs分區(qū)
pi@raspberrypi:~ $ sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): w
The partition table has been altered.
Failed to remove partition 2 from system: Device or resource busy
The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
pi@raspberrypi:~ $ sudo reboot
然后輸入‘d’,再選擇2巨坊,刪除第二分區(qū)之后撬槽,輸入‘w’。保存退出之后重啟樹莓派趾撵。
5侄柔、刪除U盤中boot分區(qū)(也可以調(diào)過)
當(dāng)系統(tǒng)啟動之后執(zhí)行以下命令:
pi@raspberrypi:~ $ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1,2, default 2): 1
Partition 1 has been deleted.
Command (m for help): w
The partition table has been altered.
Failed to remove partition 1 from system: Device or resource busy
The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
pi@raspberrypi:~ $ sudo reboot
然后輸入‘d’,再選擇1占调,刪除第一分區(qū)之后暂题,輸入‘w’。保存退出之后重啟樹莓派究珊。
pi@raspberrypi:~ $ sudo blkid
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="6341-C9E5" TYPE="vfat" PARTUUID="ea7d04d6-01"
/dev/sda2: LABEL="rootfs" UUID="80571af6-21c9-48a0-9df5-cffb60cf79af" TYPE="ext4" PARTUUID="ea7d04d6-02"
/dev/mmcblk0: PTUUID="ea7d04d6" PTTYPE="dos"
此時內(nèi)存卡中只有個啟動分區(qū)薪者,外置儲存設(shè)備中只有rootfs系統(tǒng)分區(qū)了。
6剿涮、調(diào)整文件系統(tǒng)大小
pi@raspberrypi:~ $ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
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, 30765219840 bytes, 60088320 sectors
Disk model: Ultra Fit
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: 0xea7d04d6
Device Boot Start End Sectors Size Id Type
/dev/sda2 532480 7397375 6864896 3.3G 83 Linux
Command (m for help): q
記錄下 532480 起始 sector 后面resize時候使用言津。
接下來調(diào)整分區(qū)大小,步驟如下:
pi@raspberrypi:~ $ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Selected partition 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 2
First sector (2048-60088319, default 2048): 532480
Last sector, +/-sectors or +/-size{K,M,G,T,P} (532480-60088319, default 60088319):
Created a new partition 2 of type 'Linux' and of size 28.4 GiB.
Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: n
Command (m for help): w
The partition table has been altered.
Syncing disks.
pi@raspberrypi:~ $ sudo reboot
重啟后連接設(shè)備取试,查看分區(qū)大小
pi@raspberrypi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 3.2G 2.9G 98M 97% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.6M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 54M 199M 22% /boot
tmpfs 391M 0 391M 0% /run/user/1000
看到/dev/root分區(qū)大小還沒有重新調(diào)整悬槽,接下來使用resize2fs 命令來調(diào)整
pi@raspberrypi:~ $ sudo resize2fs /dev/sda2
resize2fs 1.44.5 (15-Dec-2018)
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 7444480 (4k) blocks long.
pi@raspberrypi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 28G 2.9G 24G 11% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.6M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 54M 199M 22% /boot
tmpfs 391M 0 391M 0% /run/user/1000
經(jīng)過上面的步驟 可以看到/dev/root分區(qū)大小已經(jīng)調(diào)整過來了。
到此樹莓派4可以通過usb的rootfs啟動瞬浓,速度大大提升初婆!