Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .img file that uses the yaffs2 filesystem (an Android partition image) that I want to mount. I can't seem to do it with the mount command. How can I do this? I'm using Ubuntu 12.04.

Also, I don't want to extract it (I know how to do that using unyaffs). I want to mount it.

share|improve this question
Is it a boot.img or system.img file? – mfisch Dec 30 '12 at 4:33
@mfisch system.img file. boot.img isn't yaffs2. And I don't want to extract it, I want to mount it. – gsingh2011 Dec 30 '12 at 5:12

Ubuntu currently does not support YAFFS2. There is a feature request to package the YAFFS2 kernel module, which would provide mount support for the filesystem: [needs-packaging] yaffs2.

Kernel support

Thus, currently, if you need mount support you will have to compile it yourself. The YAFFS website has instructions for compiling a Linux kernel with YAFFS support (using Precise 32-bit):

The Ubuntu wiki also has general information on compiling your own kernel.

Extract and rebuild

Alternatively, try using yaffs2utils to extract and rebuild the image.

Note that due to a bug, you must specify the --yaffs-ecclayout option or it will silently fail. So to extract, try something like

git clone
cd yaffs2utils && make && cd ..
./yaffs2utils/unyaffs2 --yaffs-ecclayout system.img tempdir

Theoretically you can also rebuild the image using mkyaffs2, but I couldn't get it to work (the result wasn't bootable).


I found a program, Yaffey, that lets you edit a YAFFS2 image using a GUI:


While the home page says it's Windows-only, with a trivial change it compiles on Ubuntu Precise. To do so:

  1. Install dependencies: sudo apt-get install qt-sdk
  2. hg clone
  3. In the file yaffey/yaffs2/yaffs_guts.h, change the line

    typedef unsigned loff_t;


    #include <stdlib.h>
  4. Compile: cd yaffey && qmake && make
  5. Run ./yaffey.
  6. Open your image, make your desired changes, and save (it refuses to overwrite; you have to select a different filename).

When I tried it, the resulting image booted successfully in the Android emulator.

share|improve this answer
Thanks for recommending Yaffey and providing details of the patch needed to compile it on Linux! – qris Sep 9 '13 at 15:09
How to build on Mac: – dnl Aug 12 '15 at 4:39

It's a sparse filesystem, I think you'll need to unsparsify it first using simg2img. You can download it as part of ext4_utils which I have posted on here for when I used it on the Nexus7 images. Unpack the image and mount as follows:


./simg2img rootfs.img rootfs.ext4


sudo mount -o loop rootfs.ext4 tmpmnt/

Once you've unpacked it and hacked it, you rebuild it using make_ext4fs. You should probably read the blog entry I made about hacking the Nexus7 image as it covers most of this and the script it references may be useful.

share|improve this answer
Thanks for the answer but I don't think it will work. simg2img only outputs "Bad Magic". Googling told me that this happens when you use it on anything that's not a compressed ext4 image, and yaffs2 isn't a compressed ext4 image. – gsingh2011 Dec 30 '12 at 6:09
Sorry I completely missed that, did you try the unyaffs2 tool?… – mfisch Dec 30 '12 at 16:16
Yea, I was able to extract it with unyaffs, but since that's not really mounting I can't accept this answer. I guess it's not currently possible. Btw, you have an interesting blog :) – gsingh2011 Dec 30 '12 at 22:55
I've also read, but not tried, that you can compile yaffs2 support into your kernel and just mount it like that. Maybe the simplest solution here is to mount it on an Android device? – mfisch Dec 31 '12 at 1:35

I thought I would update this with Ubuntu 13. I had to make some changes to get it to compile that I hope will help others.

  1. Edit and under

    QT += core gui


    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

  2. Edit MainWindow.cpp and search/replace:

    setResizeMode with setSectionResizeMode

  3. Edit YaffTreeView.cpp and under

    #include <QDebug>


    #include <QMimeData>

You should then be able to compile.

share|improve this answer
I have created a gist with all the changes from this thread - compiling successfully ubuntu 13 – Thiago F Macedo Jun 11 '14 at 23:40

After following nospam & Mechanical Snail's steps I also had to make this change in main.cpp


#include <QtGui/QApplication>


#include <QtWidgets/QApplication>

Then it finally compiled

share|improve this answer

You can use the suggestions in this post to built it Building YAFFS2 file system in Ubuntu/Linux

share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Stormvirux Jul 25 '14 at 5:56
Welcome to askubuntu. It is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. You can edit you post clicking on the edit link below your answer. – Hastur Jul 25 '14 at 5:59

Your Answer


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.