Loading...
 

Boot from removable storage - Ubuntu

Ubuntu 14.04


Here we will show you how to transfer kernel images and Ubuntu (14.04 or 16.04) filesystem made in Creating Ubuntu filesystem to either SD card or USB device.

SD card


Next we need to transfer the contents of the fs/ directory to an SD card, but before that we need to prepare our SD card. Some of the steps are similar to steps in Boot from removable storage - Buildroot, but let us go through them again anyway.

Insert the microSD card in your local Linux machine (use a USB microSD card reader if your laptop does not have a microSD card slot) and you should see the microSD card listed most probably as /dev/sd* device (or /dev/mmcblk0*) so make sure to check with lsblk:

user@laptop:/$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238,5G  0 disk 
├─sda1   8:1    0   487M  0 part /boot/efi
├─sda2   8:2    0 234,1G  0 part /
└─sda3   8:3    0   3,9G  0 part [SWAP]
sdb      8:16   1   3,7G  0 disk 
└─sdb1   8:17   1   3,7G  0 part


Our microSD card is here listed as /dev/sdb but it is not empty. Since we will be formatting our SD card, we want to clear everything from it first (of course, backup content from your SD card before this). We clear it with:

user@laptop:/$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=100


and check again with lsblk that everything was cleared:

user@laptop:/$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238,5G  0 disk 
├─sda1   8:1    0   487M  0 part /boot/efi
├─sda2   8:2    0 234,1G  0 part /
└─sda3   8:3    0   3,9G  0 part [SWAP]
sdb      8:16   1   3,7G  0 disk


Now we will create a new partition (sdb1) on the empty SD card:

user@laptop:/$ (echo n; echo p; echo 1; echo ''; echo ''; echo w) | sudo fdisk /dev/sdb
[Example output]
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x0c01515c.

Command (m for help): Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): Partition number (1-4, default 1): First sector (2048-7744511, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-7744511, default 7744511): 
Created a new partition 1 of type 'Linux' and of size 3,7 GiB.

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


and format it as EXT4 with:

user@laptop:/$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 489472 1k blocks and 122400 inodes
Filesystem UUID: 938b353e-b156-48fd-afc0-626668f6d95a
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

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


Next we mount this partition on our local Linux machine (e.g. we will mount it to /mnt/sdcard):

user@laptop:/$ sudo mkdir -p /mnt/sdcard
user@laptop:/$ sudo mount /dev/sdb1 /mnt/sdcard


Head into the mounted directory and there copy everything from the fs/ directory:

