How to install Alpine Linux on Proxmox

Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox. Alpine Linux Homepage

Proxmox Virtual Environment is a complete open-source platform for enterprise virtualization. With the built-in web interface you can easily manage VMs and containers, software-defined storage and networking, high-availability clustering, and multiple out-of-the-box tools using a single solution. Proxmox VE Homepage

In this guide, I will show you how install and configure Alpine Linux VM in Proxmox.

Test environment

1. Downloading Alpine Linux ISO

Download latest iso image for you architecture here https://www.alpinelinux.org/downloads There are few version of distribution. Download VIRTUAL it is similar to standard. Slimmed down kernel. Optimized for virtual systems. I will install version x86_64 v3.18.3 (Released Aug 07, 2023).

Copy ISO url and download sha256 file Copy ISO url

Now let's download ISO to Proxmox storage. Insert ISO url and press Query URL Insert ISO url

Select hash algorithm SHA-256 and insert hash from sha256 file Select hash algorithm

Successefull download Successefull download

2. Creating a Proxmox VM

Follow these steps to create a new VM in Proxmox:

Click on "Create VM" in top right corner.

Configure VM name and ID Configure VM

Select Alpine Linux ISO image from storage Select ISO image from storage

Check Qemu Agent option Check Qemu Agent option

Set maximum disk size, disk will be created with minimum size and expand if needed Set maximum disk size

Set Sockets and Cores count and select Type:host
Set Sockets and Cores count

Enter minimum and maximum RAM for VM Allocate RAM for VM In my environment VM work normal even with 256Mb. Adjust memory settings to your needs of your applications.

Configure Networking Configure Networking Leave all options default.

Review configuration and click Finish Review configuration

3. Setting Up the VM

Install Alpine Linux by following the setup process.

Start VM and open Console to VM Start VM

Login to VM, use default user name: root. Start setup process with command:

setup-alpine

Set "keyboard layout" and other options, here is my:

Select keyboard layout:us  
Select variant: us  
Enter system hostname:localhost  
Initialize network interface [eth0]:<enter>  
Ip address for eth0: [dhcp]  
Set network configuration?: [n]  
Change password for root  
Set timezone: [UTC]  
Set network proxy: [none]

Set install options

Set network repository mirror. (f - fastest mirror)

Enter mirror number (1-73) (or r/f/e/done): f   

Set network repository mirror

Create new user

Setup user: user1  
Set ssh key: [none]  
Set user password:   
Set ssh server: [openssh]

Create new user

Configure virtual disk, look disk name after Available disk are:

Select disk where OS will be installed: sda  
How would you like to use it?: sys  
Erase above disk(s) and continue? y

Configure virtual disk Reboot system

Login as root user and update system

apk update 
apk upgrade

Login as root

4. Install QEMU Guest Agent

Qemu Guest Agent used to exchange information between the host and guest, and to execute command in the guest. Let's install it on our VM.

Check that QEMU Guest Agent is enabled in VM Check that QEMU Guest Agent

Currently Qemu Guest Agent information not available Qemu Guest Agent information not available

Uncomment community repository in file /etc/apk/repositories, qemu agent package located in community repository.

vi /etc/apk/repositories

file content should looks like this:

#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.18/main
http://dl-cdn.alpinelinux.org/alpine/v3.18/community

Install and start Qemu Agent

apk add qemu-guest-agent
rc-update add qemu-guest-agent
service qemu-guest-agent status
service qemu-guest-agent start

Install Qemu Agent

Now host can interact with VM Qemu Guest Agent and show information from VM Qemu Guest Agent shows information from VM

5. Add existing user to root group

We create user user1 on step 3, now lets add this user to root group. First login as root like we did in step 3. Then exec this commands:

apk add sudo
USER='user1'
echo "$USER ALL=(ALL) ALL" > /etc/sudoers.d/$USER && chmod 0440 /etc/sudoers.d/$USER
exit

Here we add package sudo, create file /etc/sudoers.d/user1 and set permission to file.

Next logout with command:exit then login as user user1 and now you can execute command with root permission. All you need is just add sudo before command. Add existing user to root group

6. Add new user to root group

Login as root like we did in step 3. To add new user with name user2 execute these commands

apk add sudo
USER='user2'
adduser -g "${USER}" $USER
echo "$USER ALL=(ALL) ALL" > /etc/sudoers.d/$USER && chmod 0440 /etc/sudoers.d/$USER
exit

Here we add package sudo. create user user2 and group user2, create file /etc/sudoers.d/user2 and set permission to file.

Next logout with command:exit then login as user2 and execute command with root permission. Add new user to root group

7. Access VM from network

Find VM IP address in Proxmox UI on VM Summary tab. Then use any ssh client and login with user user1 or user2. In my case it will looks like this:

ssh [email protected]

Access VM from network