[HOWTO] Resizing root partition on x86 (March 2023 edition)

I have another method that worked for me. I pulled the hard drive out of the Openwrt machine and connected it to a usb to sata adpater. I then plugged that into a Debian 11 machine and edited the partitions with G-parted.

This works, too. If you have the right adapter. I've done this on ext4 drives, but not on SquashFS drives. On my Mint machine, gparted recognizes SquashFS partitions, but doesn't want to do anything that involves writing with them. It's entirely possible that this can be overcome with the right software, but I have not researched this.

Also, on some x86 units (for example, Sophos XG 85[w] and 86[w]), the boot drive is an eMMC module soldered onto the motherboard. In those cases, the removal of the boot drive is simply not an option...

FYI, i build/adapt a fire and forget script (just execute and after reboot system is fine gain) for the ext4 version:

###March 2023 Edition, see https://forum.openwrt.org/t/howto-resizing-root-partition-on-x86-march-2023-edition/153398
BOOT="$(sed -n -e "\|\s/boot\s.*$|{s///p;q}" /etc/mtab)"
###Custom Part
OFFS="$(fdisk ${DISK} -l -o device,start | sed -n -e "\|^${ROOT}\s*|s///p")"
echo -e "p\nd\n${ROOTPART}\nn\np\n${ROOTPART}\n${OFFS}\n\nn\np\nw" | fdisk ${DISK}
###March 2023 Edition, see https://forum.openwrt.org/t/howto-resizing-root-partition-on-x86-march-2023-edition/153398
LOOP="$(losetup -f)"
losetup ${LOOP} ${ROOT}
resize2fs -f ${LOOP}

As side note, after https://git.openwrt.org/7b7edd25a571 one can use ImageBuilder to prepare image with desired rootfs size.


I wish, auc could handle that… :smiley:

1 Like

when i press N i get this

Partition number (2-127, default 2): Command (m for help): d
Partition number (1,2,128, default 128): 2

Partition 2 has been deleted.

Command (m for help): n
Partition number (2-127, default 2):

what should i do here?

Keep reading the HOWTO. The answer is just a few lines down:

Partition number (2-4, default 2): [[2]]

I think the best solution would be to:

1 - create a new partition with the rest of the disk
2 - use this partition to extend openwrt as it is possible to do using an external USB key

this would allow you not to touch the original firmware
this could be automatic whatever the size of the disk