It’s been far too long since I’ve posted, I know, but shrug that’s life.

Yesterday I noticed that the screen on my Kobo Touch eReader (doesn’t get much use, so I only occasionally see it) was displaying garbage. I figured it had crashed or something so (forgetting the reset button on the back) I cracked it open to disconnect and re-connect the battery, when I did that I found this. Note that the battery connector wasn’t broken from factory, just seems to be VERY fragile, as it broke as soon as I tried to unplug it, fortunately there’s enough of it left in the socket that I was able to gently plug the contacts back in by way of a pair of tweezers, I’ll probably gob it with some hot snot later too.

Kobo Internals

Kobo Internals

When I see a micro SD slot just hanging out I find it diffucult to resist pulling out the card to see whats on it… (The eagle-eyed reader will also note that there is not one but THREE suspiciously UART-y looking headers unpopulated on the board, maybe one day I’ll get bored enough to check those out.)

So I duly disconnected the battery (and finally noticed that there was a reset button so I didn’t actually need to crack it open to begin with). Pulled the card out and shoved it in a micro-SD reader connected to a VM. Three partitions were auto-mounted.

root@kali:~# ls /media/root
KOBOeReader  recoveryfs  rootfs

KOBOeReader is what it exposes as USB Mass Storage when you plug it in, recoveryfs and rootfs are ext4 and contain standard looking linux-y directory structures, so we can assume that it boots off the SD card, which might be problematic but maybe not.

Let’s dump the partition table on that card.

Disk /dev/sdb: 1.9 GiB, 1977614336 bytes, 3862528 sectors
Disk model: Storage Device
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: 0x00000000

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1         19456  543744  524289  256M 83 Linux
/dev/sdb2        543745 1068033  524289  256M 83 Linux
/dev/sdb3       1068034 3862527 2794494  1.3G  b W95 FAT32

The good news here is that the FAT32 partition is at the end of the volume so we can probably expand it. An interesting point to note is that the first partition starts at 19456 which is quite unusual, generally partition tables start at 2048 so there’s probably some data stuffed onto the front of the SD card. Since there’s no kernel in the two ext4 partitions it’s probably safe to assume that that space is occupied by the kernel and associated paraphenalia.

If we care we can confirm with binwalk;

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
108508        0x1A7DC         CRC32 polynomial table, little endian
1048576       0x100000        uImage header, header size: 64 bytes, header CRC: 0xA006C71C, created: 2012-08-27 09:17:44, image size: 1925272 bytes, Data Address: 0x70008000, Entry Point: 0x70008000, data CRC: 0x5A27347C, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: "Linux-2.6.35.3-850-gbc67621+"
1048640       0x100040        Linux kernel ARM boot executable zImage (little-endian)
1065373       0x10419D        gzip compressed data, maximum compression, from Unix, last modified: 2012-08-27 09:17:43
9961472       0x980000        Linux EXT filesystem, rev 1.0, ext4 filesystem data, UUID=f6dcc628-036b-4f97-a146-8eb8c5cbc5cb, volume name "rootfs"
...

Pretty much as expected.

Now let’s see if we can embiggen the storage, after rummaging around in my drawer I turned up a 32GB SDHC card, wasn’t sure if that would work (media size limits in various implementations of FAT) but since I didn’t have anything smaller I figured it was worth a try.

First things, let’s grab an image of the original SD card;

root@kali:~# dd if=/dev/sdb of=KOBOInternal.img bs=32k
60352+0 records in
60352+0 records out
1977614336 bytes (2.0 GB, 1.8 GiB) copied, 141.441 s, 14.0 MB/s

Swap cards and then shove it back to the bigger card with;

dd if=KOBOInternal.img of=/dev/sdb bs=32k

Then fire up fdisk to expand the partition;

root@kali:~# fdisk /dev/sdb
...
Command (m for help): p
Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Disk model: Storage Device
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: 0x00000000

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1         19456  543744  524289  256M 83 Linux
/dev/sdb2        543745 1068033  524289  256M 83 Linux
/dev/sdb3       1068034 3862527 2794494  1.3G  b W95 FAT32

Paritition table looks fine, let’s delete that FAT32 partition and re-create it;

Command (m for help): d
Partition number (1-3, default 3): 3

Partition 3 has been deleted.

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 (2048-62333951, default 2048): 1068034
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1068034-62333951, default 62333951):

Created a new partition 3 of type 'Linux' and of size 29.2 GiB.
Partition #3 contains a vfat signature.

Do you want to remove the signature? [Y]es/[N]o: n

The important thing to note here is the “First sector” answer, by default fdisk will create a partition from sector 2048 but that’s in the reserved section of the card where the kernel resides, instead we use the first sector from the original partition table (1068034).

Command (m for help): p

Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Disk model: Storage Device
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: 0x00000000

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdb1         19456   543744   524289  256M 83 Linux
/dev/sdb2        543745  1068033   524289  256M 83 Linux
/dev/sdb3       1068034 62333951 61265918 29.2G 83 Linux

Looks good, just one final change required;

Command (m for help): t
Partition number (1-3, default 3):

Changed type of partition 'Linux' to 'W95 FAT32'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Been a while since I’ve needed to work with a FAT volume in Linux, mkfs.vfat probably sets the partition type for you, but since I was already in fdisk I figured I might as well.

Speaking of, time to create a new vfat filesystem;

root@kali:~# mkfs.vfat -n KOBOeReader /dev/sdb3
mkfs.fat 4.1 (2017-01-24)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows

Not sure if the Kobo actually cares about the volume label but figured it was best to set it as it was just in case.

Now, stick the SD card back in the Kobo, plug the battery back in, power up, et voila it (eventually) boots into the “first start” state ready to be set up again (you might be able to preserve the config by copying the contents of the “original” FAT32 volume to the “new” FAT32 volume, I didn’t care enough to try).

New SD Card Installed

New SD Card Installed