OpenWrt disk expansion scheme and practice
Opening
explain
step
-
Turn off OpenWrt. It is recommended to take a snapshot of the virtual machine to prevent time wasting due to explosive reinstallation. Then add a disk. I will directly add a 5G hard disk for testing, and then turn on the OpenWrt power supply. Install the necessary tools. Opkg update # Update Opkg install fdisk # The installation tool, if any, does not need to be executed Execute command fdisk -l , confirm your disk number root@OpenWrt :~# fdisk -l Disk /dev/loop0: 214.06 MiB, 224460800 bytes, 438400 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 GPT PMBR size mismatch (1065503 != 1065534) will be corrected by write. The backup GPT table is corrupt, but the primary appears OK, so that will be used. The backup GPT table is not on the end of the device. Disk /dev/sda: 520.28 MiB, 545553920 bytes, 1065535 sectors Disk model: VMware Virtual S 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: gpt Disk identifier: 8E2DA755-0E50-0BD5-63C5-B1DC8E810D00 Device Start End Sectors Size Type /dev/sda1 512 41471 40960 20M Linux filesystem /dev/sda2 41472 1065471 1024000 500M Linux filesystem /dev/sda128 34 511 478 239K BIOS boot Partition table entries are not in disk order. Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes You can see the number here /dev/sdb It's the 5G hard disk I just added use fdisk /dev/sdb Use the default values for all new partitions. Finally, enter w to save the partition table and exit. Follow the prompts. root@OpenWrt :~# fdisk /dev/sdb Welcome to fdisk (util-linux 2.38). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xbd5366e9. 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): 1 First sector (2048-10485759, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759): Created a new partition 1 of type 'Linux' and of size 5 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. use mkfs.ext4 /dev/sdb The file system formats the partition. root@OpenWrt :~# mkfs.ext4 /dev/sdb mke2fs 1.46.5 (30-Dec-2021) Found a dos partition table in /dev/sdb Proceed anyway? (y,N) y Creating filesystem with 1310720 4k blocks and 327680 inodes Filesystem UUID: 752b4263-c24e-46cb-8e35-7e991898e6f6 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done Mount the disk after the partition and copy the original files in the/overlay directory to this directory. root@OpenWrt :~# mkdir - p/mnt/sdb # Create the mount directory root@OpenWrt :~# mount/dev/sdb/mnt/sdb # # mount root@OpenWrt :~# ls/mnt/sdb # Check whether the mount is successful, as long as there is a lost+found file lost+found root@OpenWrt :~# cp - r/overlay/*/mnt/sdb # # Copy files root@OpenWrt :/mnt/sdb # ls/mnt/sdb # # The following files are just right etc lost+found upper work Next, go to the background of the OpenWrt system and find the mount point - click the Build Configuration Button, and then pull to the bottom mount point to see the disk we just mounted, and then click Modify.
Click Modify to enter the following interface, and make sure that enabling this mount point is checked. Select the mount point Use as external overlay , save&Apply, and then restart OpenWrt. If the operation is correct, checking the free space again is the space we set.
extend
Reference article
Two Schemes for OpenWrt Storage Space Expansion
Overlay expansion of OpenWrt disks under virtual machine
Soft Route Exploration Journey III: Expand openwrt overlay Updated on March 30