after DD the x64 combined ext4 image to a new SSD I used parted to check partition alignment on the SSD and parted reported the partitions are not aligned.
I know how to re-align the partitions by booting up GPARTED but is there a way I can do it from inside openwrt ?
Is it possible that future x64 openwrt images align themselves to 2048 instead of 512 in future?
GNU Parted 3.6
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all] display the partition table, or available devices, or free space, or all
found partitions
quit exit program
rescue START END rescue a lost partition near START and END
resizepart NUMBER END resize partition NUMBER
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
type NUMBER TYPE-ID or TYPE-UUID type set TYPE-ID or TYPE-UUID of partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
(parted) print all
Model: ATA NT-256 2242 (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 262kB 17.0MB 16.8MB primary ext2 boot
2 17.3MB 126MB 109MB primary ext4
(parted) align-check opt 1
1 not aligned: 512s % 2048s != 0s
(parted) align-check opt 2
2 not aligned: 33792s % 2048s != 0s
(parted)
just discovered that FDISK aligns the next primary partition automatically without any further actions. This means I can just extroot into partion 3 and have root properly aligned.
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (33280-500118191, default 247808): 247808
Last sector, +/-sectors or +/-size{K,M,G,T,P} (247808-500118191, default 500118191):
Created a new partition 3 of type 'Linux' and of size 238.4 GiB.
Command (m for help): p
Disk /dev/sda: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: NT-256 2242
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe9bad6fa
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 512 33279 32768 16M 83 Linux
/dev/sda2 33792 246783 212992 104M 83 Linux
/dev/sda3 247808 500118191 499870384 238.4G 83 Linux
Command (m for help): w
The partition table has been altered.
Syncing disks.
You can see that FDISK started partition 3 at 247808 ( i.e. instead of naturally starting directly after partition 2 at 246783). To confirm this I opened up a spreadsheet and typed in the formula:
cell A1 type in "=246783 + 2" which results in 246785 which would be the natural starting sector of partition 3
cell B1 type in "=A1/1024" which results in a misaligned sector of 241.0009766
in cell C1 type in "=mod(B1,1)"
highlight cells A1 and B1 and C1 then use the cell drag handle to copy the formulas down until you get to see a modulus = "0" in column C. The corresponding value in column A will be the aligned sector which in this case 247808 which is what FDISK returns.
You can modify target/linux/x86/image/Makefile as follows but it renders the system unbootable. When I inspect the output of fdisk -l /dev/nvme0n1 it does not contain a BIOS boot partition.
that modification is correct for grub to boot correctly but I believe but will also need to specify DD to begin writing at 1M or the IMG file itself will need to specify this so that GRUB can locate the boot partition. I am not sure if DD has this option in which case it must be specified inside the IMG file.
root@fuj-s920:~# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/sda: 31277232 sectors, 14.9 GiB
Model: Innodisk DEMSR-
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): E9BAD6FA-7D1C-4DD0-C46B-4B84E666DF00
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 31277198
Partitions will be aligned on 2-sector boundaries
Total free space is 22362255 sectors (10.7 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 526335 256.0 MiB 8300 Linux Filesystem
2 526336 8914943 4.0 GiB 8300 Linux Filesystem
128 34 2047 1007.0 KiB EF02 EFI Legacy BIOS Boot
Command (? for help):
Non-efi images add an extra 256 (I think) sector gap between partitions, but efi images are supposedly legacy bootable.
I tried that but it did not give a bootable system. Just stuck at the BIOS on my machine. Did yours actually boot (I assume so given the gdisk output you generated).