Resizing partitions with automated script for x86 hardware different for NVMe

I installed OpenWRT on a x86_64 device yesterday. I followed the guideline on this wiki article.

I'm using a NVMe SSD in a small mini pc. The cheapest NVMe SSD is a lot larger than the *efi.img is built so I wanted to increase the size of the 2nd partition on the NVMe device. The naming scheme of NVMe devices is a bit different compared to USB sticks or other SATA devices where the automated root partition and resizing scripts are not compatible with how NVMe devices are detected on OpenWRT.

Where a SATA or USB storage device usually is known to the OS by /dev/sda for example as the first drive, the NVMe storage devices are known as /dev/nvme0n1 for the first device.

Where a partition on a SATA or USB storage device is usually indicated just by a number on the device, for example "2" on /dev/sda2, on a NVMe storage device this number is prefixed by a "p", like so: /dev/nvme0n1p2.

I'm not a "regular expression" guy, but I believe these 2 lines in the scripts are perfectly fine for USB and SATA storage devices, but don't apply wel for NVMe storage devices:

DISK="${BOOT%%[0-9]*}"
PART="$((${BOOT##*[^0-9]}+1))"

I also don't have a wiki account, don't really need one since there are far more knowledgeable folks out there than me :sweat_smile:

I'm also a x86 user, when i install openwrt from ubuntu/manjaro/etc to SSD it's always easy resize it with graphical interface, no need for scripts or something else, gui resize in ubuntu is even faster than typing those strings))

As per @Sentenzo 's post, you can do this from an Ubuntu Live image even if you only run Windows.

If your boot environment is Linux, just call the Linux utility sudo gparted - Graphical PARTition EDitor.

Alternatively, run the Ubuntu live image and call gparted from it. Be very careful that you are NOT operating on your NVMe with gparted until you know what you're doing. I highly suggest you practice with an old small capacity USB to understand it's power. It recognizes Windows FS's as well as ext, and NVMe storage devices among many others, so you can set multiple boot partitions from the same drive.

The utility is forgiving - Just don't apply until you're happy with the partition layout.

I managed to resize the partition using the USB stick with OpenWRT flashed on it. I got it resized by deleting the partition and creating a new one based in the same starting point. The filesystem will stay intact, you can resize it later on. I wanted to address that for those that want to do this in a x86 device with an NVMe SSD can’t use that script I mentioned in my first post.