How to prepare Filesystem

There are more options: you can use the filesystem created by YOCTO, you can find a filesystem you like or you can for example boot from network. If you would like to make some heavy compilation on OpenRex or run difficult tasks, we recommend to use SSD SATA hardrive - it speeds up the things a lot. It's much faster and more reliable than an SD card.

You have more options:

Option 1: Using the filesystem created by YOCTO

To create a filesystem by YCOTO, follow the commands at: OpenRex: How to start with Software.

If you already have the images, insert an SD card or connect a SATA HDD to your host PC. Check how it’s mounted, run: ‘dmesg | tail’.
fedevel@ubuntu:~$ dmesg | tail
[622632.386947] sd 33:0:0:0: Attached scsi generic sg3 type 0
[622632.408964] sd 33:0:0:0: [sdb] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
[622632.472466] sd 33:0:0:0: [sdb] Write Protect is off
[622632.472605] sd 33:0:0:0: [sdb] Mode Sense: 03 00 00 00
[622632.481326] sd 33:0:0:0: [sdb] No Caching mode page found
[622632.481333] sd 33:0:0:0: [sdb] Assuming drive cache: write through
[622632.664902]  sdb: sdb1 sdb2
[622632.712255] sd 33:0:0:0: [sdb] Attached SCSI removable disk
[623190.995120] sdb: detected capacity change from 7948206080 to 0
[646884.988206] hrtimer: interrupt took 11392215 ns
fedevel@ubuntu:~$ 
Use the correct "/dev/" (in our case "/dev/sdb") and copy the images to the SD card / SATA drive:
umount /dev/sdb?
gunzip -c ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard.gz > ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard
sudo dd if=~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard of=/dev/sdb
umount /dev/sdb?
*Note: be careful and use the correct images e.g. QUAD vs SOLO

This is a work around of fatwrite issue (if you are not sure if you should run these commands or not, just run them ... you will not do anything wrong). Re-format the fat partition and upload the zImage + dtb again:
sudo mkfs.vfat -F16 -s 2 /dev/sdb1
# In case of "Warning: Not enough clusters ...":
# 1) run "sudo fdisk /dev/sdb" and delete all disk partitions, 
# 2) remove and then insert the SD card / SATA
# 3) run again "sudo dd if=~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard of=/dev/sdb"
# 4) remove and insert the SD card / SATA
# 5) run "sudo mkfs.vfat -F16 -s 2 /dev/sdb1", now is should pass ok
sudo mount /dev/sdb1 /media/fedevel/
sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.bin /media/fedevel/zImage
sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.dtb /media/fedevel/imx6q-openrex.dtb
sudo umount /media/fedevel
Extend root disk size to SD card / SATA drive size (default size of the root is very small):
fedevel@ubuntu:~/fsl-community-bsp/build-openrex$ sudo fdisk /dev/sdb
 
Command (m for help): p
 
Disk /dev/sdb: 7948 MB, 7948206080 bytes
4 heads, 32 sectors/track, 121280 cylinders, total 15523840 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
Disk identifier: 0xe9358ca2
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192       24575        8192    c  W95 FAT32 (LBA)
/dev/sdb2           24576      204799       90112   83  Linux
 
Command (m for help): d
Partition number (1-4): 2
 
Command (m for help): p
 
Disk /dev/sdb: 7948 MB, 7948206080 bytes
4 heads, 32 sectors/track, 121280 cylinders, total 15523840 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
Disk identifier: 0xe9358ca2
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192       24575        8192    c  W95 FAT32 (LBA)
 
Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (2048-15523839, default 2048): 24576
Last sector, +sectors or +size{K,M,G} (24576-15523839, default 15523839): 
Using default value 15523839
 
Command (m for help): p
 
Disk /dev/sdb: 7948 MB, 7948206080 bytes
4 heads, 32 sectors/track, 121280 cylinders, total 15523840 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
Disk identifier: 0xe9358ca2
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192       24575        8192    c  W95 FAT32 (LBA)
/dev/sdb2           24576    15523839     7749632   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
fedevel@ubuntu:~/fsl-community-bsp/build-openrex$
Note: As the First sector number use the same number where partition 2 originally started. In the example above, it's 24576.

Then run:
sudo e2fsck -f /dev/sdb2
# in case of error: "ext2fs_open2: Bad magic number in super-block"
# try to delete all partitions (use "sudo fdisk /dev/sdb"), remove SD card / SATA disk, plug it in again and start from "sudo dd if=~/fsl-community-bsp/..."
sudo resize2fs /dev/sdb2
umount /dev/sdb?

Option 2: Using a downloaded filesystem (supports apt-get command)

As an example we will use Jasbir's filesystem. It supports apt-get command, which is often very useful.

*Note: As an example we used the filesystem from here I.MX6 – Ubuntu 13.04 with GPU acceleration and we applied the steps described at I.MX6 Ubuntu 13.04 Debugging GPU Acceleration.

1) Prepare initial SD card / SATA drive

