X86_64 Expanding root partition & filesysystem

Following procedure for Expanding root partition & filesystem .

root@OpenWrt:~# parted -l -s
Model: Samsung SSD 960 EVO 250GB (nvme)
Disk /dev/nvme0n1: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
 1      17.4kB  262kB   245kB                                      bios_grub
 2      262kB   17.0MB  16.8MB  fat16                              legacy_boot
 3      17.0MB  126MB   109MB   ext4
 4      127MB   250GB   250GB                Basic data partition  msftdata

I then issue the parted command

root@OpenWrt:~# parted -f -s /dev/nvme0n1 resizepart 3 100%
Error: Can't have overlapping partitions.
root@OpenWrt:~# ls /dev/nvme*
/dev/nvme0      /dev/nvme0n1    /dev/nvme0n1p1  /dev/nvme0n1p2  /dev/nvme0n1p3  /dev/nvme0n1p4

What am I missing here in my command? I changed the 3 to 4 and the parted command was processed, after a reboot the size appear to the same, 100MiB. Then I'm not sure about the losetup command for expanding the filesysystem.

root@OpenWrt:~# ls /dev/nvme*
/dev/nvme0      /dev/nvme0n1    /dev/nvme0n1p1  /dev/nvme0n1p2  /dev/nvme0n1p3  /dev/nvme0n1p4
root@OpenWrt:~# ls /dev/loop*
/dev/loop-control  /dev/loop1         /dev/loop3         /dev/loop5         /dev/loop7
/dev/loop0         /dev/loop2         /dev/loop4         /dev/loop6
root@OpenWrt:~# losetup /dev/loop0 /dev/nvme0n1 4> /dev/null
root@OpenWrt:~# resize2fs -f /dev/loop0
resize2fs 1.47.0 (5-Feb-2023)
resize2fs: Bad magic number in super-block while trying to open /dev/loop0
Couldn't find valid filesystem superblock.

That there is a partition that takes up the rest of the available space, the root partition has nowhere to expand to.

Also, even if the default size of ~100 MB is a bit tight to install larger packages, a root partition sized hundreds of gigabytes is fairly excessive. If you're looking to hold data it would be much more sensible to add an extra partition that will survive sysupgrades and mount it into the filesystem.

1 Like

To add an this aspect, the rootfs is rewritten -in total- by sysupgrade on each upgrade, which will take a while (even on SSD) for very large rootfs sizes (and needlessly create flash wear)..

OK, I get it now, I'll need a root & filesystem partition of reasonable size. What is a "good" size partition for lots of addons including an add blocker?

The automated script appears to be the easiest route if I start over with my image file. I'm not sure I understand the page instructions though. The page provides the script contents, then gives an example commands. Then a link is provided to download the script. Do I download the script to my router and run the command shown for my case

# Expand root partition/filesystem
sh /etc/uci-defaults/70-rootpt-resize

Will the script allow me to set the respective sizes?

That sounds like you want to resize your root partition because you can, not because you have to, at the very least not because you know you have to.

IMHO, unless you install really big packages that have no real business on an edge router anyway, the default 100-ish MB root partition size will be plenty enough. Try it on for size first, you can still enlarge it if and when you need more space.

2 Likes

Sadly there is a very unfortunate interaction between the chosen default rootfs size for x86_64 and the selection between ext4 and f2fs for the overlay (based on the overlay size). If you end up with ext4, ~100 MB is plenty - with f2fs not so much (f2fs has an absolutely huge fs overhead, especially for small partitions, leaving you with barely anything of your ~100 MB left).

But, yes, try and see would be the first approach.

--
I have no idea why f2fs has been selected for this purpose at all.

  • the fs overhead is ridiculous
  • the power loss behaviour isn't great
  • fsck support isn't great
  • on the typical storage options for x86_64 (maybe different if you think about the early 32 bit alix-like systems), f2fs doesn't really work all too well

I see my issue on this is still open, yikes.

Obviously, at some point somebody thought 100 MB is a comfortably high threshold to distinguish between f2fs for small flash sizes and ext4 for larger disks, which tbf might have actually been true before the default rootfs size was halved with 21.02.

2 Likes

Just in general.

It usually makes sense to use the overlay only for packaged things (so whatever you install via opkg/ apk) and its configuration. This usually doesn't require all that much space on an OpenWrt installation.

Things that aren't managed by the package manager are usually better suited for a dedicated (non-overlay) partition, be it data of various kinds (/srv/ comes to mind), containers/ VMs (lxc, podman, qemu, etc.), software installed by other means (think /opt/). This also avoids surprises with sysupgrades and keeping configs. blockd is made for this purpose and can mount several additional partitions where you want them to be.

You should have a reason if you think ~250 MB to ~500 MB aren't enough for the overlay (data partitions and the like are another topic). If we wouldn't be talking about f2fs, it would be pretty hard to fill up the default ~100 MB already.

Obviously this isn't a one-size-fits all solution, but you should have a reason if you want (considerably) more than that (and be aware of the downsides).

OK, I guess what I'm looking for then is commands for parted (or fdisk) to make No4 drive a ext4 partition. I'll keep the No3 drive at default 100MiB as read your comments on upgrading replacing partition files and not entire drive.

root@OpenWrt:~# parted -l -s
Model: Samsung SSD 960 EVO 250GB (nvme)
Disk /dev/nvme0n1: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
 1      17.4kB  262kB   245kB                                      bios_grub
 2      262kB   17.0MB  16.8MB  fat16                              legacy_boot
 3      17.0MB  126MB   109MB   ext4
 4      127MB   250GB   250GB                Basic data partition  msftdata

Use cfdisk and have much less pain with that process. Proper gui helps so much here.

install cfdisk, looks like I need to delete the partition first correct? then the menu should show me create "Linux File System" as an option, correct?

OK, never mind. I tried what I wrote above and it worked. "Linux filesystem" is the "Type".

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.