Using custom Debootstrap to install Ubuntu version of your choice

There are times when you want to install a newer version of the Ubuntu server but your Cloud/VPS provider might not include the version you want. This could be due to some of the following reasons.

  • Debian rescue cd or Debian live images are provided but you want to install Ubuntu.
  • Only LTS version are provided.
  • They do not provide the Ubuntu version you need.
  • You do not trust the Cloud/VPS or third party provider and want to do a clean installation based on your choice.
  • You need to use custom installation such that you can encrypt the disks.

If you are running debian flavored linux it is easy to overcome the above limitations.

Steps

  • Remove the default debootrap that was installed if it exists
apt remove --yes debootstrap
  • Create a temporary directory to work on.
mkdir -p /tmp/debootstrap
  • Change the directory to the temporary working directory.
cd /tmp/debootstrap
  • Download the deboostrap of your choice.
wget https://mirrors.kernel.org/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.124_all.deb
  • Extract .deb file
ar -x *.deb
zcat /tmp/debootstrap/data.tar.gz | tar xv
  • Copy the extract files to the root
cp -r usr /
  • Cleanup the working directory
rm -rf /tmp/debootstrap

Now you should be able to use the new debootstrap.

Script

You are looking to automate here is the entire script with slight changes allowing you to re-run the script multiple times to try it out.

apt remove --yes debootstrap || true
rm -rf /tmp/debootstrap
mkdir -p /tmp/debootstrap
pushd /tmp/debootstrap
wget https://mirrors.kernel.org/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.124_all.deb
ar -x *.deb
zcat /tmp/debootstrap/data.tar.gz | tar xv
cp -r usr /
popd
rm -rf /tmp/debootstrap