Use the exactly same steps as in Option 1. This will prepare a drive with two partitions. Partition 1 is a FAT partition (with zImage & DTB file), Partition 2 is an EXT2/4 partition (with filesystem)

2) Download the new Filesystem

Download a filesystem on your Linux host machine:
cd
mkdir tmp
cd tmp
wget http://www.imx6rex.com/rex-uploads/imx6rex-xubuntu-13-04-production-04-AUG-2014.tar

3) Format Partion 2 of your SD card /SATA drive

Insert your SD card / SATA drive into your Linux host machine. Check how it was recognized:
fedevel@ubuntu:~/tmp$ dmesg | tail
[1778206.451732] scsi host39: usb-storage 1-1:1.0
[1778207.454745] scsi 39:0:0:0: Direct-Access     Generic  External         2.10 PQ: 0 ANSI: 4
[1778207.455431] sd 39:0:0:0: Attached scsi generic sg3 type 0
[1778207.461571] sd 39:0:0:0: [sdb] 62533296 512-byte logical blocks: (32.0 GB/29.8 GiB)
[1778207.470661] sd 39:0:0:0: [sdb] Write Protect is off
[1778207.470666] sd 39:0:0:0: [sdb] Mode Sense: 21 00 00 00
[1778207.479848] sd 39:0:0:0: [sdb] No Caching mode page found
[1778207.479854] sd 39:0:0:0: [sdb] Assuming drive cache: write through
[1778207.505568]  sdb: sdb1 sdb2
[1778207.537545] sd 39:0:0:0: [sdb] Attached SCSI disk
fedevel@ubuntu:~/tmp$
Then reformat the Partition 2 (in our case, it is /dev/sdb2):
sudo mkfs.ext3 /dev/sdb2

4) Unpack the downloaded filesystem to partition 2 of your SD card / SATA drive

Once your new partition is formated, unpack and copy there the files of our new filesystem
sudo mount /dev/sdb2 /media/fedevel/
cd /media/fedevel/
sudo tar -pxvzf ~/tmp/imx6rex-xubuntu-13-04-production-04-AUG-2014.tar
cd
sudo umount /media/fedevel

5) Test your new filesystem

Don't forget. The root login/password is root/root. User login is ubuntu/ubuntu

Filesystem from SD card
Remove the SD card from your Linux host machine and plug it into OpenRex. Switch on OpenRex and go to uBoot. Run:
setenv bootcmd 'run bootmmc';saveenv;reset
Filesystem from SATA drive
Disconnect the SATA drive from your Linux host machine and connect it to OpenRex. Switch on OpenRex and go to uBoot. Run:
setenv bootcmd 'run bootsata';saveenv;reset
Important for Jasbir's filesystem!
Some filesytems may require additional settings in uBoot environmental variables. For example, for Jasbir's fileystem add "ip=dhcp" into uBoot:
setenv sataargs 'setenv bootargs console=${console},${baudrate} root=${sataroot} ${video_args} ip=dhcp'
setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=${mmcroot} ${video_args} ip=dhcp'
saveenv
When you boot up Jasbri's file system for very first time, you may want to run following commands:
apt-get update
apt-get upgrade
*Note: If you see any errors when running "apt-get upgrade" command, have a look at the next point: Unreliable / BAD SD cards.

Many SD Cards are not reliable. If you are using Jasbir's file system, this can be very visible. Any BAD sectors can cause errors or board crashing. Therefore, if you are observing any problems, re-copy the filesystem to SD card again and check the SD card for bad sectors:
sudo umount /dev/sdb?
sudo mkfs.ext3 /dev/sdb2 #format sd card
sudo e2fsck -fc /dev/sdb2 #check it for bad sectors
sudo mount /dev/sdb2 /media/fedevel/
cd /media/fedevel/
sudo tar -pxvzf ~/tmp/imx6rex-xubuntu-13-04-production-04-AUG-2014.tar #copy the filesystem again
#Wait until SD card activity LED stops flashing! Even the copy is finished, SD card still may be working!
cd
sudo umount /media/fedevel
sudo e2fsck -fc /dev/sdb2 #re-check the sd card for bad sectors

Option 3: Using NFS (network filesystem placed on your Linux host machine)

On your Linux host machine, mount the YOCTO filesystem image and copy the files into "nfs" directory:
cd
mkdir nfs
cd nfs
sudo mount ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.ext4 /media/fedevel/
cd /media/fedevel/
sudo cp -prv * ~/nfs/
cd
sudo umount /media/fedevel/
Edit settings of nfs server. Open "/etc/exports":
sudo nano /etc/exports
and add (you may want to adjust the location based on where you created the "nfs" directory):
/home/fedevel/nfs *(rw,no_root_squash)
Restart NFS server:
sudo service nfs-kernel-server restart
Now, you need to copy the Kernel image and dtb to tftp directory:
cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.bin /tftp/imx6/zImage-imx6q-openrex
cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.dtb /tftp/imx6/imx6q-openrex.dtb
Reset your OpenRex, go to uboot and set it to boot from network:
setenv bootcmd 'run bootnet';saveenv;reset