Table of Contents
Ubuntu
debootstrap
Steps to get ubuntu-system (use armhf as arch): https://help.ubuntu.com/lts/installation-guide/armhf/apds04.html
sudo apt-get install qemu-user-static debootstrap binfmt-support distro=bionic #distro=focal arch=armhf #for bpi-r64 use arch=arm64 targetdir=$(pwd)/debootstrap_ubuntu_${distro}_${arch} sudo debootstrap --arch=$arch --foreign $distro $targetdir #if you got this error: E: Cannot install into target '...' mounted with noexec or nodev sudo mount -i -o remount,exec,dev /mounted_dir sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/ sudo cp /etc/resolv.conf $targetdir/etc sudo distro=$distro chroot $targetdir export LANG=C /debootstrap/debootstrap --second-stage #echo "deb-src http://archive.ubuntu.com/ubuntu $distro main">>/etc/apt/sources.list #echo "deb http://security.ubuntu.com/ubuntu $distro-security main">>/etc/apt/sources.list #echo "deb-src http://security.ubuntu.com/ubuntu $distro-security main">>/etc/apt/sources.list echo "deb http://ports.ubuntu.com/ubuntu-ports/ $distro main">>/etc/apt/sources.list echo "deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro main">>/etc/apt/sources.list echo "deb http://ports.ubuntu.com/ubuntu-ports/ $distro-updates main">>/etc/apt/sources.list echo "deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro-updates main">>/etc/apt/sources.list echo "deb http://ports.ubuntu.com/ubuntu-ports/ $distro-security main">>/etc/apt/sources.list echo "deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro-security main">>/etc/apt/sources.list echo "bpi-r2-ubuntu" >/etc/hostname #set root-password! else you will not be able to login passwd
configure fstab/… like it's done for debian ubuntu 18.4 uses netplan as default network-framework bionic releasenotes
#exit chroot exit
pack:
cd $targetdir sudo tar cvpzf ../debootstrap_${distro}_${arch}.tar.gz .
install System to SD-Card
#unpacking in root-partiton with sudo tar -xpzf /path/to/debootstrap_$distro.tar.gz sudo mkdir lib/modules/ cd lib/modules/ #unpack kernel-modules here
temporary configure network:
ip a ip link set eth0 up ip addr add 192.168.0.11/24 dev lan0 #ip/prefix in your lan-segment not used ip link set lan0 up ip route add default via 192.168.0.10 #ip from your router echo "nameserver 192.168.0.10" >>/etc/resolv.conf #ip from your router for dns resolution
install “ifupdown” and add “netcfg/do_not_use_netplan=true” to bootopts in /boot/bananapi/bpi-r2/linux/uEnv.txt
after reboot the “old” system with /etc/network/interfaces is used. currently /etc/resolv.conf is resetted every reboot
root@bpi-r2-ubuntu:~# ls -l /etc/resolv.conf lrwxrwxrwx 1 root root 39 Jun 13 10:27 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf #delete symlink and replace it by a static file with your settings rm /etc/resolv.conf echo "nameserver 192.168.0.10" >>/etc/resolv.conf
in ubuntu 18.4 there is a own dns-service running, which have to be disabled (followed by a reboot or stop), in order to get e.g. DNSMasq running (like in my wifi.sh-script)
systemctl disable systemd-resolved systemctl stop systemd-resolved
create the image
imgfile=/path/to/ubuntu-18.04-bpi-r2-preview.img #create img file from sdcard (optional if no img file available) sudo dd if=/dev/sdx of=$imgfile #watch state of dd from another terminal with "sudo kill -SIGUSR1 $(pidof dd)" #truncate image to last partitions end (mbr only,do not use for gpt)...make sure your path does not contain spaces! IFS=$'\t' #just for security reasons (ignore spaces in path) ENDOFDATA=$(fdisk -l "$imgfile" |tail -1|awk '{print $3}') echo $ENDOFDATA truncate --size=$[($ENDOFDATA+1)*512] $imgfile #check size ls -lh "$imgfile" #maybe do some stuff with the img loopdev=$(losetup -f) sudo losetup $loopdev $imgfile sudo partprobe $loopdev sudo mount ${loopdev}p2 /mnt ls /mnt #overwrite free space with zeros for better packing and not leaving possible sensitive data sudo sh -c 'cat /dev/zero >/mnt/null.dat' sudo rm /mnt/null.dat sudo umount /mnt #pack image gzip $imgfile md5sum $imgfile.gz > $imgfile.gz.md5
i have uploaded my image to my gdrive for testing (ubuntu-18.04-bpi-r2-preview.img.gz)
Lan0-IPv4 is 192.168.0.11 (second port,next to wan) you can change it in /etc/network/interfaces. More on network
installation
Sdcard:
dd if=path/to/ubuntu.img of=/dev/sdx
Emmc:
- dd if=path/to/ubuntu.img of=/dev/mmcblkx
- maybe you need reboot reading the partitiontable
- First follow steps here
- in /boot/bananapi/bpi-r2/linux/uEnv.txt: find the line “root=…” and replace /dev/mmcblk0p2 with /dev/mmcblk1p2
- in /etc/fstab: replace /dev/mmcblk0p2 with /dev/mmcblk1p2
SSH
ssh-server is installed on my image ubuntu-18.04-bpi-r2-preview.img.gz from my gdrive, but root-login have to be enabled
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config service sshd restart
you should create new host-keys for ssh…
#first delete your old keys rm /etc/ssh/ssh_host_* #reconfigure sshserver-package dpkg-reconfigure openssh-server