Installing Alpine Linux on TransIP VPS
Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox. Its small size, simplicity, and focus on security make it an excellent choice for VPS deployments. This guide walks through the process of installing Alpine Linux v3.20.3 on a TransIP VPS.
Why Alpine Linux?
- Lightweight: Minimal base installation under 130MB
- Security-focused: Regular security updates and a minimal attack surface
- Resource-efficient: Perfect for VPS environments with limited resources
- Fast boot times: Boots in seconds, even on modest hardware
- Simple package management: Easy-to-use APK package manager
Prerequisites
Before starting the installation, ensure you have:
- A TransIP VPS with at least 1GB of memory
- Access to the VPS control panel
- Initial Debian installation (we’ll use this as a starting point)
- Basic knowledge of Linux command line
Step 1: Initial Debian Setup
During the initial Debian installation, make note of these important details:
- Hostname:
136-144-129-179
(your hostname will differ) - Domain name:
colo.transip.net
The default TransIP VPS setup typically creates the following partition layout:
Virtual disk 1 (vda) - 161.1 GB Virtio Block Device
#1 primary 160 GB f ext4 /
#5 logical 1.0 GB f swap swap
Step 2: Preparing for Alpine Installation
Once you have access to your Debian system, follow these steps to prepare for the Alpine installation:
- Download the Alpine Virtual ISO for x86_64:
wget https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.3-x86_64.iso
- Move the ISO to the root directory for easier access:
mv alpine-virt-3.20.3-x86_64.iso /
- Optionally, verify the ISO contents:
mkdir -p /mnt/iso
mount -o loop /alpine-virt-3.20.3-x86_64.iso /mnt/iso
ls -la /mnt/iso/boot
You should see files like vmlinuz-virt
and initramfs-virt
in the boot directory.
- Unmount the ISO and reboot the system:
umount /mnt/iso
reboot
Step 3: Booting into GRUB Shell
When the system reboots, you’ll need to access the GRUB shell:
- During boot, use the arrow keys to stop the countdown
- Press
c
to enter the GRUB command line
- In the GRUB shell, enter the following commands to boot from the Alpine ISO:
grub> ls
(hd0) (hd0,msdos1) (hd0,msdos5)
grub> set root=(hd0,msdos1)
grub> linux /alpine-virt-3.20.3-x86_64.iso
grub> boot
Step 4: Handling the Emergency Recovery Shell
After a few seconds, the boot process will stop with an error message like Mounting boot media: failed
. This is expected.
- You’ll be dropped into the Emergency Recovery Shell
- Copy the ISO to the shared memory filesystem:
cp /alpine-virt-3.20.3-x86_64.iso /dev/shm/
Note:
/dev/shm
is a special filesystem in Unix-like systems designed for shared memory. It provides a temporary, high-speed storage area accessible to all processes.
- Exit the Emergency Recovery Shell:
exit
or press CTRL-D
Step 5: Installing Alpine Linux
After exiting the Emergency Recovery Shell, the system will continue booting into the Alpine Installation Mode.
- Start the Alpine setup process:
setup-alpine
- Follow the interactive setup process:
- Set keyboard layout (default is
us
) - Set hostname (e.g.,
alpine-vps
) - Set network interface (usually
eth0
) - Configure IP address (DHCP or static)
- Set root password
- Choose timezone
- Set HTTP/FTP proxy if needed
- Select a mirror (choose one geographically close to your VPS)
- Choose SSH server (openssh is recommended)
- Select disk mode (
sys
for traditional installation) - Select disk to use (usually
vda
)
When prompted about disk usage, select
sys
to perform a traditional system installation.Choose the disk to install to (typically
vda
for VPS environments).When asked about partitioning, you can choose:
lvm
for Logical Volume Managementsys
for standard partitioningdata
for data disk mode
For most VPS setups, sys
is the appropriate choice.
- Confirm the installation by typing
y
when prompted.
Step 6: Post-Installation Configuration
After the installation completes, you’ll need to perform some additional configuration:
- Update the package repository:
apk update
- Install any additional packages you need:
apk add curl nano sudo
- Create a non-root user:
adduser username
- Add the user to the wheel group for sudo access:
adduser username wheel
- Edit the sudoers file to allow wheel group members to use sudo:
echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
- Configure the firewall:
apk add ufw
ufw allow ssh
ufw enable
- Enable and start SSH on boot:
rc-update add sshd default
service sshd start
Step 7: Reboot and Verify
Finally, reboot your system to ensure everything is working properly:
reboot
After the reboot, you should be able to log in to your newly installed Alpine Linux system.
Troubleshooting
If you encounter issues during the installation, here are some common problems and solutions:
- Network connectivity issues: Verify your network settings with
ip addr
andping google.com
- Boot failures: Make sure the GRUB configuration is correct
- Package installation errors: Check your mirror selection with
cat /etc/apk/repositories
Conclusion
You now have a fully functional Alpine Linux installation on your TransIP VPS. The lightweight nature of Alpine makes it an excellent choice for servers, providing good performance even on modest hardware while maintaining a strong security posture.
For further customization and hardening of your Alpine Linux server, refer to the official Alpine documentation.