How to create a filesystem


Thank you very much to Sam Nazarko. Sam created a script which can generate a fresh file system for the iMX6 Rex.

On this page you will find step-by-step instructions how to prepare a fresh file system for iMX6 Rex. I have tested Ubuntu 14.04 – trusty with Kernel 3.15. Please note, some file systems will not work with older Kernels (such Kernel 3.05).

Setup a host computer

You may need to run the Sam’s script on the latest Ubuntu. (I have tested the script on Ubuntu 14.10). You can install it into a virtual machine, e.g. VMware Player. Go to and download for example this image (for 64bit PC):

Once you install the host, login, create an imx6rex directory and create a new file inside it:

mkdir imx6rex
cd imx6rex

Go to the Sam’s github, click to the RAW button, Copy & Paste the script into your file. Here is an example of the script (but always get the latest one from the github):


# i.MX6 filesystem builder for R. Feranec
# Sam Nazarko - 20141028

echo -e "i.MX6 filesystem generator"
echo -e "For best results run this on the latest Ubuntu build"


function checkPackage()
	dpkg -l | grep -q $1
	if [ $? == 0 ]
		echo "Package ${1} is already installed"
		echo "Package ${1} is not installed. We need to grab it"
		if [ "${hasRefreshed}" -ne 1 ]
			echo "Need to update apt cache"
			echo "Please be patient"
			apt-get update > /dev/null 2>&1
		apt-get -y install ${1}

checkPackage "debootstrap"
checkPackage "qemu-user-static"


echo -e "Please specify the distribution you would like to build. Examples:\ntrusty (Ubuntu 14.04)\nprecise (Ubuntu 12.04)\nwheezy (Debian 7.0)"
read dist


echo -e "What packages would you like to install? Examples:\napache2\nopenssh-server\n\nFor a list of packages, or to properly determine the package name, Google 'packagename in ${dist}'\n\nType 'END' when you have selected all your packages"
while [ "$packagename" != "END" ]
	read packagename
	if [ "$packagename" != "END" ]
		echo -e "Added package ${packagename}"
		packages+="${packagename} "


if [ -d rootfs ]
	echo -e "Deleting old root filesystem"
echo -e "Debootstrapping"
debootstrap --foreign --arch=armhf --include="${packages}" ${dist} rootfs


echo -e "Using emulator to finish install"
cp /usr/bin/qemu-arm-static rootfs/usr/bin
chroot rootfs/ /debootstrap/debootstrap --second-stage

echo -e "Please set a root password"
chroot rootfs/ passwd

# Clean up ARM

rm rootfs/usr/bin/qemu-arm-static


echo -e "Enabling network support on eth0"
echo "
# The loopback network interface
auto lo eth0
iface lo inet loopback

# The primary network interface
iface eth0 inet dhcp" > rootfs/etc/network/interfaces

echo -e "Configuring hostname, what would you like?"
read hostname
echo -e ${hostname} > rootfs/etc/hostname

echo -e "Creating tarball"
cd rootfs
tar -czvf ${TAR}.tar.gz *
md5sum ${TAR}.tar.gz > ${TAR}.md5
mv ${TAR}* ../
cd ../


echo -e "Build completed successfully"

Save the file. Now change the permissions:

sudo chmod +x

Generate filesystem

Run the script:

sudo ./

You will see this:
Select for example ‘trusty’ (or you can try jessie), so write:


In the next step, you can choose additional packages you would like to install:
You can try ‘openssh-server’, so write:


Now wait …..

and then choose your password:

..wait again ….

and write down a hostname (e.g. imx6rex)

Your filesystem is now ready:

Check the directory. You should see something like this:

fedevel@ubuntu:~/imx6rex$ ls -la
total 102012
drwxrwxr-x  3 fedevel fedevel      4096 Nov 15 10:28 .
drwxr-xr-x 24 fedevel fedevel      4096 Nov 15 10:20 ..
-rwxrwxrwx  1 fedevel fedevel      2208 Nov 15 10:12
-rw-r--r--  1 root    root           62 Nov 15 10:28 root-filesystem-imx6.md5
-rw-r--r--  1 root    root    104435687 Nov 15 10:28 root-filesystem-imx6.tar.gz
drwxr-xr-x 20 root    root         4096 Nov 15 10:28 rootfs

Copy the filesystem

You can now directly copy the file system to your SD card, SATA Hardrive or USB. As an example, we will use an USB memory stick.

Plug in your USB memory stick into your host. Check what /dev was assigned to it:

fedevel@ubuntu:~/imx6rex$ dmesg | tail
[96486.527939] sd 36:0:0:0: [sdb] 30869504 512-byte logical blocks: (15.8 GB/14.7 GiB)
[96486.532256] sd 36:0:0:0: [sdb] Write Protect is off
[96486.532296] sd 36:0:0:0: [sdb] Mode Sense: 23 00 00 00
[96486.535752] sd 36:0:0:0: [sdb] Write cache: disabled, read cache: disabled, doesn't support DPO or FUA
[96486.557992]  sdb: sdb1
[96486.572646] sd 36:0:0:0: [sdb] Attached SCSI removable disk
[96487.654261] EXT4-fs (sdb1): mounting ext3 file system using the ext4 subsystem
[96487.672825] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)

Check how it is mounted:

/dev/sdb1 on /media/fedevel/16999e5b-9518-4f5a-a05d-36a191d0128d type ext3 (rw,nodev,nosuid,uhelper=udisks2)

Our USB is using /dev/sdb. Let’s umount it:

sudo umount /media/fedevel/16999e5b-9518-4f5a-a05d-36a191d0128d

Now, we will delete the existing partition and create a new one. The commands below will destroy all the data on the USB memory stick:

fedevel@ubuntu:~/imx6rex$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.25.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-30869503, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-30869503, default 30869503):

Created a new partition 1 of type 'Linux' and of size 14.7 GiB.

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


Format the USB:

fedevel@ubuntu:~/imx6rex$ sudo mkfs.ext3 /dev/sdb1
mke2fs 1.42.10 (18-May-2014)
/dev/sdb1 contains a ext3 file system
        last mounted on / on Sat Nov 15 10:39:24 2014
Proceed anyway? (y,n) y
Creating filesystem with 3858432 4k blocks and 964768 inodes
Filesystem UUID: fe37cd2a-7105-43f4-b516-5b1417ece3d3
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


Mount the empty USB:

sudo mkdir /media/usb
sudo mount /dev/sdb1 /media/usb/

Copy the filesystem to the USB memory stick

cd /media/usb
sudo tar -pxvzf ~/imx6rex/root-filesystem-imx6.tar.gz

Umount the USB and remove it from your host computer:

sudo umount /media/usb

Test the new filesystem

Plug in the USB memory stick with your new filesystem into your iMX6 Rex board and you can test it for example with this Kernel 3.15 uImage. Do not forget, you will need to have the uImage on your SD card. Once your Kernel boots up, it will mount and use the USB (/dev/sda1) as the filesystem. You should see the login prompt on your HDMI monitor.

Connect an USB keyboard and have a fun :)