Skip to content

Instantly share code, notes, and snippets.

@wwng2333
Last active February 12, 2023 13:41
Show Gist options
  • Save wwng2333/2a5a4d503242850859e38c45434a423f to your computer and use it in GitHub Desktop.
Save wwng2333/2a5a4d503242850859e38c45434a423f to your computer and use it in GitHub Desktop.
mkdir overlay
cd overlay
mkdir -p etc/ssh etc/network etc/runlevels/{default,boot,sysinit,shutdown} root/.ssh etc/lbu
cp -a /etc/{passwd,group,shadow,gshadow,hostname,resolv.conf,network/interfaces,ssh} etc/
cp /etc/network/interfaces etc/network
cp -a /root/.ssh/authorized_keys root/.ssh
echo "/root/.ssh" > etc/lbu/include
sed -i -e '/^root:/s:/bin/bash:/bin/ash:' etc/passwd

Then edit etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
       address 172.16.0.122/32
       gateway 172.16.0.1

edit etc/resolv.conf

nameserver 172.16.0.2
mkdir -p etc/apk
echo "alpine-base iproute2 openssh" > etc/apk/world

ln -s /etc/init.d/{hwclock,modules,sysctl,hostname,bootmisc,syslog} etc/runlevels/boot/
ln -s /etc/init.d/{devfs,dmesg,mdev,hwdrivers} etc/runlevels/sysinit/
ln -s /etc/init.d/{networking,sshd} etc/runlevels/default/
ln -s /etc/init.d/{mount-ro,killprocs,savecache} etc/runlevels/shutdown/
tar czf ../host.apkovl.tar.gz *
cp ../host.apkovl.tar.gz /
wget https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-virt-3.17.2-x86_64.iso
#wget https://mirrors.ustc.edu.cn/alpine/v3.17/releases/x86_64/alpine-virt-3.17.2-x86_64.iso
mkdir /cdrom
mount alpine*.iso /cdrom -o loop
cp -a /cdrom/* /
apt install extlinux

then create /boot/extlinux.conf

timeout 20
prompt 1
default grsec
label grsec
  kernel /boot/vmlinuz-virt
  append initrd=/boot/initramfs-virt alpine_dev=vda1:ext4 modloop=/boot/modloop-virt modules=loop,cramfs,sd-mod,usb-storage,ext4 quiet
extlinux -i /boot
reboot

after reboot, add repositories at /etc/apk/repositories

https://dl-3.alpinelinux.org/alpine/v3.17/main/

unmount /media/vda1, then normal install it.

/etc/init.d/modloop stop
apk update
umount /media/vda1
setup-alpine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment