Installing Ubuntu server running from USB-disk
It took me quite a while to find out how to run my M5 on USB-disk. The wiki is erroneous, so here my version:
Prepare
- download Ubuntu server for the m5 and name it
ubuntuserver-m5.img.zip
- a SD-card of at least 16Gb
- an USB-disk of for example 100G size
- connect your M5 with a network cable (local network)
- a Linux desktop computer
- connect your M5 to a HDMI display
Phase 1 - Unpack and burn on SD
Attach the SD to your desktop and use lsblk
to see where it is. In my case it is /dev/sdc
(Be careful, using the wrong device will erase your system!)
unzip ubuntuserver-m5.img.zip
sudo dd if=ubuntuserver-m5.img of=/dev/sdc bs=10M status=progress
- put this SD in the M5 and power the M5 up
- See the messages appearing on your HDMI display
- Log in as user
pi
passwordbananapi
- Use
lsblk
to see the names of devices- The one with size 14.6Gb is the eMMc drive,
mmcblk0
- The one with size 14.6Gb is the eMMc drive,
- Use
ip a show dev eth0:
to see the M5 ip-address - On your desktop computer
scp ubuntuserver-m5.img pi@<m5-ip-address>:
- Then on the M5, type
sudo dd if=ubuntuserver-m5.img of=/dev/mmcblk0 bs=10M status=progress
which copies ubuntu-server to the eMMC - Now you need to expand the filesystem on the eMMC:
sudo cfdisk /dev/mmcblk0
- Do not change the
/dev/mmcblk0p1
, which is the boot partition of 256Mb, FAT - Resize
/dev/mmcblk0p2
to maximum, 14.2Gb - Write and exit. Now you resized the partition
- Do not change the
- To expand the filesystem type:
sudo resize2fs /dev/mmcblk0p2
- (you probably have to type
sudo e2fsck -f /dev/mmcblk0p2
before and after)
- (you probably have to type
- You are ready to boot from eMMC:
sudo halt
Phase 2 - Prepare USB disk
- Remove the SD-card and press the button between the micro-hdmi and hdmi entry
- Sytem on eMMC is starting. A little after the green light goes off you can login from your desktop:
ssh pi@<same_m5-ip-address>
- type
lsblk
- You should see your mmcblk0 mounted on
/
and/boot
- Plug in your external USB-drive en type
lsblk
, and seesda
- From your desktop type:
scp ubuntuserver-m5.img pi@<m5-ip-address>:
- And after on your M5:
sudo dd if=ubuntuserver-m5.img of=/dev/sda bs=10M status=progress
- Then you need to alter the partitions on /dev/sda:
sudo cfdisk /dev/sda
- Resize /dev/sda2 (where root (/) will come) to something between 32G and 64G
- Create a third partition covering the rest of the disk, where your data (/data) will come:
sudo resize2fs /dev/sda2
sudo mkfs.ext4 /dev/sda3
- Now comes the tricky part, if this goes wrong, your M5 will go dead.
- To make M5 boot to /dev/sda, you should remove
boot.ini
on your eMMcmv /boot/boot.ini /boot/boot.ini.orig
- Cross your fingers and reboot:
sudo reboot
Phase 3 - Configure your Ubuntu server on USB-disk
- A little after the green light goes off you can login from your desktop:
ssh pi@<same_m5-ip-address>
- log in with
pi
andbananapi
- type
lsblk
- You should see your sda mounted on
/
and/boot
- Modify your system:
- Change password of user pi:
passwd
- Change timezone (to Berlin timezone):
sudo timedatectl set-timezone Europe/Berlin && timedatectl
- Change password of user pi:
- Check locale:
locale -a
- Change hostname:
sudo hostname bpim5
- Update software:
sudo apt update && sudo apt -y upgrade
- To mount the third partition:
- obtain uuid:
sudo blkid | grep sda3
sudo mkdir /data
-
sudo vim /etc/fstab
and add the line:UUID=<UUID_here> /data ext4 noatime,defaults 0 2
sudo mount -a
- obtain uuid:
- Now /data will be your data directory, check with:
lsblk
Turn it back
To boot from eMMC again, do the following:
sudo mount /dev/mmcblk0p1 /mnt
sudo mv /mnt/boot.ini.org /mnt/boot.ini
sudo reboot
Now your M5 boots from eMMC, and you can safely remove your USB-disk
(Corrections and additions welcome)