Fix resize partition in NVME drive
I posted about buying a NVME SSD (Crucial E100 480GB), in a USB3 caddy, early February:
- Statically-linked sg_vpd utility compiled in OE — February 06, 2025
The purpose of this purchase was for testing TRIM support.
Yesterday, decided to test writing the EasyOS .img file to it, to test that it will boot OK. I didn't expect any problem, as I have other SSDs in USB caddies and they boot OK -- but, they are SATA drives.
The 'easy-6.6.3-amd64.img' file has two partitions, a 7MiB fat12 esp boot partition, and a 921MiB ext4 partition. The latter is the working-partition, and at first bootup, the 'init' script in the initrd resizes that to fill the drive. The resizing failed.
I don't fully understand, but the gist of the problem is that the MBR and partition-table in the .img file think in terms of 512 byte sector size, whereas the drive has 4096 bytes sector size. This is not normally a problem, but now it has become a problem. I don't know if this problem is with all NVME drives, or just this one. The SSD is plugged in now, as /dev/sdc (after fixing, and successfully resizing, the second partition):
# fdisk -u -l /dev/sdc
Disk /dev/sdc: 447.13 GiB, 480103981056 bytes, 937703088 sectors
Disk model: 0SSD8
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0xd0a7c76b
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 16383 14336 7M ef EFI (FAT-12/16/32)
/dev/sdc2 16384 937703087 937686704 447.1G 83 Linux
The 'init' script in the initrd tries to resize the second partition, where WKG_PARTNUM=2 and Wstart=16384:
echo -e "d\n${WKG_PARTNUM}\nn\np\n${WKG_PARTNUM}\n${Wstart}\n\nw" | fdisk -u /dev/${WKG_DRV} > /dev/null 2>&1
However, fdisk reports an error, that "16384" is invalid; it wants a bigger number for starting sector (I think, from memory, 65536, which totally mystifies me). However, I found that forcing sector size to be 512 bytes, works:
echo -e "d\n${WKG_PARTNUM}\nn\np\n${WKG_PARTNUM}\n${Wstart}\n\nN\nw" | fdisk -u -b 512 /dev/${WKG_DRV} > /part2resize.log 2>&1
The partition then does resize and it seems to be working OK.
I don't want to change the .img file to have a GPT, as want it to work on very old computers. This hack fix seems OK.
Here is the github commit:
https://github.com/bkauler/woofq/commit/b92f389fb6eb1e423cfd56d591afcc703d571467
Got a list of things to fix in Easy already; will work through
them gradually, in between my much greater interest right now, the
new trike project.
Tags: easy