Alpine Linux on ARM64

#1

Here are the steps I took to install Alpine linux on Scaleway ARM64 servers.

Bootstrap Alpinelinux on Scaleway ARM64

Installation

  1. Boot to rescue mode
  2. Format hard drive
    # mkfs.ext4 /dev/vda
  3. Mount hard drive
    # mount /dev/vda /mnt
  4. Download and extract apk-tools-static for aarch64
    # cd /dev/shm
    # wget http://dl-cdn.alpinelinux.org/alpine/v3.7/main/aarch64/apk-tools-static-2.8.2-r0.apk
    # tar xvzf apk-tools-static-2.8.2-r0.apk
  5. Bootstrap Alpine Linux
    # ./sbin/apk.static --arch aarch64 -X http://dl-cdn.alpinelinux.org/alpine/v3.7/main/ -U --allow-untrusted --root /mnt --initdb add alpine-base
  6. Download and copy dynamic-getty to Alpine
    # wget https://raw.githubusercontent.com/scaleway/image-alpine/master/overlay/usr/local/sbin/dynamic-getty
    # mkdir /mnt/usr/local/sbin
    # mv dynamic-getty /mnt/usr/local/sbin/
    # chmod +x /mnt/usr/local/sbin/dynamic-getty
  7. Edit /etc/inittab
    # vi /mnt/etc/inittab
    > # /etc/inittab
    >
    > ::sysinit:/sbin/rc sysinit
    > ::wait:/sbin/rc default
    >
    > ::respawn:/usr/local/sbin/dynamic-getty
    >
    > ::shutdown:/sbin/rc shutdown
  8. Copy resolv.conf to Alpine
    # cp /etc/resolv.conf /mnt/etc/
  9. Setup apk repositories
    # echo http://dl-cdn.alpinelinux.org/alpine/v3.7/main/ > /mnt/etc/apk/repositories
  10. Chroot into Alpine
    # chroot /mnt /bin/sh
  11. Set correct permissions on folders
    # chmod 0755 /etc /usr /usr/local /usr/local/bin /usr/local/sbin
  12. Setup root password and SSH key
    # passwd
    # mkdir /root/.ssh
    # vi /root/.ssh/authorized_keys
    # chmod 0600 /root/.ssh/authorized_keys
    # chmod 0750 /root
  13. Reboot
    # reboot

Post installation

  1. Login and run setup-alpine
    # setup-alpine
  2. Setup Scaleway stuffs
    # apk add bash curl tar wget
    # wget -qO - https://j.mp/scw-skeleton | FLAVORS=common,docker-based,openrc bash -e
    # rc-update add scw-hostname
    # rc-update add scw-ssh-keys
    # rc-update add scw-sshd-keys
    # rc-update add scw-swapfile
    # rc-update add scw-sync-kernel-extra
    # rc-update add scw-initramfs-shutdown shutdown
  3. Set correct permissions on folders
    # chmod 0755 /etc /usr /usr/local /usr/local/bin /usr/local/sbin
    # chmod 0600 /root/.ssh/authorized_keys
    # chmod 0750 /root
1 Like
#2

Thanks for providing this tutorial :slight_smile:

#3

Adding console to /etc/securetty is also needed

#4

Is there any similar script available for Arch Linux?

#5

Hello.

AFAIK there is no script for ARM64 servers. But you may try the following instructions:

Bootstrap Archlinux on Scaleway ARM64

Installation

  1. Boot to rescue mode
  2. Partition the disk
    # fdisk /dev/vda
  3. Format hard drive
    # mkfs.ext4 /dev/vda1
  4. Mount the partition
    # mount /dev/vda1 /mnt
  5. Download bsdtar
    # apt-get update && apt-get install bsdtar
  6. Download archlinux ARM for ARMv8 (generic version)
    # cd /dev/shm
    # wget http://archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
  7. Extract Archlinux ARM
    # bsdtar -xpvf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt
  8. Delete resolv.conf symlink in you new installation and copy the original one
    # rm /mnt/etc/resolv.conf
    # cp /etc/resolv.conf /mnt/etc/
  9. Mount special devices
    # mount -t proc none /mnt/proc
    # mount -o bind /sys /mnt/sys
    # mount -o bind /dev /mnt/dev
  10. Enter the chroot
    # chroot /mnt
  11. Generate fstab
    # genfstab -U / >> /etc/fstab

Scaleway specific

  1. Install scaleway startup services
    # pacman -S wget curl
    # wget https://github.com/scaleway/image-tools/archive/master.zip
    # unzip master.zip
    # cp -rv image-tools-master/bases/overlay-common/* /
    # cp -rv image-tools-master/bases/overlay-systemd/* /
    # systemctl enable /etc/systemd/system/scw-*.service
    # systemctl enable sshd
  2. Setup root SSH key
    # touch /root/.ssh/authorized_keys
    # chmod 0600 /root/.ssh/authorized_keys
    # chmod 0750 /root
  3. Remove linux kernel
    # pacman -Rscu linux-aarch64
  4. Delete alarm user
    # userdel -r alarm
  5. Remove hostname config file
    # rm /etc/hostname
  6. Set default target
    # systemctl set-default multi-user.target
  7. Exit the chroot and Reboot
    # exit
    # sync ; reboot

Edit:

  1. Corrected a typo
  2. Styling
#6

But in any case, the kernel that will be loaded will be the one provided by Scaleway, right?

#7

On ARM64, yes. The kernel is provided by Scaleway.

#8

It would be nice to load the kernel provided by the distribution. To use the local boot option.

#9

I followed the tutorial for Alpine Linux using the version 3.10
I cannot login Alpine Linux at the step 14.

As ssh is not enabled I login with the console but I am not prompted for a password
vm-10-10-21-17 login: root
Login incorrect

If I create a standard user in the chroot, I can then login as this user but cannot become root
vm-10-10-21-17:~$ su
Password:
su: incorrect password

Any idea about this issue ?

#10

Well, this guide is a bit outdated now and some things have changed on Scaleway side.
Some links are now unavailable (dynamic-getty for example). It might be the issue.

I have a few instances laying around. I might give a try to Alpine if I find some time.

Latest files and scripts from Scaleway for Alpine are available here.
You may want to check them: https://github.com/scaleway/image-alpine

#11

Thanks, I had updated the links including the one of dynamic-guetty but it fails.
I’ll dig a little bit more with Alpine.

By the way I switched to debian (ubuntu cannot boot twice the kernels 4.14 and 4.19).