Installing alpine linux from another linux

 

make partitin without journal and reserved space for ssd

if your pc reboots suddendly dont disable journal

sudo mke2fs -t ext4 -O ^has_journal -m 0  /dev/sda5
 
 

download static apk from gitlab release for your architecture

 https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases

chmod +x apk.static
sudo cfdik /dev/sda
mkfs.ext4 /dev/sda2  
mount /dev/sda2 /mnt
  

 bootstrap alpine base

sudo ./apk.static  -X "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" -U --allow-untrusted --root /mnt --initdb add alpine-base
 

chroot script 

nano chroot.sh
mount --rbind /dev /mnt/dev && mount --make-rslave /mnt/dev
mount --rbind /dev/pts /mnt/dev/pts && mount --make-rslave /mnt/dev/pts
mount --rbind /proc /mnt/proc && mount --make-rslave /mnt/proc
mount --rbind /sys /mnt/sys && mount --make-rslave /mnt/sys
chroot  /mnt /bin/sh  
sudo /bin/sh ./chroot.sh
 
echo "nameserver 1.1.1.1"  > /etc/resolv.conf
 setup-apkrepos
   
 

install and configure apps 

cat /etc/apk/workd
 
apk add alsa-utils brightnessctl bubblewrap cfdisk doas dosfstools e2fsprogs file firefox font-awesome font-dejavu font-dejavu-sans-mono-nerd foot grim gsettings-desktop-schemas htop i3blocks intel-media-driver iwd jq libudev-zero linux-firmware-ath10k linux-firmware-i915 linux-firmware-none linux-lts mesa-dri-gallium mingetty mpv nano nnn ntfs-3g openresolv seatd slurp socat sway wireless-regdb wl-clipboard wofi wtype zathura-pdf-mupdf
 

run setup-devd, choose mdev or udev 

else install libudev-zeroif you dont care about udev rules for android,brightness etc


startsway

if [ -z "$XDG_RUNTIME_DIR" ]; then
	XDG_RUNTIME_DIR="/tmp/$(id -u)-runtime-dir"
	mkdir -pm 0700 "$XDG_RUNTIME_DIR"
	export XDG_RUNTIME_DIR
fi

export NO_AT_BRIDGE=1
dbus-run-session sway
 

 kernel, firmware , bootloaders 

 
for systemd-boot , limeline , or stub loaders
mount efi partition to /boot as alpine install kernel and initrafs there 
mount /dev/sda1 /boot 
 
apk add systemd-boot efibootmgr
mkdir -p /boot/EFI/systemd/
cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi /boot/EFI/systemd/
mkdir -p /boot/loader/entries/ 

cat /boot/loader/entries/alpine.conf

title alpine
linux /vmlinuz-lts
initrd /initramfs-lts
options root=/dev/sda2 modules=sd-mod,ext4 quiet

apk add linux-firmware-none
# Device specific: Inspiron 3501
apk add linux-firmware-ath10k linux-firmware-i915

# Device specific: Inspiron 5559
apk add linux-firmware-amd linux-firmware-amdgpu linux-firmware-radeon linux-firmware-intel intel-media-driver
 

custom kernel try 

apk add xz-utils zstd  # whatever kernel compression
sudo apk add  build-base ncurses-dev  libssl-dev bc flex elfutils-dev bison diffutils openssl-dev
 

 service managment 

  rc-service --help
Usage: rc-service [options] [-i] <service> <cmd>...
   or: rc-service [options] -e <service>
   or: rc-service [options] -l
   or: rc-service [options] -r <service>

Options: [ cdDe:ilr:INsSZChqVvU ]
  -d, --debug                       set xtrace when running the command
  -D, --nodeps                      ignore dependencies
  -e, --exists <arg>                tests if the service exists or not
  -c, --ifcrashed                   if the service is crashed run the command
  -i, --ifexists                    if the service exists run the command
  -I, --ifinactive                  if the service is inactive run the command
  -N, --ifnotstarted                if the service is not started run the command
  -s, --ifstarted                   if the service is started run the command
  -S, --ifstopped                   if the service is stopped run the command
  -l, --list                        list all available services
  -r, --resolve <arg>               resolve the service name to an init script
  -Z, --dry-run                     dry run (show what would happen)
  -h, --help                        Display this help output
  -C, --nocolor                     Disable color output
  -V, --version                     Display software version
  -v, --verbose                     Run verbosely
  -q, --quiet                       Run quietly (repeat to suppress errors)
  -U, --user                        Run in user mode
 
 rc-update --help
Usage: rc-update [options] add <service> [<runlevel>...]
   or: rc-update [options] del <service> [<runlevel>...]
   or: rc-update [options] [show [<runlevel>...]]

Options: [ asuChqVvU ]
  -a, --all                         Process all runlevels
  -s, --stack                       Stack a runlevel instead of a service
  -u, --update                      Force an update of the dependency tree
  -h, --help                        Display this help output
  -C, --nocolor                     Disable color output
  -V, --version                     Display software version
  -v, --verbose                     Run verbosely
  -q, --quiet                       Run quietly (repeat to suppress errors)
  -U, --user                        Run in user mode 

Services & Users


setup-devd mdev

if you dont use udev you need libudev-zero for xorg/wayland-compositor
hwdrivers service is added if you select y on devd
 

rc-update add fsck sysinit

rc-update add localmount

rc-update add iwd boot
rc-update add seatd boot


rc-update add killprocs shutdown
rc-update add mount-ro shutdown

# User setup
adduser k -s /bin/ash
passwd k

addgroup k seat
addgroup k video
addgroup k audio
addgroup k wheel

 

 
autologin inittab
apk add mingetty
cat /etc/inittab 
# /etc/inittab

::sysinit:/sbin/openrc -q sysinit
::sysinit:/sbin/openrc -q boot
::wait:/sbin/openrc -q default

::sysinit:/bin/chown k:k /sys/class/backlight/intel_backlight/brightness
tty1::respawn:/usr/sbin/mingetty --autologin k --noclear --nonewline --noissue --nohostname tty1
tty2::respawn:/sbin/getty 38400 tty2

::ctrlaltdel:/sbin/reboot
::shutdown:/sbin/openrc shutdown
 
https://wiki.alpinelinux.org/wiki/Sway
https://wiki.alpinelinux.org/wiki/XDG_RUNTIME_DIR
 
cat .local/bin/startsway
#!/bin/sh

if test -z "${XDG_RUNTIME_DIR}"; then
export XDG_RUNTIME_DIR=/tmp/xdg/"${UID}"-xdg-runtime-dir
if ! test -d "${XDG_RUNTIME_DIR}"; then
mkdir -p "${XDG_RUNTIME_DIR}"
chmod 0700 "${XDG_RUNTIME_DIR}"
fi
fi
export XDG_CURRENT_DESKTOP=sway
dbus-run-session sway

at .profile 
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
if [ "$(tty)" = "/dev/tty1" ]; then
exec startsway
fi 
 
update time
 sudo ntpd -d -n -q -p pool.ntp.org