0 / 0
Skip to content

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

Debian Installation Screen

Step 2: Preparing for Alpine Installation

Once you have access to your Debian system, follow these steps to prepare for the Alpine installation:

  1. Download the Alpine Virtual ISO for x86_64:
bash
wget https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.3-x86_64.iso
  1. Move the ISO to the root directory for easier access:
bash
mv alpine-virt-3.20.3-x86_64.iso /
  1. Optionally, verify the ISO contents:
bash
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.

ISO Verification

  1. Unmount the ISO and reboot the system:
bash
umount /mnt/iso
reboot

Step 3: Booting into GRUB Shell

When the system reboots, you’ll need to access the GRUB shell:

  1. During boot, use the arrow keys to stop the countdown
  2. Press c to enter the GRUB command line

GRUB Menu

  1. 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

GRUB Command Line

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.

  1. You’ll be dropped into the Emergency Recovery Shell
  2. Copy the ISO to the shared memory filesystem:
bash
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.

  1. Exit the Emergency Recovery Shell:
bash
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.

  1. Start the Alpine setup process:
bash
setup-alpine
  1. 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)
  1. When prompted about disk usage, select sys to perform a traditional system installation.

  2. Choose the disk to install to (typically vda for VPS environments).

  3. When asked about partitioning, you can choose:

    • lvm for Logical Volume Management
    • sys for standard partitioning
    • data for data disk mode

For most VPS setups, sys is the appropriate choice.

  1. 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:

  1. Update the package repository:
bash
apk update
  1. Install any additional packages you need:
bash
apk add curl nano sudo
  1. Create a non-root user:
bash
adduser username
  1. Add the user to the wheel group for sudo access:
bash
adduser username wheel
  1. Edit the sudoers file to allow wheel group members to use sudo:
bash
echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
  1. Configure the firewall:
bash
apk add ufw
ufw allow ssh
ufw enable
  1. Enable and start SSH on boot:
bash
rc-update add sshd default
service sshd start

Step 7: Reboot and Verify

Finally, reboot your system to ensure everything is working properly:

bash
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 and ping 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.

References