This guide will let us create a big Linux partition which we can use for Linux chroots. The aim is to end up with something like this
A 10GB ext2 partition.
The Kobo onboard storage is formatted as FAT32 which has a lot of limitations, especially since it doesn't support Linux file permissions. It would be great if we could format it as ext2 but I expect this would cause problems with Nickel. The normal workaround is to create an image file which we can mount
This solves the problem, except you need to know the size in advance. Since I'm mostly using my Kobo for development/hacking, I'd happily give almost all the SD space to Linux. But FAT32 only supports files up to 4GB so we can't create a single huge image.
Enter RAID.
It sounds a bit crazy but we can create a bunch of 4GB image files and combine them all together using RAID. Then we can put everything Linux related inside (e.g. I have an Alpine chroot and a Debian chroot both inside this partition). Here's how to do it.
1. Download RAID kernel modules from here https://github.com/jmacindoe/kobo-kernel-modules/. I've only compiled them for the latest two devices. If you get this working on older devices please add the modules to the repo in a PR!
2. Create the images. Normally in RAID0 all the images need to be the same size, but we'll use Linear mode, so you can make the images any sizes.
3. Set up an Alpine Linux chroot if you haven't already https://www.mobileread.com/forums/sh...d.php?t=336175. This is needed to bootstrap the RAID array, so we'll need to keep this even once we have our big partition. So probably set it up to only take up a very small amount of space. Now in the chroot run
4. Now back outside the chroot run
5. Boom! It's a gigantic ext2 partition. Next time you reboot you can get it back with these commands
Code:
df -H
Filesystem Size Used Available Use% Mounted on
/dev/md0 10.0G 1.0G 9.0G 10% /mnt/data
The Kobo onboard storage is formatted as FAT32 which has a lot of limitations, especially since it doesn't support Linux file permissions. It would be great if we could format it as ext2 but I expect this would cause problems with Nickel. The normal workaround is to create an image file which we can mount
Code:
dd bs=1M count=2000 if=/dev/zero of=/mnt/onboard/linux.img
mke2fs -F /mnt/onboard/linux.img
mount /mnt/onboard/linux.img /mnt/data
Enter RAID.
It sounds a bit crazy but we can create a bunch of 4GB image files and combine them all together using RAID. Then we can put everything Linux related inside (e.g. I have an Alpine chroot and a Debian chroot both inside this partition). Here's how to do it.
1. Download RAID kernel modules from here https://github.com/jmacindoe/kobo-kernel-modules/. I've only compiled them for the latest two devices. If you get this working on older devices please add the modules to the repo in a PR!
Code:
insmod md-mod.ko
insmod linear.ko
Code:
dd bs=1M count=4000 if=/dev/zero of=/mnt/onboard/data1.img
dd bs=1M count=4000 if=/dev/zero of=/mnt/onboard/data2.img
dd bs=1M count=2000 if=/dev/zero of=/mnt/onboard/data3.img
losetup /dev/loop1 /mnt/onboard/data1.img
losetup /dev/loop2 /mnt/onboard/data2.img
losetup /dev/loop3 /mnt/onboard/data3.img
Code:
pkg add mdadm
mdadm --create /dev/md0 --level=linear --raid-devices=3 /dev/loop1 /dev/loop2 /dev/loop3
Code:
mke2fs -F /dev/md0
mkdir /mnt/data
mount /dev/md0 /mnt/data
Code:
insmod md-mod.ko
insmod linear.ko
losetup /dev/loop1 /mnt/onboard/data1.img
losetup /dev/loop2 /mnt/onboard/data2.img
losetup /dev/loop3 /mnt/onboard/data3.img
# Update this command with your Alpine chroot directory
chroot /mnt/user/ mdadm --assemble --scan
mount /dev/md0 /mnt/data