OpenWrt soft routing space expansion

Preliminary knowledge

OpenWrt system firmware classification

  1. EXT4 firmware

    The firmware package name contains ext4keywords, you can refer to 固件分类关键字示意图the picture. This type of firmware hard disk space is divided as follows:

    image-20230127104021941

  2. SQUASHFS firmware

    Firmware package names contain squashfskeywords, also refer to 固件分类关键字示意图pictures. This type of firmware hard disk space is divided as follows:

    image-20230127104108093

Schematic diagram of firmware classification keywords:

image-20230127103239081

EXT4 firmware expansion method

New partition expansion

Create a new partition and mount the root directory to the new partition; (recommended)

Create a new partition in the unformatted area, then copy all the contents of the original system file partition to the new partition, and finally change the default mount point of the system root directory to the new partition.

image-20230127105251868

Steps

  1. View current disk information

    fdisk -l
    

    image-20230127110105047

  2. create new partition

    # 注意fdisk后参数是磁盘名称,是要根据实际情况填写
    fdisk /dev/mmcblk0
    # 输入p查看分区情况
    p
    # 输入n创建新分区
    n
    # 选择p,primary分区类型
    p
    # 选择分区序号,根据实际情况填写了,一般默认即可
    # 输入分区起始位置,需要大于红色下划线数字
    # 输入要创建的分区大小,例如要创建3GB,可以输入+3G即可
    # 最后输入w写入磁盘
    

    image-20230127110647824

    image-20230127111021791

  3. Check partition effect

    fdisk -l
    

    image-20230127111348514

  4. format partition

    # mkfs.ext4后参数为新分区名称
    mkfs.ext4 /dev/mmcblk0p3
    
  5. Log in to openwrt on the web page, select the system mount point, and select Add

    image-20230127111549019

  6. Select the newly created partition and mount it to the root directory, save and apply
    image-20230127115350975

  7. The command to copy 根目录准备the region is as follows

    mkdir -p /tmp/introot
    mkdir -p /tmp/extroot
    mount --bind / /tmp/introot
    # mount命令后参数为新分区,该博客中的例子为/dev/mmcblk0p3
    mount /dev/sda1 /tmp/extroot
    tar -C /tmp/introot -cvf - . | tar -C /tmp/extroot -xf -
    umount /tmp/introot
    umount /tmp/extroot
    
  8. Paste and execute the above command on the command line

  9. If the firmware contains efithe keyword, you need to refer to EFI引导固件的额外操作the chapter to perform additional steps (optional: only if the firmware contains the efi keyword)

  10. Restart the soft router

    reboot
    

direct expansion

Directly expand the original root partition, as shown in the figure below:

image-20230127105057618

Steps

  1. Delete the old partition (you need to remember the disk start position of the old partition, as shown in the underlined position), and create a new partition

    # 注意fdisk后参数是磁盘名称,是要根据实际情况填写
    fdisk /dev/mmcblk0
    # 删除第2个分区,输入d
    d
    # 选择第2个分区,根据实际情况填写
    2
    # 输入n创建新分区
    n
    # 选择primary分区类型
    p
    # 分区编号选择2,一般默认即可
    2
    # 输入分区起始位置,该位置要与删除分区的起始位置相同
    # 输入创建分区大小,例如+3G
    # 不要删除标识!不要删除标识!不要删除标识!选择n!
    n
    # 输入w写入磁盘
    w
    

    image-20230127113027636

    image-20230127113141262

  2. Check partition effect

    fdisk -l
    

    image-20230127113227559

  3. Set loop device

    losetup /dev/loop0 /dev/mmcblk0p2
    
  4. expand disk space

    resize2fs -f /dev/loop0
    
  5. If the firmware contains efithe keyword, you need to refer to EFI引导固件的额外操作the chapter to perform additional steps (optional: only if the firmware contains the efi keyword)

  6. Restart the soft router

    reboot
    

SQUASHFS firmware expansion method

New partition expansion

Since the SQUASHFS firmware will automatically create rom space after installation, it can be expanded directly.

direct expansion

The direct expansion method is the same as the ext4 firmware expansion method, you can refer to the above steps. Similarly, x86 device efi firmware needs to be distinguished. Special operations are also mentioned above, you can refer to them.

Extra Actions for EFI Boot Firmware

  1. View partition ID

    blkid
    

    image-20230127114244639

  2. modify system boot

    # 编辑grub.cf文件
    vi /boot/grub/grub.cfg
    # 将下划线的两个分区ID修改成新分区的UUID即可
    

    image-20230127114608438

  3. save document

    # 输入:wq即可,或者Shift + ZZ快捷键保存均可
    

reference

  1. OpenWrt's space expansion problem can be solved directly!

Guess you like

Origin blog.csdn.net/ls0111/article/details/128769859