Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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)? –  Gilles Feb 27 '12 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 Feb 27 '12 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. –  Gilles Feb 27 '12 at 12:31

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
    
good one. Is not the journaling support natively available on android? I am surprised. So what is the default fs on it? –  Nikhil Mulley Feb 25 '12 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. –  Ninefingers Feb 25 '12 at 11:37
    
so I would use mkfs.ext2 ./system.img && tune2fs -j ./system.img right? –  Binoy Babu Feb 25 '12 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 Feb 25 '12 at 14:28

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

share|improve this answer
    
/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 Feb 25 '12 at 20:25
    
That's a typo in your answer. The right one is mke2fs -F -T ext3 system.img –  Binoy Babu Feb 25 '12 at 20:30
    
@BinoyBabu Strange; his way should work with a standard mke2fs (other than forgetting the device); it must be something with Busybox –  Michael Mrozek Feb 25 '12 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 Feb 25 '12 at 20:42
    
@BinoyBabu, why don't you just create the image on your computer with real mke2fs and then transfer it to the phone? –  psusi Feb 25 '12 at 23:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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