Classic install or sys mode on Raspberry Pi

From Alpine Linux

Howto for classic installation or "sys mode"

This method works with a desktop PC under Ubuntu and other linuxes

PREPARATION

Download archive of Alpinelinux for Rasperry Pi :

http://dl-cdn.alpinelinux.org/alpine/v3.6/releases/armhf/alpine-rpi-3.6.2-armhf.tar.gz

On a class 10 sd-card with size of 16Go or more, create 2 partitions :

  • First in fat16 with size of 128Ko. Check boot and lba flags
  • Second in ext4 with the remaining place

Eject and insert your SD-card to recognize all the partitions

Now go inside the first partition (fat16).

Untar the archive with tar: tar zxvf ~/Download/alpine-rpi-3.6.2-armhf.tar.gz

Because a bug, it's recommended to add in the partition a file named usercfg.txt with the unique line :

enable_uart=1

Eject properly the sd card, insert it in the Raspberry Pi, plug a usb keyboard, an HDMI and a network cables, and power on. As a prompt is displaying, connect as root without password.

INSTALLATION

So, execute the following commands :

  • setup-alpine (set the mapping keyboard, the timezone, how to connect to the network (dhcp is the best method), say "no" at "save config" and cache)
  • apk update
  • apk add chrony (Raspberry Pi has no battery for his hardware clock. So, synchronize with a ntp server)
  • service chronyd restart
  • mount /dev/mmcblk2p2 /mnt (The second partition in ext4 format where Alpinuxlinux is installing in sys mode)
  • setup -m sys /mnt
  • mount -o remount,rw /dev/mmcblk0p1 (An update in the first partition is required for the next reboot)
  • rm -f /media/mmcblk0p1/boot/* (clean up the boot folder in the first partition to drop unused files)
  • cd /mnt (We are in the second partition)
  • rm boot/boot (Drop the useful symbolink link)
  • mv boot/* /media/mmcblk0p1/boot/ (Move the image and init ram for AlpineLinux at the good place)
  • rm -Rf boot
  • mkdir media/mmcblk1p1 (It's the mount point for the first partition on the next reboot)
  • ln -s media/mmcblkp1/boot boot (Don't worry about the error)
  • echo "/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0" >> etc/fstab (Update /etc/fstab)
  • sed -i '/cdrom/d' etc/fstab (Of course, you don't have any cdrom or floppy on the Raspberry Pi)
  • sed -i '/floppy/d' etc/fstab
  • sed -i '/edge/s/^#//' etc/apk/repositories (Enable the repository for the community if you want vim, mc, php, apache, nginx, ...)
  • cd /media/mmcblk0p1
  • sed -i 's/^/root=\/dev\/mmcblk0p2 /' cmdline.txt (Tell for the next boot that the root filesystem is on the second partition)
  • reboot

That works on Raspberry Pi 3B and 1B. But if you have the 1B version, let's be very, very patient (several tens of minutes)

If a hard disk is connected via usb, you can replace above /dev/mmcblk0p2 by /dev/sda1, for example.

If you don't like sed and regular expressions, you can use nano editor after executing the following command :

apk add nano

POST-INSTALLATION

Must be continued ....