Resize NVME root partition

Hi all,

I got myself one of those x86 mini-PC's with 128GB of NVMe storage. I installed latest OpenWRT on it according to instructions here:

Basically, booted from USB image of "openwrt-22.03.3-x86-64-generic-ext4-combined-efi.img",
then run

dd if=openwrt-21.02.0-x86-64-generic-ext4-combined.img bs=1M of=/dev/nvme0n1

Rebooted from HD and that's it. It works fine except for 100MB root which I would like to expand to full 100GB. .I tried to expand it by running:

parted -s /dev/sda resizepart 2 100%

It finished fine but after reboot I still have 100MB of storage (except my tmp which seems to have grown to 100GB).

DF output here:

root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               104788     20920     81740  20% /
tmpfs                  3998908       248   3998660   0% /tmp
/dev/nvme0n1p1           16334      5866     10468  36% /boot
/dev/nvme0n1p1           16334      5866     10468  36% /boot
tmpfs                      512         0       512   0% /dev

lsblk output:


root@OpenWrt:~# lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1       259:0    0 119.2G  0 disk
âânvme0n1p1   259:1    0    16M  0 part /boot
â                                       /boot
âânvme0n1p2   259:2    0 119.2G  0 part /
âânvme0n1p128 259:3    0   239K  0 part

What am I doing wrong?

Boot from the flash drive again, change the partition size,
using fdisk(delete, create, save), then do a resize2fs and fsck.

1 Like

This post is extremely helpful

2 Likes

OK. I got it working. I booted gparted from USB Linux, it said my partition 2 "needs fixing". I let it "fix it" and presto...100GB of root.

FAQ is not really working for NVME it seems.

There is not a whole lot special about NVME, except the device name, which isn't

but obviously /dev/nvme0n1.

This is just a typo from my side. I resized the partition with correct device. But still, it is not enough to do it, you need to fix file system for partition to be usable. It is not mentioned in FAQ so maybe it needs to be added?

If you see anything that needs to be added to or clarified in @NC1's guide, make sure to post it on the thread @d687r02j8g mentions above so it can be updated!

Indeed. :smile: I am thinking of putting out the next edition in April or maybe May (in other words, whenever I have some time to put into it). Found an interesting issue (that, upon some Googling, has apparently been around for a while), which can be easily avoided by a slightly different resizing routine.

After resizing a UEFI/SquashFS system, the boot partition fails to automount at boot (even though resizing doesn't affect it). Everything still works, routers still boot, but the boot partition is not accessible to the root user unless mounted manually.

The workaround turns out to be pretty simple: rather than edit the grub config to reflect the renaming of the root partition that happened during resizing, we can give the resized and renamed root partition its original UUID back (there are options for that in fdisk) and leave the grub config be... So I am thinking of changing to this approach and throwing out everything grub-related...

And yes, I should probably spell out more explicitly that sda is not the only naming possibility; eMMC and NVMe storage devices do go under different names... After all, I do claim to target less experienced users, for whom this would be good to know...

2 Likes