user@laptop:/$ cd /mnt/sdcard
user@laptop:/mnt/sdcard$ sudo cp -a ~/ubuntu/fs/* .


Our SD card is now ready and contains the necessary images and Ubuntu file system. Exit the mounted directory and unmount it from your local machine with:

user@laptop:/mnt/sdcard$ cd
user@laptop:/$ sudo umount /mnt/sdcard

Setting U-Boot parameters


Unplug the SD card from your local machine and plug it into the SD card slot on the ESPRESSObin, plug the power adapter and connect to the board using micro USB cable and serial connection as described in Quick User Guide, section Serial Connection.

For the ESPRESSObin to boot Ubuntu file system and images have placed on the SD card, we must configure U-Boot parameters to do so. When the boot starts, hit any key to stop autoboot and get to the Marvell U-Boot prompt:

Hit any key to stop autoboot:
Marvell>> 
Marvell>>


Check that our SD card has necessary files we have transferred using ext4ls command:

Marvell>> ext4ls mmc 0:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 bin
<DIR>       4096 boot
<DIR>       4096 dev
<DIR>       4096 etc
<DIR>       4096 home
<DIR>       4096 lib
<DIR>       4096 media
<DIR>       4096 mnt
<DIR>       4096 opt
<DIR>       4096 proc
<DIR>       4096 root
<DIR>       4096 run
<DIR>       4096 sbin
<DIR>       4096 srv
<DIR>       4096 sys
<DIR>       4096 tmp
<DIR>       4096 usr
<DIR>       4096 var
Marvell>> ext4ls mmc 0:1 boot
<DIR>       4096 .
<DIR>       4096 ..
            8175 armada-3720-community.dtb
        13189120 Image


There are only a few variables we need to set (other needed variables should be set by default) in order to boot from microSD card. First, set proper image and device tree path and name if they are not already set:

Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-3720-community.dtb


Next we setup the boot command by changing the bootmmc variable. We will use this variable to boot the microSD card:

Marvell>> setenv bootmmc 'mmc dev 0; ext4load mmc 0:1 $kernel_addr $image_name;ext4load mmc 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk0p1 rw rootwait; booti $kernel_addr - $fdt_addr'


Be careful to set the root path above to point to where you have extracted the Ubuntu file system (in our case we copied it to the first partition).

After this we can save the variables we have set so far:

Marvell>> save


or setup the bootcmd variable for the ESPRESSObin to automatically boot with the desired variables:

Marvell>> setenv bootcmd 'mmc dev 0; ext4load mmc 0:1 $kernel_addr $image_name;ext4load mmc 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk0p1 rw rootwait; booti $kernel_addr - $fdt_addr'


Finally we boot up the ESPRESSObin with run bootmmc:

Marvell>> run bootmmc
switch to partitions #0, OK
mmc0 is current device
12670464 bytes read in 4125 ms (2.9 MiB/s)
8107 bytes read in 69 ms (114.3 KiB/s)
## Flattened Device Tree blob at 01000000
   Booting using the fdt blob at 0x1000000
   Using Device Tree in place at 0000000001000000, end 0000000001004faa

Starting kernel ...

...

Ubuntu 14.04 LTS localhost.localdomain ttyMV0

localhost login: root (automatic login)

Ubuntu 14.04 LTS localhost.localdomain ttyMV0

localhost login: root (automatic login)

Welcome to Ubuntu 14.04 LTS (GNU/Linux 4.4.8-armada-17.02.1-g7aeb724 aarch64)

 * Documentation:  https://help.ubuntu.com/

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~#


View an example bootlog here.

USB device


Here we will cover how to transfer necessary Ubuntu files to USB device and boot from it. Aside from few changes, booting Ubuntu from USB is quite similar to booting from microSD card, but we will go through the whole process again below.

Download and configure Ubuntu file system as shown above. Insert the USB device in your local Linux machine and run lsblk. Your USB device is probably listed as /dev/sd* device although this may vary:

user@laptop:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238,5G 0 disk
├─sda1 8:1 0 487M 0 part /boot/efi
├─sda2 8:2 0 234,1G 0 part /
└─sda3 8:3 0 3,9G 0 part [SWAP]
sdb 8:16 1 7,5G 0 disk
└─sdb1 8:17 1 7,5G 0 part


We can see that our USB device is recognized as /dev/sdb/. Since we will be formatting our USB device we want to clear everything from it first (of course, backup content if necessary). We clear it with:

user@laptop:~$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=100
[sudo] password for user:
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 23,3945 s, 4,5 MB/s


and check again with lsblk that everything was cleared:

user@laptop:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238,5G 0 disk
├─sda1 8:1 0 487M 0 part /boot/efi
├─sda2 8:2 0 234,1G 0 part /
└─sda3 8:3 0 3,9G 0 part [SWAP]
sdb 8:16 1 7,5G 0 disk


Now we will create a new partition (sdb1) on the empty USB device:

user@laptop:~$ (echo n; echo p; echo 1; echo ''; echo ''; echo w) | sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
[...]
Created a new partition 1 of type 'Linux' and of size 7,5 GiB.

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


and format it as EXT4 with:

user@laptop:~$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 1953536 4k blocks and 488640 inodes
Filesystem UUID: adf3cb6b-9391-40ae-a277-8732d66159b7
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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


Next we mount this partition on our local Linux machine (e.g. we will mount it to /mnt/usb):

user@laptop:~$ sudo mkdir -p /mnt/usb
user@laptop:~$ sudo mount /dev/sdb1 /mnt/usb


Head into the mounted directory and there we copy everything from the fs/ subdirectory:

user@laptop:~$ cd /mnt/usb
user@laptop:/mnt/usb$ sudo cp -a ~/ubuntu/fs/* .


When we now list the directory we can see that the root file system is now on our USB device:

user@laptop:/mnt/usb$ ls
bin   dev  home  lost+found  mnt  proc  run   srv  tmp  var
boot  etc  lib   media       opt  root  sbin  sys  usr


Our USB device is now ready and contains the necessary images and file system. Exit the mounted directory and unmount it from your local machine with:

user@laptop:/mnt/usb$ cd
user@laptop:/$ sudo umount /mnt/usb

 

Setting U-Boot parameters


Unplug the USB device from your local machine and plug it into an USB port on the ESPRESSObin, plug the power adapter and connect to the board via micro USB cable and serial connection as described in Quick User Guide, section Serial Connection.

For the ESPRESSObin to boot the images we have placed on the USB device, we must configure valid U-Boot parameters to do so. When the boot starts, hit any key to stop autoboot and get to the Marvell U-Boot prompt:

Hit any key to stop autoboot:
Marvell>>
Marvell>>


First we can check that the necessary files are on our USB device with:

Marvell>> usb start
(Re)start USB...
USB0:   Register 2000104 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
Marvell>> ext4ls usb 0:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 etc
<DIR>       4096 usr
<DIR>       4096 tmp
<DIR>       4096 proc
<DIR>       4096 media
<DIR>       4096 bin
<DIR>       4096 home
<DIR>       4096 sys
<DIR>       4096 var
<DIR>       4096 opt
<DIR>       4096 mnt
<DIR>       4096 srv
<DIR>       4096 run
<DIR>       4096 root
<DIR>       4096 lib
<DIR>       4096 sbin
<DIR>       4096 boot
<DIR>       4096 dev
Marvell>> ext4ls usb 0:1 boot
<DIR>       4096 .
<DIR>       4096 ..
        12358656 Image
            8175 armada-3720-community.dtb


using printenv we can list currently set U-Boot variables. If changed, here we need to set up correct values for image names:

Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-3720-community.dtb


and set bootusb variable which we will use to boot from USB device

Marvell>> setenv bootusb 'usb start;ext4load usb 0:1 $kernel_addr $image_name;ext4load usb 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/sda1 rw rootwait; booti $kernel_addr - $fdt_addr'


and lastly we boot by issuing run bootusb:

Marvell>> run bootusb
(Re)start USB...
USB0:   Register 2000104 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
12507136 bytes read in 813 ms (14.7 MiB/s)
8175 bytes read in 128 ms (61.5 KiB/s)
## Flattened Device Tree blob at 01000000
   Booting using the fdt blob at 0x1000000
   Using Device Tree in place at 0000000001000000, end 0000000001004fee

Starting kernel ...

[...]

Ubuntu 14.04 LTS localhost.localdomain ttyMV0

localhost login: root (automatic login)

Welcome to Ubuntu 14.04 LTS (GNU/Linux 4.4.8-armada-17.02.1-g4271698 aarch64)

 * Documentation:  https://help.ubuntu.com/

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~#

 

Ubuntu 16.04

SD card


Next we need to transfer necessary images and extract rootfs.tar.bz2 (that we have created in Creating Ubuntu filesystem) to an SD card, but make sure to prepare your SD card before that. This can be seen above so we will not go over it again.

Once a new, clean and EXT4-formatted partition is created, mount it on your local Linux machine (e.g. we will mount it to /mnt/sdcard):

user@laptop:/$ sudo mkdir -p /mnt/sdcard
user@laptop:/$ sudo mount /dev/sdb1 /mnt/sdcard


Head into the mounted directory and there extract rootfs.tar.bz2:

user@laptop:/$ cd /mnt/sdcard
user@laptop:/mnt/sdcard$ sudo tar -xvf /home/user/ubuntu_16.04/rootfs.tar.bz2


Now copy kernel image and dtb file into the boot folder:

user@laptop:/mnt/sdcard$ sudo cp /home/user/kernel/4.4.8/arch/arm64/boot/Image boot/
user@laptop:/mnt/sdcard$ sudo cp /home/user/kernel/4.4.8/arch/arm64/boot/dts/marvell/armada-3720-community.dtb boot/


Our SD card is now ready and contains the necessary images and Ubuntu file system. Exit the mounted directory and unmount it from your local machine with:

user@laptop:/mnt/sdcard$ cd
user@laptop:/$ sudo umount /mnt/sdcard


Setting U-Boot parameters


Unplug the SD card from your local machine and plug it into the SD card slot on the ESPRESSObin, plug the power adapter and connect to the board using micro USB cable and serial connection as described in Quick User Guide, section Serial Connection.

For the ESPRESSObin to boot Ubuntu file system and images have placed on the SD card, we must configure U-Boot parameters to do so. When the boot starts, hit any key to stop autoboot and get to the Marvell U-Boot prompt:

Hit any key to stop autoboot:
Marvell>> 
Marvell>>


Check that our SD card has necessary files we have transferred using ext4ls command:

Marvell>> ext4ls mmc 0:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 etc
<DIR>       4096 usr
<DIR>       4096 tmp
<DIR>       4096 proc
<DIR>       4096 media
<DIR>       4096 bin
<DIR>       4096 home
<DIR>       4096 sys
<DIR>       4096 var
<DIR>       4096 opt
<DIR>       4096 mnt
<DIR>       4096 srv
<DIR>       4096 run
<DIR>       4096 root
<DIR>       4096 lib
<DIR>       4096 sbin
<DIR>       4096 boot
<DIR>       4096 dev
Marvell>> ext4ls mmc 0:1 boot
<DIR>       4096 .
<DIR>       4096 ..
        12358656 Image
            8175 armada-3720-community.dtb


There are only a few variables we need to set (other needed variables should be set by default) in order to boot from microSD card. First, set proper image and device tree path and name if they are not already set:

Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-3720-community.dtb


Next we setup the boot command by changing the bootmmc variable. We will use this variable to boot the microSD card:

Marvell>> setenv bootmmc 'mmc dev 0; ext4load mmc 0:1 $kernel_addr $image_name;ext4load mmc 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk0p1 rw rootwait; booti $kernel_addr - $fdt_addr'


Be careful to set the root path above to point to where you have extracted the Ubuntu file system (in our case we copied it to the first partition).

After this we can save the variables we have set so far:

Marvell>> save


or setup the bootcmd variable for the ESPRESSObin to automatically boot with the desired variables:

Marvell>> setenv bootcmd 'mmc dev 0; ext4load mmc 0:1 $kernel_addr $image_name;ext4load mmc 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk0p1 rw rootwait; booti $kernel_addr - $fdt_addr'


Finally we boot up the ESPRESSObin with run bootmmc:

Marvell>> run bootmmc
switch to partitions #0, OK
mmc0 is current device
12670464 bytes read in 4125 ms (2.9 MiB/s)
8107 bytes read in 69 ms (114.3 KiB/s)
## Flattened Device Tree blob at 01000000
   Booting using the fdt blob at 0x1000000
   Using Device Tree in place at 0000000001000000, end 0000000001004faa

Starting kernel ...

...

[  OK  ] Started Update UTMP about System Runlevel Changes.

Ubuntu 16.04.2 LTS localhost.localdomain ttyMV0

localhost login: root
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.8-armada-17.02.1-g4271698 aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~#

USB device


Here we will show how to transfer necessary kernel image and dtb file as well as how to extract rootfs.tar.bz2 (that we have created in Creating Ubuntu filesystem) to a USB device. Instructions for preparing your USB device are identical as shown above for Ubuntu 14.04, so we will not go over them again.

Once a new, clean and EXT4-formatted partition is created on your USB device, mount it on your local Linux machine (e.g. we will mount it to /mnt/usb):

user@laptop:~$ sudo mkdir -p /mnt/usb
user@laptop:~$ sudo mount /dev/sdb1 /mnt/usb


Head into the mounted directory and there extract rootfs.tar.bz2:

user@laptop:/$ cd /mnt/usb
user@laptop:/mnt/usb$ sudo tar -xvf /home/user/ubuntu_16.04/rootfs.tar.bz2


Now copy kernel image and dtb file into the boot folder:

user@laptop:/mnt/usb$ sudo cp /home/user/kernel/4.4.8/arch/arm64/boot/Image boot/
user@laptop:/mnt/usb$ sudo cp /home/user/kernel/4.4.8/arch/arm64/boot/dts/marvell/armada-3720-community.dtb boot/


Our USB device is now ready and contains the necessary images and Ubuntu file system. Exit the mounted directory and unmount it from your local machine with:

user@laptop:/mnt/sdcard$ cd
user@laptop:/$ sudo umount /mnt/sdcard



Setting U-Boot parameters


Unplug the USB device from your local machine and plug it into an USB port on the ESPRESSObin, plug the power adapter and connect to the board via micro USB cable and serial connection as described in Quick User Guide, section Serial Connection.

For the ESPRESSObin to boot the images we have placed on the USB device, we must configure valid U-Boot parameters to do so. When the boot starts, hit any key to stop autoboot and get to the Marvell U-Boot prompt:

Hit any key to stop autoboot:
Marvell>>
Marvell>>


First we can check that the necessary files are on our USB device with:

Marvell>> usb start
(Re)start USB...
USB0:   Register 2000104 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
Marvell>> ext4ls usb 0:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
<DIR>       4096 etc
<DIR>       4096 usr
<DIR>       4096 tmp
<DIR>       4096 proc
<DIR>       4096 media
<DIR>       4096 bin
<DIR>       4096 home
<DIR>       4096 sys
<DIR>       4096 var
<DIR>       4096 opt
<DIR>       4096 mnt
<DIR>       4096 srv
<DIR>       4096 run
<DIR>       4096 root
<DIR>       4096 lib
<DIR>       4096 sbin
<DIR>       4096 boot
<DIR>       4096 dev
Marvell>> ext4ls usb 0:1 boot
<DIR>       4096 .
<DIR>       4096 ..
        12358656 Image
            8175 armada-3720-community.dtb


using printenv we can list currently set U-Boot variables. If changed, here we need to set up correct values for image names:

Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-3720-community.dtb


and set bootusb variable which we will use to boot from USB device

Marvell>> setenv bootusb 'usb start;ext4load usb 0:1 $kernel_addr $image_name;ext4load usb 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/sda1 rw rootwait; booti $kernel_addr - $fdt_addr'


and lastly we boot by issuing run bootusb (login with root):

Marvell>> run bootusb
(Re)start USB...
USB0:   Register 2000104 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
12358656 bytes read in 940 ms (12.5 MiB/s)
8175 bytes read in 289 ms (27.3 KiB/s)
## Flattened Device Tree blob at 01000000
   Booting using the fdt blob at 0x1000000
   Using Device Tree in place at 0000000001000000, end 0000000001004fee

Starting kernel ...

[...]

[  OK  ] Started Update UTMP about System Runlevel Changes.

Ubuntu 16.04.2 LTS localhost.localdomain ttyMV0

localhost login: root
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.8-armada-17.02.1-g4271698 aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~#


View an example Ubuntu 16.04 bootlog here.