It appears the default partitions Manjaro creates on the eMMC are not aligned. This is really bad for performance! Here's how to check this and fix it without re-installing or erasing eMMC. You do need a boot from a bootable sdcard to do the final step.
First, check the alignment:
The start of the root partition should be aligned to a multiple of 4kB, if not more. That means the start sector (500001) should be a multiple of 8 (8 sectors of 512 bytes is 4 kB). It's not even a multiple of two!
The process to fix this will be shrink the boot partition, p1, to be a bit smaller and then move the root partition down so it's aligned.
Here's the process for shrinking the boot partition. It can be done when booted from eMMC since the boot partition isn't actively used and can be unmounted.
There's a tool called fatresize that should be able to shrink it in place, but it doesn't work. Since it's small, I just make a copy and reflash it.
As we can see in post #1, the current size of the boot partition is 437501 sectors. I want to shrink that by 289 sectors, which will then align the root partition to 4MB. The mkfs.vfat command wants the size in kilobytes, which are two sectors.
Now we want to loopback mount this filesystem and copy the contents of /boot into it.
Ok, now we'll umount both filesystems and copy the new image over the existing fs. If anything goes wrong while copying then you're in trouble but should still be able to recover from SD since this doesn't wipe out the eMMC u-boot. But it only takes a couple second to copy the data.
And now for the final step, we'll shrink the size of the boot partition table entry to be 289 sectors smaller.
And now reboot so the new table takes effect. It can't be re-read because the root partition is still mounted from /dev/mmcblk2p2 and you can't unmount that. If you were booted from SD then the table re-read will have worked. You might want reboot from eMMC anyway just to be sure it all still works.
First, check the alignment:
Quote:$ sudo sfdisk -l /dev/mmcblk2
Disk /dev/mmcblk2: 58.24 GiB, 62537072640 bytes, 122142720 sectors
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: 0x87129214
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 62500 500000 437501 213.6M c W95 FAT32 (LBA)
/dev/mmcblk2p2 500001 122142719 121642719 58G 83 Linux
The start of the root partition should be aligned to a multiple of 4kB, if not more. That means the start sector (500001) should be a multiple of 8 (8 sectors of 512 bytes is 4 kB). It's not even a multiple of two!
The process to fix this will be shrink the boot partition, p1, to be a bit smaller and then move the root partition down so it's aligned.
Here's the process for shrinking the boot partition. It can be done when booted from eMMC since the boot partition isn't actively used and can be unmounted.
There's a tool called fatresize that should be able to shrink it in place, but it doesn't work. Since it's small, I just make a copy and reflash it.
As we can see in post #1, the current size of the boot partition is 437501 sectors. I want to shrink that by 289 sectors, which will then align the root partition to 4MB. The mkfs.vfat command wants the size in kilobytes, which are two sectors.
Quote:$ mkfs.vfat -v -n BOOT_MNJRO -C new-root.img $(( (437501 - 289) / 2 ))
mkfs.fat 4.1 (2017-01-24)
new-root.img has 64 heads and 32 sectors per track,
hidden sectors 0x0000;
logical sector size is 512,
using 0xf8 media descriptor, with 437212 sectors;
drive number 0x80;
filesystem has 2 16-bit FATs and 8 sectors per cluster.
FAT size is 216 sectors, and provides 54592 clusters.
There are 8 reserved sectors.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is 7d933d98, volume label BOOT_MNJRO .
Now we want to loopback mount this filesystem and copy the contents of /boot into it.
Quote:$ sudo mount -o loop new-root.img /mnt
# Check that the filesystems are mounted as expected and the new one is empty.
$ df /boot /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk2p1 218512 40296 178216 19% /boot
/dev/loop0 218368 0 218368 0% /mnt
# Copy all the files
$ sudo cp -a /boot/. /mnt
# Check fs is filled as expected
# It wouldn't hurt to ls -l /mnt too
$ df /boot /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk2p1 218512 40296 178216 19% /boot
/dev/loop0 218368 40296 178072 19% /mnt
Ok, now we'll umount both filesystems and copy the new image over the existing fs. If anything goes wrong while copying then you're in trouble but should still be able to recover from SD since this doesn't wipe out the eMMC u-boot. But it only takes a couple second to copy the data.
Quote:$ sudo umount /dev/mmcblk2p1
$ sudo umount /mnt
# This is the command that writes the partition. Be sure you have mmcblk2p1 here!
$ sudo dd if=new-root.img of=/dev/mmcblk2p1
And now for the final step, we'll shrink the size of the boot partition table entry to be 289 sectors smaller.
Quote:
$ echo ",-289" | sudo sfdisk --no-reread -N 1 /dev/mmcblk2
Disk /dev/mmcblk2: 58.24 GiB, 62537072640 bytes, 122142720 sectors
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: 0x87129214
Old situation:
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 62500 500000 437501 213.6M c W95 FAT32 (LBA)
/dev/mmcblk2p2 500001 122142719 121642719 58G 83 Linux
/dev/mmcblk2p1:
New situation:
Disklabel type: dos
Disk identifier: 0x87129214
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 62500 499711 437212 213.5M c W95 FAT32 (LBA)
/dev/mmcblk2p2 500001 122142719 121642719 58G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
Syncing disks.
And now reboot so the new table takes effect. It can't be re-read because the root partition is still mounted from /dev/mmcblk2p2 and you can't unmount that. If you were booted from SD then the table re-read will have worked. You might want reboot from eMMC anyway just to be sure it all still works.