Classic install or sys mode on Raspberry Pi

From Alpine Linux
Revision as of 08:41, 7 November 2017 by Bazooka07 (talk | contribs) (POST-INSTALLATION)
Jump to: navigation, search

Howto for classic installation or "sys mode"

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


Download archive of Alpinelinux for Rasperry Pi :

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 :


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.


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/mmcblk0p2 /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 unused symbolink link)
  • mv boot/* /media/mmcblk0p1/boot/ (Move the image and init ram for AlpineLinux at the right 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


The Raspberry Pi (RPI) has no battery to keep the time updated. So, we need to enable the right service to synchronize with a ntp server:

  • rc-update del hwclock boot
  • rc-update add swclock boot
  • service hwclock stop
  • service swclock start

Update and upgrade the system :

  • apk update
  • apk upgrade

If you want a cool editor (vim), a files manager (mc), which tasks are running (htop), which services are starting on the boot process, add the right packages :

  • apk add vim mc htop
  • rc-update

The RPI 3B has wifi for networking. So, start service for the encrypted key on wpa2 protocol :

  • apk add wpa_supplicant
  • rc-update add wpa_supplicant boot
  • service wpa_supplicant start
  • setup-interface (replace IP address by dhcp for all the interfaces if necessary, select the SSID network for wifi and add password)
  • ip addr (to know the IP address for all interfaces)

If you want to connect on your remote RPI via ssh, an additional user (foo) and sudo package are required because it's forbidden to conect as root :

  • apk add sudo
  • adduser foo
  • adduser foo wheel
  • visudo (uncomment line #82 with "wheel ALL=(ALL) ALL". If vim is installed, save the changes by typing "Esc :x")