InstantVM based on Devuan Daedalus

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.

  1. Create a 3Gbyte partition Daedalus 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 -a /dev/LVM/VMname
    mount /dev/mapper/LVM-VMname1 /mnt
    rsync -Pav fs.Daedalus.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
    echo -e "PermitRootLogin yes\nPubkeyAcceptedKeyTypes=+ssh-dss" >etc/ssh/sshd_config.d/dss.conf
    echo "HashKnownHosts no" >etc/ssh/ssh_config.d/nohash.conf
    sed -i "s/sulogin/sulogin -t 30/" etc/init.d/checkfs.sh
    sed -i "s/#kernel.printk = 3 4 1 3/kernel.printk = 3 4 1 3/" etc/sysctl.conf
    sed -i "s/:root:/:MyHostNameGoesHere:/" etc/passwd
    cd ~
    umount /mnt
    dd if=/dev/zero of=/dev/mapper/LVM-VMname2
    kpartx -d /dev/LVM/VMname
    • Note: The fs.Daedalus.tgz file contains:
      etc/apt/apt.conf.d/42norecommendationsplease
      etc/apt/apt.conf.d/42nosuggestionsplease
      etc/apt/sources.list.d/Daedalus.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/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 and run the following commands on it:
    tune2fs -L rootfs /dev/vda1
    ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime
    cd /
    tar -xvf fs.Daedalus.tgz
    rm -f fs.Daedalus.tgz
    apt-get install -y aptitude
    aptitude install -y less ntp 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 (2 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.