diff --git a/alpine.sh b/alpine.sh index a19ec3b..b022010 100755 --- a/alpine.sh +++ b/alpine.sh @@ -46,13 +46,11 @@ echo -n 'password' | cryptsetup open --type luks /dev/sda2 system # Set up LVM pvcreate /dev/mapper/system vgcreate vg0 /dev/mapper/system -lvcreate -L 4G vg0 -n swap lvcreate -l 100%FREE vg0 -n root # Format mkfs.ext4 -m0 /dev/sda1 mkfs.ext4 -m1 /dev/vg0/root -mkswap /dev/vg0/swap # Mount mount -t ext4 /dev/vg0/root /mnt @@ -97,7 +95,6 @@ dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/sda # Unmount and shut down umount /mnt/boot umount /mnt -swapoff -a vgchange -a n cryptsetup luksClose system poweroff diff --git a/basic.sh b/basic.sh index acfceca..9b829f1 100755 --- a/basic.sh +++ b/basic.sh @@ -5,7 +5,7 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/basic # Install packages apk --no-cache add --virtual .useful git file htop less openssh-server openssh-sftp-server -apk --no-cache add curl docker gettext kbd-misc libressl python3 py3-bcrypt py3-cffi py3-dnspython py3-jinja2 py3-requests py3-six py3-werkzeug nginx +apk --no-cache add curl docker e2fsprogs-extra gettext kbd-misc libressl python3 py3-bcrypt py3-cffi py3-dnspython py3-jinja2 py3-requests py3-six py3-werkzeug nginx util-linux # Copy profile files and settings mkdir -p /root/.config/htop /root/.ssh @@ -17,6 +17,7 @@ cp ${SOURCE_DIR}/root/.config/htop/htoprc /root/.config/htop/htoprc cp ${SOURCE_DIR}/boot/extlinux.conf /boot/extlinux.conf cp ${SOURCE_DIR}/boot/spotter.txt /boot/spotter.txt cp ${SOURCE_DIR}/etc/inittab /etc/inittab +cp ${SOURCE_DIR}/sbin/extend-disk /sbin/extend-disk >/etc/motd # Enable support for Czech characters @@ -47,7 +48,7 @@ cp -r ${SOURCE_DIR}/srv/spotter /srv/spotter ln -s /srv/spotter/cli.py /usr/bin/spotter-appmgr # Configure services -for SERVICE in consolefont crond nginx ntpd sshd spotter-appmgr; do +for SERVICE in consolefont crond nginx ntpd sshd spotter-appmgr swap; do rc-update add ${SERVICE} boot service ${SERVICE} start done diff --git a/basic/etc/inittab b/basic/etc/inittab index a56b0af..f8432af 100644 --- a/basic/etc/inittab +++ b/basic/etc/inittab @@ -2,6 +2,7 @@ ::sysinit:/sbin/openrc sysinit >/dev/null 2>&1 ::sysinit:/sbin/openrc boot >/dev/null 2>&1 +::wait:/sbin/extend-disk >/dev/null 2>&1 ::wait:/sbin/openrc default >/dev/null 2>&1 # Set up getty diff --git a/basic/sbin/extend-disk b/basic/sbin/extend-disk new file mode 100755 index 0000000..174d230 --- /dev/null +++ b/basic/sbin/extend-disk @@ -0,0 +1,39 @@ +#!/bin/sh +set -e + +# No resizing with less than 10k unused blocks +BLOCKS_FREE=$(/usr/bin/awk '/sda$/ {blocks = $3} /sda\d/ {blocks -= $3} END {print blocks}' /proc/partitions) +[ ${BLOCKS_FREE} -lt 10240 ] && exit 0 + +# Resize physical partition +# Force busybox fdisk as util-linux fdisk breaks subsequent partx command +cat <