MHR

Alpine on Scaleway - Your IPv6 box for $0.15/Month

Moohr avatar
  • Moohr
  • 2 min read

Please note that this is done for scientific purposes and for educating on how Linux servers works.

  1. Delete the 10GB volume of storage. Go to local storage and add a 1GB volume.
  2. Boot the VM in rescue mode.
  3. Once inside, find your disk:
root@scw-strange-lewin:~# lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   9.3G  1 disk
├─sda1    8:1    0   3.5G  1 part /media/root-ro
├─sda14   8:14   0     4M  1 part
├─sda15   8:15   0   106M  1 part /boot/efi
└─sda16 259:0    0   913M  1 part /media/root-ro/boot
vda     253:0    0 953.7M  0 disk
root@scw-strange-lewin:~#

In here, we can see that that vda is the 1GB disk we added. Let’s get Alpine onto that.

  1. Download Alpine, DD, and set up some required mounts:

First let’s grab the cloud image

wget https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/cloud/generic_alpine-3.22.2-x86_64-uefi-cloudinit-r0.qcow2

To actually DD it onto a blank block device (aka disk), we need to convert it from the qcow (qemu copy-on-write) format into raw. However we don’t actually have enough storage

apt update && apt install qemu-utils -y

#qemu-img convert -O raw generic_alpine-3.22.2-x86_64-uefi-cloudinit-r0.qcow2 alpine.raw
#dd if=alpine.raw of=/dev/vda bs=1M status=progress
#if you have enough storage in your rescue you can do it this way (old fashioned)
#otherwise you can just do it like this

qemu-img convert -O raw generic_alpine-3.22.2-x86_64-uefi-cloudinit-r0.qcow2 /dev/vda

sync

After here, we have already written alpine to the disk image. It’ll boot, but we haven’t added any credentials. To do that, we need to perform some setup. Let’s expand the disk to full size first

parted -s /dev/vda resizepart 2 100%
e2fsck -f /dev/vda2
resize2fs /dev/vda2

Afterwards, mount the disk and chroot into the system:

mkdir -p /mnt/alpine
mount /dev/vda2 /mnt/alpine

Then mount some required stuff from the rescue system to our new system:

mount -t proc none /mnt/alpine/proc
mount -t sysfs none /mnt/alpine/sys
mount --rbind /dev /mnt/alpine/dev
mount --make-rslave /mnt/alpine/dev
  1. Enter alpine (hurrah)
chroot /mnt/alpine /bin/sh
  1. Set up some stuff.

Let’s add the ssh key in.

mkdir -p /root/.ssh && echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFWnkfCZETwETd8bpdiz2/RRvsswdc+ryNZK5jXGi7jf" > /root/.ssh/authorized_keys

Then we need to add these two lines to the start of /etc/ssh/sshd_config

PermitRootLogin prohibit-password
PubkeyAuthentication yes

Then run this to remove the locked root account

passwd -d root

Then you’re basically done. If you find the boot times annoyingly long, you can disable the cloudinit:

touch /etc/cloud/cloud-init.disabled

Do keep in mind you will have to set up your own IPs. This shouldn’t be a huge problem, because you have VNC access to the machine in Scaleway’s panel.

Moohr

Written by : Moohr

Everyone cares about the destination, but you should always care about the journey. That's what makes you different.

Recommended for You