Alpine Linux(UEFI) Semi-Automatic Installation
Enter Installation
Your login username is root, password is empty
Check UEFI
test -d /sys/firmware/efi && echo UEFI || echo BIOS
Keyboard Layout
Answer some questions
setup-keymap
## answer 'us' twice
Hostname
setup-hostname <your_hostname>
Networking
Alpine Linux’s wiki recommend you using ethernet to connect internet
But you can also use setup-interfaces to use wireless connection
Answer some questions
setup-interfaces
After the configuration
rc-service networking start
rc-update add networking boot
Apk Repositories
You can find all repositories mirrors in here
Edit /etc/apk/repositories
vi /etc/apk/repositories
For Chinese user, you can use example below
# /etc/apk/repositories
...
https://mirrors.aliyun.com/alpine/latest-stable/main
https://mirrors.aliyun.com/alpine/latest-stable/community
Finally, update your repositories
apk update
Timezone
We need to install tzdata
apk add tzdata
Set your region info
install -Dm 0644 /usr/share/zoneinfo/<Region>/<Country> /etc/zoneinfo/<Region>/<Country>
export TZ='<Region>/<Country>'
echo "export TZ='$TZ'" >> /etc/profile.d/timezone.sh
For Chinese user
install -Dm 0644 /usr/share/zoneinfo/Asia/Shanghai /etc/zoneinfo/Asia/Shanghai
export TZ='Asia/Shanghai'
echo "export TZ='$TZ'" >> /etc/profile.d/timezone.sh
Root password
passwd
SSH
Answer some questions
setup-sshd
NTP
Answer some questions
setup-ntp
Disk
Useful Tools
Install some useful packages
apk add cfdisk dosfstools e2fsprogs e2fsprogs-extra
Partition
(Optional)
If you wish your Alpine Linux live with other Linux distributions, you can share your existingbootandswappartitions to Alpine Linux
List All Disks and Partitions
fdisk -l
Change Partition Table
You can use cfdisk to do this step.
cfdisk /dev/<your_disk>
Partition Table Example
| mount point | partition | type | recommend size |
|---|---|---|---|
| /mnt/boot | /dev/efi_boot_partition | EFI | >=300M |
| [SWAP] | /dev/swap_partition | Linux Swap | >=512M |
| /mnt | /dev/root_partition | Linux Filesystem | space left |
Partition Table Example (With Home Partition)
| mount point | partition | type | recommend size |
|---|---|---|---|
| /mnt/boot | /dev/efi_boot_partition | EFI | >=300M |
| [SWAP] | /dev/swap_partition | Linux Swap | >=512M |
| /mnt | /dev/root_partition | Linux Filesystem | space left |
| /mnt/home | /dev/home_partition | Linux Filesystem | space left |
Format
- For Boot Partition
mkfs.fat -F 32 -n ALPINEBOOT /dev/efi_boot_partition
- For Swap Partition
mkswap /dev/swap_partition
- For Root Partition
mkfs.ext4 -L ALPINEROOT /dev/root_partition
- For Home Partition (If you have)
mkfs.ext4 -L ALPINEHOME /dev/home_partition
Mount
- Mount Root Partition
mount /dev/root_partition /mnt
- Mount Boot Partition
mkdir /mnt/boot
mount /dev/boot_partition /mnt/boot
- Mount Swap Partition
swapon /dev/swap_partition
- Mount Home Partition (If you have)
mkdir /mnt/home
mount /dev/home_partition /mnt/home
Install Basic Package
I only want Alpine Linux!
setup-disk -m sys /mnt
You can reboot your system now
I already have other Linux distribution, and they share same grub partition
Setting BOOTLOADER=none in order to make the script avoiding grub installation
BOOTLOADER=none setup-disk -m sys /mnt
Then, you can create a menuentry in /mnt/boot/grub/custom.cfg
You can use
blkidto find your root partition UUID
# /mnt/boot/grub/custom.cfg
menuentry "Alpine Linux" { ## <-- You can change the name
search --no-floppy --fs-uuid --set=root 88D1-11D6
# You must chage Boot Partition UUID above
linux /vmlinuz-lts root=UUID=8de6973a-4a8c-40ed-b710-c4e2b42d6b7a modules=sd-mod,usb-storage,ext4 quiet
# You must chage Root Partition UUID above
initrd /initramfs-lts
}