We're no longer updating This wiki!!

Changelog:

20150121:

  1. Initial version

20150131:

  1. Added the missing automount of /media/boot
  2. Fixed the date (image was 20140121)
  3. Added optional step to allow root login via ssh (included on the image)

20161102:

  1. Updated to Ubuntu 16.04

—-

To this you'll need:

  • PC running Linux Ubuntu 16.04 64 Bits
  • MicroSD or eMMC to write the new image

This guide will cover the process to recreate the official Ubuntu Minimal image. Tested and written on a Ubuntu 16.04 64Bits x86 Machine.

  1. Tools:
    Basic set of tools that we will need to create our image.
    sudo apt-get install debootstrap qemu-user-static
  2. Work folder
    Create a workspace
    mkdir ~/ubuntu
    cd ubuntu
    export ubuntu=`pwd`
  3. Empty image (4GB)
    Create a image with 4096 1Mbyte blocks (4Gbyte image)
    dd if=/dev/zero of=./image.img bs=1M count=4096
  4. Image partitioning
    Create the two needed partitions, one fat32 for kernel+initramfs+boot script and another ext4 for the OS
    fdisk image.img
    n
    p
    1
    <return>
    +128M
    t
    c
    n
    p
    2
    <return>
    <return>
    w
  5. Formatting and setting up partitions
    Setup loopback and format the partitions.
    Also change the UUID and disable journaling.
    sudo losetup /dev/loop0 ./image.img
    sudo partprobe /dev/loop0
    sudo mkfs.vfat -n boot /dev/loop0p1
    sudo mkfs.ext4 -L rootfs /dev/loop0p2
    sudo tune2fs /dev/loop0p2 -U e139ce78-9841-40fe-8823-96a304a09859
    sudo tune2fs -O ^has_journal /dev/loop0p2
  6. Bootloaders
    Download a pre-built version of U-Boot for C1 and fuse to our image.
    wget https://raw.githubusercontent.com/mdrjr/c1_uboot_binaries/master/bl1.bin.hardkernel
    wget https://raw.githubusercontent.com/mdrjr/c1_uboot_binaries/master/u-boot.bin
    wget https://raw.githubusercontent.com/mdrjr/c1_uboot_binaries/master/sd_fusing.sh
    chmod +x sd_fusing.sh
    sudo ./sd_fusing.sh /dev/loop0
  7. Deboostrap
    Mount the partitions, copy qemu to enable chroot to arm and start debootstrap
    mkdir -p target
    sudo mount /dev/loop0p2 target
    sudo mkdir -p target/media/boot
    sudo mount /dev/loop0p1 target/media/boot
    sudo mkdir -p target/usr/bin
    sudo cp /usr/bin/qemu-arm-static target/usr/bin
    sudo debootstrap --variant=buildd --arch armhf xenial target http://ports.ubuntu.com
  8. Preparations via chroot
    Will add hardkernel keys and repositories, fix ubuntu respository list and install the basic set of tools for a minimal image
    sudo chroot target
    cat << EOF > /etc/apt/sources.list
    deb http://ports.ubuntu.com/ubuntu-ports/ xenial main universe restricted
    deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main universe restricted
    
    deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main universe restricted
    deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main universe restricted
    
    deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
    deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
    
    deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
    deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
    deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
    deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
    deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse  
    deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse
    EOF
    
    apt-get update
    apt-get install software-properties-common u-boot-tools isc-dhcp-client ubuntu-minimal ssh
    
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D986B59D
    echo "deb http://deb.odroid.in/c1/ xenial main" > /etc/apt/sources.list.d/odroid.list
    apt-get update
    
    apt-get install linux-image-c1 bootini

    At this point.. You'll have several errors, That's fine.
    You can ignore it right now.

    cp /boot/uImage* /media/boot/uImage
  9. Setup ethernet as DHCP and create the loopback interface
    cat << EOF > /etc/network/interfaces.d/lo
    auto lo
    iface lo inet loopback
    EOF
    
    cat << EOF > /etc/network/interfaces.d/eth0
    auto eth0
    iface eth0 inet dhcp
    EOF
  10. Setup fstab
    echo "LABEL=boot /media/boot vfat defaults 0 0" >> /etc/fstab
    echo "UUID=e139ce78-9841-40fe-8823-96a304a09859 / ext4 errors=remount-ro,noatime 0 1" >> /etc/fstab
  11. Setting a root password
    passwd root
  12. (Optional) Allow root login via ssh
    sed -i s/"PermitRootLogin without-password"/"PermitRootLogin yes"/g /etc/ssh/sshd_config
  13. Clean ups and preparation to test the image.
    exit
    sudo umount target/media/boot
    sudo umount target
    sudo sync
    sudo losetup -d /dev/loop0
  14. Flashing your image
    dd if=image.img of=/dev/sdX bs=1M
  15. After your first boot, install the u-boot package to get updates.
    sudo apt-get install u-boot
en/c1_ubuntu_minimal.txt · Last modified: 2016/11/04 03:02 by mdrjr
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0