User Tools

Site Tools



en:bpi-r2:ubuntu

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
en:bpi-r2:ubuntu [2018/06/18 17:28] – [create the image] franken:bpi-r2:ubuntu [2023/02/15 19:09] – [create the image] frank
Line 1: Line 1:
 +====== Ubuntu ======
  
 +===== debootstrap =====
 +
 +Steps to get ubuntu-system (use armhf as arch): https://help.ubuntu.com/lts/installation-guide/armhf/apds04.html
 +
 +<code bash>
 +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
 +</code>
 +configure fstab/... like it's done for [[debian]]
 +:!: ubuntu 18.4 uses netplan as default network-framework [[https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes#Network_configuration|bionic releasenotes]]
 +<code bash>
 +#exit chroot
 +exit
 +</code>
 +pack:
 +<code bash>
 +cd $targetdir
 +sudo tar cvpzf ../debootstrap_${distro}_${arch}.tar.gz .
 +</code>
 +
 +===== install System to SD-Card =====
 +[[storage#manual_copy_of_os|prepare SD-Card]]
 +<code bash>
 +#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
 +</code>
 +
 +temporary configure network:
 +<code>
 +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
 +</code>
 +
 +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
 +
 +<code>
 +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
 +</code>
 +
 +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 =====
 +<code bash>
 +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
 +</code>
 +
 +i have uploaded my image to [[https://drive.google.com/open?id=1oP7jy1KrrIOifvImo2nQ59wx3_9hHkgk|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 [[storage#install_os_on_emmc|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 [[https://drive.google.com/open?id=1oP7jy1KrrIOifvImo2nQ59wx3_9hHkgk|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
en/bpi-r2/ubuntu.txt · Last modified: 2023/06/08 17:06 by 127.0.0.1