Loading...
 

Creating Ubuntu filesystem

Among one of file systems supported by MACCHIATObin is the Ubuntu file system. To flash Ubuntu on the MACCHIATObin board, you can either build the file system manually or download a prebuilt SD card image.

Prebuilt image


On our Software page under Ubuntu SD card image you can obtain a prebuilt Ubuntu 16.04.3 LTS image (ubuntu-xenial-mcbin_u-boot_sd.img_.gz). The image is configured to boot directly from the SD card.

The image requires a micro SD card or USB flash drive with 4 GB capacity or more.

After downloading it, flash it on a Linux machine with the following command (replace sdx with your device label):

$ gunzip -c ubuntu-xenial-mcbin_u-boot_sd.img_.gz | sudo dd of=/dev/sdx


Alternatively, extract the image first using gzip and flash with dd or some other tool which you prefer.

 Bigger medium size

In case your removable storage medium is larger than 4 GB, resize the partition either with GParted or manually to use all available space. To do it manually:


1. If mounted, first unmount the partition (replace sdxX with your partition label):


$ sudo umount /dev/sdxX


2. Check for free space:


$ sudo parted /dev/sdx print free
Model: Generic STORAGE DEVICE (scsi)
Disk /dev/sdx: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        32.3kB  10.5MB  10.5MB           Free Space
 1      10.5MB  45.1MB  34.6MB  primary  fat16
 2      45.1MB  3880MB  3835MB  primary  ext3
        3880MB  15.9GB  12.1GB           Free Space


3. Increase the desired partition to the desired size, e.g. to increase the second partition to use all the available space (15.9GB in our case):


$ sudo parted /dev/sdx resizepart 2 15.9GB


4. Check the filesystem with:


$ sudo e2fsck -f -y -v -C 0 /dev/sdxX


5. Lastly, resize the filesystem


$ sudo resize2fs -p /dev/sdxX

Unplug the micro SD card from your Linux machine and plug it into the MACCHIATObin board. Relocate the jumpers (or DIP switches on revisions 1.2 and older) on the MACCHIATObin board to boot from the SD card as instructed in MACCHIATObin Interface list, section Boot Selection. Lastly, plug in the board and you should see Ubuntu booting directly from the SD card.

Building from Source


This section will show how to download and create an Ubuntu file system image for MACCHIATObin. Note that you will need a Linux machine to follow the instructions on this page.

We begin by downloading a copy of Ubuntu Operating System (16.04.3 LTS). Make a directory where you will download the iso image (for example /home/mcbin/ubuntu/):

mcbin@buildserver:~$ mkdir ubuntu
mcbin@buildserver:~$ cd ubuntu
mcbin@buildserver:~/ubuntu$ wget http://cdimage.ubuntu.com/releases/16.04.3/release/ubuntu-16.04.3-server-arm64.iso

 
After the iso image has been downloaded, make a new directory to mount the iso image:

mcbin@buildserver:~/ubuntu$ mkdir temp
mcbin@buildserver:~/ubuntu$ sudo mount -o loop ubuntu-16.04.3-server-arm64.iso temp/


The Ubuntu file system is available at the install sub-directory named filesystem.squashfs:

mcbin@buildserver:~/ubuntu$ ls temp/install/
filesystem.manifest  filesystem.squashfs      hwe-initrd.gz  hwe-vmlinuz  netboot
filesystem.size      filesystem.squashfs.gpg  hwe-netboot    initrd.gz    vmlinuz


Next step you'll need to unsquash the file system into a directory named rootfs:

mcbin@buildserver:~/ubuntu$ sudo unsquashfs -d rootfs/ temp/install/filesystem.squashfs
mcbin@buildserver:~/ubuntu$ ls rootfs/
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var


Now we have a Ubuntu file system in the sub-directory rootfs. To remove the password required for root login, you'll need to modify the file rootfs/etc/passwd on its first line to remove the 'x' in between root: and :0. Please check the example of this line after the modification:

mcbin@buildserver:~/ubuntu/rootfs/etc$ cat passwd
root::0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
[truncated output]


The root file system you have created here is able to run on the MACCHIATObin board. Lastly, we also need to copy the kernel binary and dtb file over to the Micro SD card. Kernel binary and dtb file are available by either following instructions at Build from source - Kernel or they can be downloaded from the Software page, under Linux kernel. Either way, copy the Image kernel binary and the armada-8040-mcbin.dtb dtb file to the boot directory:

mcbin@buildserver:/ubuntu$ sudo cp ~/kernel/4.4.52/arch/arm64/boot/Image rootfs/boot/
mcbin@buildserver:/ubuntu$ sudo cp ~/kernel/4.4.52/arch/arm64/boot/dts/marvell/armada-8040-mcbin.dtb rootfs/boot/


Now we will zip the folder up to later extract it to a removable media such as micro SD card or USB stick:

mcbin@buildserver:~/ubuntu$ sudo tar -cjvf rootfs.tar.bz2 -C rootfs/ .


This root file system with kernel binary and dtb file included can also be downloaded from our Software page, under Ubuntu.

Please refer to the page Boot from MicroSD card/USB stick - Ubuntu on how to extract the root file system on a removable media for MACCHIATObin.