Let's see how filesystem data should be aligned and what block size was chosen for stock filesystems :
Code:
[root@kindle root]# grep Align /etc/upstart/userstore
# Align fs data to 4MB boundary
# Align FAT fs data on 4 MB boundary to improve eMMC performance
Code:
[root@kindle root]# grep cluster /var/local/system/mntus.params
# Use 8k cluster size for better write performance
Code:
[root@kindle root]# for i in 1 2 3; do tune2fs -l /dev/mmcblk0p$i | grep 'Block size:'; done
Block size: 1024
Block size: 1024
Block size: 1024
I think, our ext3 filesystem should be aligned on 4MB (4194304 = 4 * 1024 * 1024) and have block of 1024 bytes.
Let's find offset (in bytes) of start of our new free space (
UPD: read
this beforehand). Offset of
/dev/mmcblk0p4 (in sectors) could be read with
cat /sys/class/block/mmcblk0p4/start. Offset of
/dev/mmcblk0p4p2 (in sectors, relative to start of
/dev/mmcblk0p4) could be found in output of
sfdisk -uS -l --force /dev/mmcblk0p4. Sector size is 512 bytes.
Code:
[root@kindle root]# expr 512 \* \( \
> $(sfdisk -uS -l --force /dev/mmcblk0p4 | awk '/mmcblk0p4p2/ {print $2}') \
> \+ $(cat /sys/class/block/mmcblk0p4/start) \
> \)
1574969344
This offset isn't aligned on 4MB boundary. To find new, aligned offset, we should divide found offset on 4MB, round the answer to most closest larger integer and multiply rounded answer on 4MB. In Python 3.x:
Code:
>>> round(1574969344 / 4194304) * 4194304
1577058304
And then let's convert found absolute offset (from start of eMMC device) to relative offset (from start of
/dev/mmcblk0p4) required for
losetup:
Code:
[root@kindle root]# expr 1577058304 - 512 \* $(cat /sys/class/block/mmcblk0p4/start)
1075838976
Userstore parition is mounted to
/dev/loop/0. All other loop devices are
free (
UPD: not quite right, read
here). So let's select
/dev/loop/1 as device for our new parition, mount free space as loopback device and format it (output is skipped):
Code:
[root@kindle root]# losetup -o 1075838976 /dev/loop/1 /dev/mmcblk0p4
[root@kindle root]# mkfs.ext3 -b 1024 /dev/loop/1
[root@kindle root]# losetup -d /dev/loop/1
To mount our new filesystem:
Code:
[root@kindle root]# losetup -o 1075838976 /dev/loop/1 /dev/mmcblk0p4
[root@kindle root]# mount /dev/loop/1 /somewhere
To unmount:
Code:
[root@kindle root]# umount /somewhere
[root@kindle root]# losetup -d /dev/loop/1