4

On ubuntu I'm using the following to create a ext3 filesystem image system.img.

dd if=/dev/zero of=./system.img bs=1000000 count=200
mkfs.ext3 ./system.img

I'm attempting to do the same on android platform. But the problem is I can't find a mkfs.ext3 binary for armv7 android. But I have mkfs.ext2 , mke2fs , tune2fs and e2fsck. So my question is, Is it possible to achieve the same result with the available binaries? If yes, how to do it?

3
  • Is your problem that you can't find a binary for Android (in which case, just make one, a statically compiled BusyBox), or that you need to rely on existing binaries (in which case, beware that different OEMs and different releases of Android come with different sets of utilities)? Commented Feb 27, 2012 at 0:46
  • @Gilles I'm making this app for only one phone, I tried to compile e2fsprogs for armv7 It cant be compiled statically, it uses dynamic. I'm fairly new to cross compiling so I didn't succeed. But It'll be nice if someone have already done it.
    – Binoy Babu
    Commented Feb 27, 2012 at 11:13
  • My bad, I checked, and BusyBox does not in fact support ext3 or ext4 (it accepts but ignores a filesystem type argument). So you'd need to make a statically compiled e2fsprogs or install a Linux in a chroot; both are possible, but overkill given that you have a solution with the tools you already have. Commented Feb 27, 2012 at 12:31

2 Answers 2

8

Actually yes. Since ext2 and ext3 are fairly similar, with the major difference being ext3 supports journalling, you should be able to:

tune2fs -j ./system.img

Which enables journalling. The conversion process is detailed here with the usual disclaimers about important information, messing with filesystems etc.

You can actually go back to ext2 too, if needed, by removing the journal. Also note - you'll need to change any auto-mount options to ext3 to actually enable use of the journal.

4
  • good one. Is not the journaling support natively available on android? I am surprised. So what is the default fs on it? Commented Feb 25, 2012 at 11:29
  • @NikhilMulley I'm... not sure. I checked my mount output and vfat shows up - I'm guessing its the default much as it is for MP3 players and other small devices. Various parts (system images by the look of it) are mounted ro, too, which makes journalling unnecessary even if fat supported it.
    – user119
    Commented Feb 25, 2012 at 11:37
  • so I would use mkfs.ext2 ./system.img && tune2fs -j ./system.img right?
    – Binoy Babu
    Commented Feb 25, 2012 at 14:25
  • yep I can conirm that it works, $ file system.img system.img: Linux rev 1.0 ext3 filesystem data, UUID=168a5dd8-26b0-423b-abdf-545c5a8a8ab0. Thanks
    – Binoy Babu
    Commented Feb 25, 2012 at 14:28
2

mkfs.ext[234] are all symlinks to mke2fs, so just run mke2fs -F -T ext3 ./system.img.

12
  • /mnt/sdcard # mke2fs -t ext3 system.img unknown option -- tBusyBox v1.19.4-cm9 bionic (2012-02-05 18:40 +0100) multi-call binary. Usage: mke2fs [-Fn] [-b BLK_SIZE] [-i INODE_RATIO] [-I INODE_SIZE] [-m RESERVED_PERCENT] [-L LABEL] BLOCKDEV [KBYTES] -b BLK_SIZE Block size, bytes -F Force -i RATIO Max number of files is filesystem_size / RATIO -I BYTES Inode size (min 128) -L LBL Volume label -m PERCENT Percent of blocks to reserve for admin -n Dry run I get this when I run that.
    – Binoy Babu
    Commented Feb 25, 2012 at 20:25
  • That's a typo in your answer. The right one is mke2fs -F -T ext3 system.img
    – Binoy Babu
    Commented Feb 25, 2012 at 20:30
  • @BinoyBabu Strange; his way should work with a standard mke2fs (other than forgetting the device); it must be something with Busybox Commented Feb 25, 2012 at 20:40
  • It didn't work, It created the fs sucessfully but the created fs turned out to be ext2. Some werid problem with busybox. $ file system.img system.img: Linux rev 1.0 ext2 filesystem data, UUID=cf32ba30-2a3f-402d-9c05-43fbcd298d11
    – Binoy Babu
    Commented Feb 25, 2012 at 20:42
  • 1
    @psusi BionyBabu has the BusyBox version of mke2fs, not the more complete one from e2fsprogs normally found on non-embedded systems. The BusyBox version only supports ext2, and most of the options it accepts are in fact silently ignored. Commented Feb 27, 2012 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .