0

I'm trying to mount the Android nand image provided by Project Sandcastle (a project that can run Android 10 on an iPhone 7). I'm trying to mount this disk image so that I can edit the boot.img file that is presumably in this image. Here's some information about the file:

$ file nand
nand: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x0,4,4), startsector 1, 255 sectors; partition 2 : ID=0x7, start-CHS (0x0,4,5), end-CHS (0x0,8,8), startsector 256, 256 sectors
$ sudo fdisk -lu nand
Disk nand: 3.5 GiB, 3269459968 bytes, 6385664 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: 0x00000000

Device Boot Start   End Sectors   Size Id Type
nand1           1   255     255 127.5K ee GPT
nand2         256   511     256   128K  7 HPFS/NTFS/exFAT

I've tried to mount this in macOS, but it asked for a filesystem and ext4 and msdos didn't work. So I made an Ubuntu live USB and tried these commands and got this output:

$ sudo mkdir /android
$ sudo mount -o loop,rw,offset=512 nand /android
mount: /android: wrong fs type, bad option, bad superblock on /dev/loop6, missing codepage or helper program, or other error.

So I tried to give nand a file extension, I thought that maybe it wasn't recognizing it as a file because there was no extension.

$ mv nand android.image
$ sudo mount -o loop,rw,offset=512 android.image /android
NTFS signature is missing.
Failed to mount '/dev/loop6': Invalid argument
The device '/dev/loop6' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

I tried mounting the other partition with offset=$((512*256)) but the same output occurred. I also tried it with no offset, but the same output occurred. Finally, I tried using ro instead of rw, but again, the same output occurred. I'm stuck and I don't know what to do next. The gzipped nand image can be found at this link. I'd really appreciate any help anyone can offer.

1 Answer 1

1

Your fdisk output indicates that this is not a valid partition table: nand2 occupies just 128KB which is simply not enough for an NTFS partition. I've used 7-zip (you can probably use p7zip available natively) running in Wine to open the image: it contains two "partitions" and a huge file which is an ext4 partition.

Don't ask my how but I've found the offset for this ext4 partition. You can mount it with:

mount -o loop,offset=3145728,ro nand /mnt/sandcastle

It cannot be mounted read write because Android 10 implements a new ext4 feature called "shared_blocks" which hasn't yet found its way into mainline.

4
  • Thank you so much for your answer! I got it opened in 7zip. However, when I try to mount it, I get the same wrong fs type, bad option... etc. error. Any ideas? Also, if I get this successfully mounted, can I write to it? If not, how could I do that? Aug 12, 2020 at 21:43
  • In Fedora 32 I mounted it successfully read/write, so you should be able to do that as well. Not sure if MacOS is capable of doing that. Aug 13, 2020 at 11:11
  • Hmm, I made a Fedora 32 Workstation installation, and tried your command, prefixed with sudo. Still the same error as above. All I did to create /mnt/sandcastle was sudo mkdir /mnt/sandcastle. Is there something else I need to do to the directory to make it a valid mount point? Aug 13, 2020 at 16:46
  • My bad, it can be mounted only read-only, i.e. mount -o loop,offset=3145728,ro nand /mnt/sandcastle. When I try to mount it read-write I get this error message: couldn't mount RDWR because of unsupported optional features (4000) Looks like Android 10 enables some ext4 features which Linux itself doesn't understand: google.com/… I've tried to find a way to fix this error but I've been unsuccessful so far. Android implements a new ext4 feature called "shared_blocks" which is not implemented. Aug 13, 2020 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.