原创 如何在 树莓派4 上安装 openwrt !

2023-6-7 10:38 1255 6 6 分类: 软件与OS
openwrt
  • OpenWrt镜像:archive.openwrt.org/rel
  • OpenWrt工具链:archive.openwrt.org/rel
  • 版本:22.03.2
安装
At the PC:
#unzip the Image
  1. gzip -d openwrt-21.02.0-bcm27xx-bcm2708-rpi-squashfs-factory.img.gz
  2. # insert SD-card and check the name, alternatively check dmesg
  3. lsblk
  4. # copy the Image 1:1 to the SD-card
  5. sudo dd if=openwrt-21.02.0-bcm27xx-bcm2708-rpi-squashfs-factory.img of=/dev/mmcblk0 bs=1M conv=fsync

扩展文件系统
SSH INTO THE RASPBERRY PI:
  1. opkg install kmod-usb-storage kmod-usb-ohci kmod-usb-uhci e2fsprogs fdisk resize2fs
  2. fdisk /dev/mmcblk0
  3. (also see the less finicky way by @SemperEnim below):
  4. To make it clear what I entered, here the complete session of fdisk. Please note how the first sector remains unaltered:
  5. Welcome to fdisk (util-linux 2.36.1).
  6. Changes will remain in memory only, until you decide to write them.
  7. Be careful before using the write command.
  8. Command (m for help): p
  9. Disk /dev/mmcblk0: 14.99 GiB, 16096690176 bytes, 31438848 sectors
  10. Units: sectors of 1 * 512 = 512 bytes
  11. Sector size (logical/physical): 512 bytes / 512 bytes
  12. I/O size (minimum/optimal): 512 bytes / 512 bytes
  13. Disklabel type: dos
  14. Disk identifier: 0x5452574f
  15. Device Boot Start End Sectors Size Id Type
  16. /dev/mmcblk0p1 * 8192 139263 131072 64M c W95 FAT32 (LBA)
  17. /dev/mmcblk0p2 147456 360447 212992 104M 83 Linux
  18. Command (m for help): d
  19. Partition number (1,2, default 2): 2
  20. Partition 2 has been deleted.
  21. Command (m for help): n
  22. Partition type
  23. p primary (1 primary, 0 extended, 3 free)
  24. e extended (container for logical partitions)
  25. Select (default p): p
  26. Partition number (2-4, default 2): 2
  27. First sector (2048-31438847, default 2048): 147456
  28. Last sector, +/-sectors or +/-size{K,M,G,T,P} (147456-31438847, default 31438847):
  29. Created a new partition 2 of type 'Linux' and of size 14.9 GiB.
  30. Partition #2 contains a squashfs signature.
  31. Do you want to remove the signature? [Y]es/[N]o: n
  32. Command (m for help): p
  33. Disk /dev/mmcblk0: 14.99 GiB, 16096690176 bytes, 31438848 sectors
  34. Units: sectors of 1 * 512 = 512 bytes
  35. Sector size (logical/physical): 512 bytes / 512 bytes
  36. I/O size (minimum/optimal): 512 bytes / 512 bytes
  37. Disklabel type: dos
  38. Disk identifier: 0x5452574f
  39. Device Boot Start End Sectors Size Id Type
  40. /dev/mmcblk0p1 * 8192 139263 131072 64M c W95 FAT32 (LBA)
  41. /dev/mmcblk0p2 147456 31438847 31291392 14.9G 83 Linux
  42. Command (m for help): w
  43. The partition table has been altered.
  44. Syncing disks.

REBOOT AND LOG IN AGAIN
The device usage and sizes are now as follows (my SD-card is 16 GB in size). The size needs still needs to be adjusted:
  1. df -h
  2. Filesystem Size Used Available Use% Mounted on
  3. /dev/root 4.3M 4.3M 0 100% /rom
  4. tmpfs 217.9M 52.0K 217.9M 0% /tmp
  5. /dev/loop0 92.7M 2.6M 83.1M 3% /overlay
  6. overlayfs:/overlay 92.7M 2.6M 83.1M 3% /
  7. /dev/mmcblk0p1 63.9M 17.3M 46.6M 27% /boot
  8. tmpfs 512.0K 0 512.0K 0% /dev

Actually this was easier than expected, simply use resize2fs:
  1. opkg update && opkg install resize2fs
  2. resize2fs /dev/loop0
  3. resize2fs 1.45.6 (20-Mar-2020)
  4. Filesystem at /dev/loop0 is mounted on /overlay; on-line resizing required
  5. old_desc_blocks = 1, new_desc_blocks = 120
  6. The filesystem on /dev/loop0 is now 15641408 (1k) blocks long.

AND NOW DF -H RETURNS THE ADJUSTED SIZE:
  1. df -h
  2. Filesystem Size Used Available Use% Mounted on
  3. /dev/root 4.3M 4.3M 0 100% /rom
  4. tmpfs 217.9M 56.0K 217.9M 0% /tmp
  5. /dev/loop0 14.5G 3.1M 13.9G 0% /overlay
  6. overlayfs:/overlay 14.5G 3.1M 13.9G 0% /
  7. /dev/mmcblk0p1 63.9M 17.3M 46.6M 27% /boot
  8. tmpfs 512.0K 0 512.0K 0% /dev
WX:上海晶珩电子

作者: 树莓派开发者, 来源:面包板社区

链接: https://mbb.eet-china.com/blog/uid-me-4034091.html

版权声明:本文为博主原创,未经本人允许,禁止转载!

文章评论0条评论)

登录后参与讨论
我要评论
0
6
关闭 站长推荐上一条 /2 下一条