Although Arch Linux has packages for most everything, there is the odd circumstance when one can't simply install one from even the AUR.
DigitalOcean deprecated Arch Linux a while back because it was relativelydifficult to support due to the rolling updates. I wrote this script tobring it back! This script downloads a bootstrap Arch Linux image, updates itto the latest version, then overwrites the host operating system with it.
Warning / Disclaimer
ALL DATA ON THE DROPLET WILL BE UNCONDITIONALLY DESTROYED.
This script may cause your VPS to become unbootable.I only recommend running this script on newly created droplets with noimportant data.Installation
- Create a new Debian 9.x droplet (either 32-bit or 64-bit is fine).
- In the droplet, run the following as root:
- Follow the instructions when prompted.
- Sit back and relax! The system will automatically reboot once complete,and you should have a fully updated Arch Linux system in within minutes.
Advanced Configuration
This script supports several flags, all of which are optional.
--archlinux_mirror
The Arch Linux mirror from which the bootstrap image and packages should bedownloaded. Defaults to http://mirrors.kernel.org/archlinux.--extra_packages
Installs any extra packages to the Arch installation (e.g. base-devel).Packages should be space-separated and quoted(e.g.--extra_packages 'git wget'
).--grub_timeout
Overrides the default GRUB_TIMEOUT value of 5 seconds.--kernel_package
The kernel package to install. Defaults to the vanillalinux
package.Other options includelinux-lts
for long term support andlinux-hardened
fora kernel with patches from linux-hardened.--mkfs_options
Extra options to pass tomkfs
. Useful for settings bytes per inode on ext4,e.g.--mkfs_options='-i 65536'
.--target_architecture
The architecture of the new Arch Linux installation. Defaults to thearchitecture of the original Debian image as provided byuname -m
.A 64-bit Debian image may convert to eitherx86_64
ori686
.A 32-bit Debian image may only convert toi686
.--target_disklabel
The type of partition table to use. Defaults togpt
(GUID partition tableas used by EFI). The alternative isdos
(traditional MBR).--target_filesystem
The filesystem on which the Arch Linux installation should be installed.Defaults toext4
. The alternative isbtrfs
.
How it Works
- A sparse disk image is created with the same size of the droplet's disk.
- Three partitions are made and formatted.
- DORoot: A 'dummy' partition to keep DigitalOcean happy. When snapshotsare restored, new passwords are written here.
- BIOSBoot: The virtual machine BIOS cannot boot from GPT partitionsdirectly, so a small partition is placed here for bootloader code.
- ArchRoot: The main root filesystem for Arch Linux.
- The Arch Linux bootstrap image is downloaded and unpacked onto ArchRoot.
pacman -Syu
is called inside the image to pull in all the base packagesalong with OpenSSH and any other packages put in the --extra_packages option.- The root password and SSH host keys are copied into the image.
- A special script called
digitalocean-synchronize
is installed intothe image. This script is run at every startup to autodetect the networksettings from the metadata service. It also detects if the dropletwas just restored, and if so, it resets the root password and regeneratesthe host SSH keys. - The image is now ready. The script then generates a 'blockplan'. It isessentially a list of instructions to image the virtual disk with thesparse disk image without requiring any extra space.
- A minimal root filesystem is generated on RAM so that the disk canbe unmounted.
- The script calls
systemctl switch-root
to enter the minimalroot filesystem. - The disk is unmounted.
- The blockplan is executed.
- The bootloader (Grub) is installed.
- Reboot!
- Done!