InstantVM based on Devuan Excalibur

NOTE: WORK IN PROGRESS - I am writing these as I go through the process, therefore until this notice is removed, they are incomplete / untested.

These notes are for creating a virtual server installed and running the way I like it, in under 2 minutes (time is dependent on the hosting hardware, Internet connection speed, and how many packages have been updated since you created the template).

It's based on the previous notes I wrote when doing this for Chimaera and Daedalus.

  1. Create a 3Gbyte partition Excalibur VM and go through the standard Devuan installation process, but do not re-start the server at the end
    • Use DHCP networking on eth0
    • Set the hostname to (literally) MyHostNameGoesHere
    • Leave the domain name blank
    • The root password, the first user and its password, will be replicated on every VM created from this image
    • Select Manual partitioning
      • Create vda1 of as large a size as possible, but leave around 1-2Mbyte free (yes, megabytes) for vda2 - try 3218850Kb as the size for vda1
        • Make vda1 an ext4 partition for /
        • Set vda2 to "do not use" (this should end up in the summary as 1Mbyte)
      • Create vdb1 as swap
    • For a 3 Gbyte root FS, the package selector won't offer a graphical desktop environment, but "SSH server" should be selected by default - this is exactly what you want for a server
    • When the installer wants to restart the machine, pause the Grub menu and then just power off the VM
  2. Use ddrescue or similar to take a copy of the resultant disk image, just in case something goes horribly wrong with the next few steps and you need to start again - this saves you going through the entire Devuan installation process again
  3. Use kpartx to mount the (as yet never-booted-up) root partition and preserve the pristine /var/log directory, copy some files to be unpacked later, and then adjust some configuration files:
    kpartx -av /dev/VG/VMname
    mount /dev/mapper/VG-VMname1 /mnt
    rsync -Pav fs.Excalibur.tgz /mnt
    cd /mnt
    rsync -Pav var/log/ var/log.pristine
    rm -f etc/apt/sources.list etc/apt/sources.list~
    sed -i "s/export PATH/export PATH\nexport HISTSIZE=10000\nexport HISTFILESIZE=10000\nexport HISTCONTROL=none\nexport HISTTIMEFORMAT=\"%F %T \"\nexport QUOTING_STYLE=literal/" etc/profile
    sed -i "s/sulogin/sulogin -t 30/" etc/init.d/checkfs.sh
    sed -i "s/:root:/:MyHostNameGoesHere:/" etc/passwd
    cd ~
    umount /mnt
    dd if=/dev/zero of=/dev/mapper/VG-VMname2
    kpartx -dv /dev/VG/VMname
    • Note: The fs.Excalibur.tgz file contains:
      etc/apt/apt.conf.d/42norecommendationsplease
      etc/apt/apt.conf.d/42nosuggestionsplease
      etc/apt/sources.list.d/Excalibur.list
      etc/boot.d/firstboot
      etc/cron.midnight/
      etc/cron.midnight/.placeholder
      etc/cron.minutely/
      etc/cron.minutely/.placeholder
      etc/cron.yearly/
      etc/cron.yearly/.placeholder
      etc/cron.daily/backup
      etc/crontab
      etc/fstab
      etc/network/interfaces
      etc/ssh/ssh_config.d/nohash.conf
      etc/ssh/ssh_config.d/dsa.conf
      etc/ssh/sshd_config.d/root.conf
      etc/timezone
      etc/rsyslog.d/default.conf
      etc/rsyslog.d/central.conf
      home/youruser/.ssh/authorized_keys
      root/.ssh/authorized_keys
      root/.ssh/backup.id_rsa
      root/.ssh/backup.id_rsa.pub
      root/.ssh/known_hosts

      These will be unpacked onto the new system in the next step.

  4. Start the VM, log in as root, and run the following commands on it (adjust as appropriate for your time zone etc.):
    tune2fs -L rootfs /dev/vda1
    ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime
    cd /
    tar -xvf fs.Excalibur.tgz
    rm -f fs.Excalibur.tgz
    apt-get install -y aptitude
    aptitude install -y less openntpd rsync vim
    aptitude purge -y nano vim-tiny
    echo 'syntax off' >>~/.vimrc
    [ -e /etc/default/su ] || echo ALWAYS_SET_PATH=yes >/etc/default/su
    cat /etc/default/su | grep -q ALWAYS_SET_PATH || echo ALWAYS_SET_PATH=yes >>/etc/default/su
    aptitude install -y parted acpi{d,-support-base} sendmail s-nail dnsutils
    echo 'RESUME=LABEL=swap' >/etc/initramfs-tools/conf.d/resume
    update-initramfs -k all -u
  5. Shut down the server

You now have a VM server image which can be ddrescue'd over the top of a blank VM partition (3 Gbytes or bigger), and when booted, will be a usable VM in under 2 minutes using the NewInstantVM script..


Go up
Return to main index.