Chạy Alpine Linux trên Oracle Cloud

Tải và ghi file ISO vào ổ đĩa VPS

curl -O 'https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/alpine-virt-3.14.2-aarch64.iso'
https://alpinelinux.org/downloads/
[email protected]:~$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0 48.9M  1 loop /snap/core18/2127
loop1     7:1    0   62M  1 loop /snap/lxd/21032
loop2     7:2    0 28.1M  1 loop /snap/snapd/12886
loop3     7:3    0 36.3M  1 loop /snap/oracle-cloud-agent/15
sda       8:0    0 46.6G  0 disk
├─sda1    8:1    0 46.5G  0 part /
└─sda15   8:15   0   99M  0 part /boot/efi

Ghi file ISO vào sda /dev/sda

sudo dd if=alpine-virt-3.14.2-aarch64.iso of=/dev/sda

Khởi động instance thông qua giao diện web

Chờ đợi vài phút sau khi khỏi động thông qua giao diện web, màn hình sẽ trông như sau:

                             GNU GRUB  version 2.06

 /----------------------------------------------------------------------------\
 |*Linux virt                                                                 |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 \----------------------------------------------------------------------------/

      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, `e' to edit the commands
      before booting or `c' for a command-line.
   The highlighted entry will be executed automatically in 0s.
  Booting `Linux virt'

Welcome to Alpine Linux 3.14
Kernel 5.10.61-0-virt on an aarch64 (/dev/ttyAMA0)

localhost login: root

Lúc này, Alpine sẽ chạy trên RAM. Login vói user là root và mật khẩu để trống.

Copy những file cần thiết từ file ảnh ISO, lúc này đang nằm ở ổ đĩa sda vào RAM

mkdir /media/setup
cp -a /media/sda/* /media/setup
mkdir /lib/setup
cp -a /.modloop/* /lib/setup

Khi những file đã được copy thì unmount sda

/etc/init.d/modloop stop
umount /dev/sda

Di chuyển những file đã copy đến thư mục phù hợp.

mv /media/setup/* /media/sda/
mv /lib/setup/* /.modloop/

Run the following commands to setup the keyboard layout, hostname, network interface, timezone, and package repositories:

setup-keymap

setup-hostname
rc-service hostname restart

setup-interfaces -a
rc-service networking start
rc-update add networking boot

setup-timezone
setup-apkrepos

Thiết lập mật khẩu cho tài khoản root:

password root

Trước khi cài lên đĩa, cài đặt một vài gói cần thiết:

apk add grub-efi
apk add efibootmgr

Set the boot and swap partition size:

# The boot partition size is set to 512MB.
export BOOT_SIZE=512
# The swap partition size is set to 1024MB.
export SWAP_SIZE=1024

Use GRUB as the bootloader as it is required for booting the system with UEFI:

export BOOTLOADER=grub
# The following makes sure grub-efi is used as the bootloader.
export USE_EFI=1

Now setup the disk:

setup-disk /dev/sda

Suốt quá trình cài đặt chọn sys mode. Quá trình trông như sau:

localhost:~# setup-disk /dev/sda
The following disk is selected:
  sda   (50.0 GB ORACLE   BlockVolume     )
How would you like to use it? ('sys', 'data', 'lvm' or '?' for help) [?] sys
WARNING: The following disk(s) will be erased:
  sda   (50.0 GB ORACLE   BlockVolume     )
WARNING: Erase the above disk(s) and continue? (y/n) [n] y
Partition id "vfat" is not supported!
GPT PMBR size mismatch (88035 != 97677311) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Creating file systems...
Installing system on /dev/sda3:
Installing for arm64-efi platform.
Installation finished. No error reported.
100% ████████████████████████████████████████████==> initramfs: creating /boot/initramfs-virt
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-virt
Found initrd image: /boot/initramfs-virt
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done

Installation is complete. Please reboot.

Cài đặt login với SSH (OpenSSH)

https://wiki.alpinelinux.org/wiki/Setting_up_a_ssh-server

vi /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication no
/etc/init.d/sshd restart

Cài đặt Alpine linux thông qua SSH từ console

Đọc thêm

https://www.alextsang.net/articles/20191006-063049/index.html

https://www.cyberciti.biz/faq/how-to-change-root-password-on-alpine-linux/

https://docs.genesys.com/Documentation/System/latest/DDG/InstallationofDockeronAlpineLinux

https://gist.github.com/bakkujp/cdef0091f25b2a537307ab410809ea81

https://wiki.alpinelinux.org/wiki/Docker