Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Last active February 24, 2026 20:36
Show Gist options
  • Select an option

  • Save gdamjan/acb23bd93a4ccf7daef49a3bed3dd94f to your computer and use it in GitHub Desktop.

Select an option

Save gdamjan/acb23bd93a4ccf7daef49a3bed3dd94f to your computer and use it in GitHub Desktop.
create vm image on scaleway for scaleway

Create a VM image for scaleway

  1. Start a surrogate instance with an aditional "target" volume
  2. run bootstrap commands
  3. shutdown
  4. make an image from target volume

Target package selection

UBUNTU=resolute
UBUNTU_COMPONENTS=main,universe

PKGS=(
  systemd
  systemd-boot
  systemd-boot-efi
  systemd-ukify
  systemd-resolved
  systemd-timesyncd
  systemd-sysv
  systemd-cron
  systemd-container
  systemd-repart
  initramfs-tools
  linux-image-virtual
  dbus-broker
  iproute2
  openssh-server
  less
  vim
  bash-completion
)

prepare partitions and filesystems

sfdisk /dev/sdb <<EOF
label: gpt
size=512M, type=uefi
size=+, type="linux root (x86-64)"
EOF

mkfs.vfat -n ESP /dev/sdb1
mkfs.ext4 -L ROOT /dev/sdb2

mount --mkdir /dev/sdb2 /mnt/
mount --mkdir /dev/sdb1 /mnt/efi/

target system config

uki

mkdir -p /mnt/etc/kernel/
cat <<EOF > /mnt/etc/kernel/install.conf
layout=uki
BOOT_ROOT=/efi
EOF

fstab and kernel command line

# fixed sda1, sda2 until systemd-gpt-auto-generator works
echo 'root=LABEL=ROOT rw console=tty1 console=ttyS0' > /mnt/etc/kernel/cmdline
echo 'LABEL=ESP /efi vfat umask=0077,rw,nodev,nosuid,noexec,nosymfollow 0 0' >> /mnt/etc/fstab 

network

mkdir -p /mnt/etc/systemd/network/
cat <<EOF > /mnt/etc/systemd/network/ens2.network
[Match]
Name=ens2

[Network]
DHCP=yes
EOF

repart

mkdir -p /mnt/etc/repart.d/
cat <<EOF > /mnt/etc/repart.d/root.conf
[Partition]
Type=root
GrowFileSystem=true
EOF

Bootstrap

# concat array with commas (,)
IFS=","

debootstrap --variant minbase --merged-usr \
  --include="${PKGS[*]}" \
  --components=$UBUNTU_COMPONENTS \
  $UBUNTU /mnt/

Make it bootable

chroot /mnt
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs udev /dev

bootctl install --no-variables
dpkg-reconfigure linux-image-6.19.0-6-generic

Finalize

systemctl --root=/mnt enable systemd-networkd

chroot /mnt apt clean
rm /mnt/etc/machine-id
passwd -R /mnt root
cp .ssh/authorized_keys /mnt/root/.ssh/

umount -R /mnt
poweroff

apps:

  • cgi-bin scripts
  • thelounge
  • certbot
  • tt-rss portable service
  • convertor
  • soju, gamja

hosts:

  • damjan.softver.org.mk
  • chat.softver.org.mk
  • rss.softver.org.mk
  • lounge.softver.org.mk
  • convertor.ot.mk / preobrazen.ie.mk
  • ip.ie.mk / ipv6.ie.mk / ipv4.ie.mk

packages:

  • nginx-light

  • libnginx-mod-stream

  • libnginx-mod-nchan

  • libnginx-mod-http-echo

  • uwsgi-plugin-python3

  • python3-certbot-nginx

  • systemd-cron

  • systemd-container

  • systemd-boot

  • systemd-ukify

apt purge modemmanager rsyslog mdadm udisks2 multipath-tools unattended-upgrades fwupd python3-distupgrade ubuntu-release-upgrader-core netplan.io plymouth snapd console-setup-linux apt autoremove --purge

@gdamjan
Copy link
Author

gdamjan commented Feb 23, 2026

TODO:

  • setup grow fs
  • cloud-init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment