Creating Ubuntu 16.04 Image for EMB-2238

From Estone Technology Wiki
Jump to: navigation, search

Build rootfs

Install host dependencies

$ sudo apt-get install gparted git build-essential libncurses5 wget u-boot-tools zlib1g-dev ncurses-dev
$ sudo apt-get install cmake libc-dev-armhf-cross pkg-config-arm-linux-gnueabihf build-essential checkinstall cmake
$ sudo apt-get install pkg-config lzop libc6 libstdc++6 debootstrap qemu-user-static binfmt-support zlib1g:i386
$ sudo apt-get install qemu-user-static

Download the base rootfs

$ cd ~/
$ mkdir rootfs
$ cd rootfs
$ wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.4/release/ubuntu-base-16.04.4-base-armhf.tar.gz
$ sudo tar zxf ubuntu-base-16.04.4-base-armhf.tar.gz

copy qemu-arm-static to rootfs

$ sudo cp /usr/bin/qemu-arm-static ~/rootfs/usr/bin/
$ sudo cp /etc/resolv.conf ~/rootfs/etc/

Add ubuntu arm source

$ sudo vim etc/apt/sources.list
  deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
  deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
  deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
  deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
  deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
  deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
  deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
  deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
  deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
  deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe


Mount the rootfs and chroot

$sudo mount -t proc /proc ~/rootfs/proc
$sudo mount -t sysfs /sys ~/rootfs/sys
$sudo mount -o bind /dev ~/rootfs/dev
$sudo mount -o bind /dev/pts ~/rootfs/pts
$sudo chroot ~/rootfs/


Update the source

#apt update

Install the software

#apt install sudo
#apt install language-pack-en-base
#apt install ssh
#apt install net-tools
#apt install ethtool 
#apt install ifupdown
#apt install iputils-ping
#apt install rsyslog
#apt install htop 
#apt install kmod

Set up the root password

#passwd root


Set up the serial and network

#ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc1.service
#echo auto eth0 > /etc/network/interfaces.d/eth0
#echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0


exit chroot

#exit


umount the rootfs

$ sudo umount ~/rootfs/proc
$ sudo umount ~/rootfs/sys
$ sudo umount ~/rootfs/dev/pts
$ sudo umount ~/rootfs/dev