HELLO OPENWRT
This note record some openwrt compile experience.
Build step by step
Step 1
# Download and update the sources
git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git pull
# Select a specific code revision
git branch -a
git tag
git checkout v21.02.3
# Update the feeds
./scripts/feeds update -a
./scripts/feeds install -a
Step 2
wget [this_repo/.config] -O .config
Step 3
make menuconfig
Load config file
make defconfig
# Need science network maybe
make download
Step 4
First time recommend:
make -j1 -V=sc
Second time and for on:
make -j(nproc) -V=s
Trouble check
When some package compile error, then rebuilding single package:
make package/utils/jsonpath/{clean,compile} V=s
Install openwrt firmware
Step 1
Use this package 👇
openwrt-21.02.3-x86-64-generic-ext4-combined.img.gz
Wirte *.img.gz file to usb storage device
# Unpack image
gunzip openwrt-*.img.gz
# Identify disk (to replace sdX in the following command below)
lsblk
# Write image
dd if=openwrt-21.02.0-x86-64-generic-ext4-combined.img bs=1M of=/dev/sdX
Step 2
Start usb storage device system, set side router.
# set static ip
uci set network.lan.ipaddr="192.168.2.1"
uci commit network
/etc/init.d/network restart
Step 3
Test network is ok
ping baidu.com
Step 4 (Optional)
Resizing partitions
- Install fdisk.
- Use fdisk to show the partitions.
- Write down the starting sector address of /dev/sda2 (which is the root partition).
- Use fdisk to delete the partition 2 (which is sda2), don’t write the changes to disk yet.
- Use fdisk to create a new partition 2, choose/type the starting sector address you wrote down earlier (as by default it will try to place it somewhere else), and leave the default end sector address (this will mean the partition will now use all available space).
- Write the partition table changes to disk. It may complain about partition signatures already present, write n to NOT remove the partition signature to proceed.
ex:
Welcome to fdisk (util-linux 2.32).
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: 7.2 GiB, 7751073792 bytes, 15138816 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: 0xcbad8a62
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 512 33279 32768 16M 83 Linux
/dev/sda2 33792 246783 212992 104M 83 Linux
Command (m for help): d
Partition number (1,2, default 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):
Partition number (2-4, default 2):
First sector (33280-15138815, default 34816): 33792
Last sector, +sectors or +size{K,M,G,T,P} (33792-15138815, default 15138815):
Created a new partition 2 of type 'Linux' and of size 7.2 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.
Note for format usb storage
ps: fomat filesystem
mkfs.ext4 /dev/sdXY
Step 5 (Optional)
Resizing filesystem
Resize Ext4 rootfs for ext4-combined.img.gz:
opkg update
opkg install losetup resize2fs
BOOT="$(sed -n -e "/\s\/boot\s.*$/{s///p;q}" /etc/mtab)"
DISK="${BOOT%%[0-9]*}"
PART="$((${BOOT##*[^0-9]}+1))"
ROOT="${DISK}${PART}"
LOOP="$(losetup -f)"
losetup ${LOOP} ${ROOT}
fsck.ext4 -y ${LOOP}
resize2fs ${LOOP}
reboot
留下评论