Create a root filesystem image file sized 1000M and populate it with the ubuntu base tar file:
fallocate -l 1000M rootfs.imgsudo mkfs.ext4 -F ROOTFS rootfs.img mkdir mnt sudo mount rootfs.img mntsudo tar -xzvf ubuntu-base-16.04.1-base-arm64.tar.gz -C mnt/sudo cp -a /usr/bin/qemu-aarch64-static mnt/usr/bin/
qemu-aarch64-static is the magic cure here, which enables chroot into an arm64 filesystem under amd64 host system.
Chroot to the new filesystem and initialize:
sudo chroot mnt/# Change the setting hereUSER=fireflyHOST=firefly# Create Useruseradd -G sudo -m -s /bin/bash $USERpasswd $USER# enter user password# Hostname & Networkecho $HOST /etc/hostnameecho "127.0.0.1 localhost.localdomain localhost" > /etc/hostsecho "127.0.0.1 $HOST" >> /etc/hostsecho "auto eth0" > /etc/network/interfaces.d/eth0echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0echo "nameserver 127.0.1.1" > /etc/resolv.conf# Enable serial consoleln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service # Install packagesapt-get updateapt-get upgradeapt-get install ifupdown net-tools network-managerapt-get install udev sudo sshapt-get install vim-tiny