DEV Community

José Miguel Moreno
José Miguel Moreno

Posted on

From Ubuntu to Debian without any external storage device

Say you have a machine, probably a virtualized one, running Ubuntu or any other similar GNU/Linux distribution. The thing is, you don't want to run Ubuntu anymore on that particular machine and you decide to nuke the entire disk and install Debian 10.

But, and here's the catch, you're not able to plug any bootable USB stick or mount a CD/DVD! Also, your BIOS/UEFI doesn't support network booting (because of course not) and you're running extremely low on storage space.

You may be asking: "How the f$%&! did you manage to get into such troublesome situation?" and "Is it really possible to overwrite the OS at this point?". Well, as you might have probably guessed by the title of this post, it is!

My current (hypothetical) situation

So, let's recap. I have a virtual machine that...

  • Has no working USB ports
  • Has no CD/DVD drive
  • Has a limited BIOS with no support for network booting
  • Has less than 100 MB of disk space left

This means that:

  • I cannot burn the Debian Installer to a USB drive
  • I cannot mount the Debian Installer ISO
  • I cannot use the Debian Installer via Network Boot
  • I cannot create a partition to copy the Debian Installer to and boot from there

The (surprisingly easy) solution

Believe or not, there's still a way to install Debian on this crappy machine. You just need three things: "mini.iso", GRUB2 and at least 100 MB of RAM. And that's all.

First of all, you need to download the "mini.iso" file from the Debian Network Installer. This ISO is a 40 MB, minimal bootable system that can install Debian providing you have a working Internet connection.

You can download the latest version of this file from the official Debian Project page using this link.

The Debian Mini ISO file

Now copy that file to /boot:

~$ sudo cp debian.iso /boot/debian.iso

We'll use GRUB to dump that ISO to RAM and then boot to it. In order to achieve it, modify the /etc/grub.d/40_custom configuration file to add the following menu entry:

menuentry "debian-installer" {
  set isofile='/boot/debian.iso'
  loopback loop $isofile
  linux (loop)/linux priority=low toram vga=788 ---
  initrd (loop)/initrd.gz
}

You may also need to modify the /etc/default/grub file to display the entry selection menu at boot:

#GRUB_HIDDEN_TIMEOUT=0 # <--- Make sure this is commented
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10

Lastly, call update-grub to apply the changes you've just made:

~$ sudo update-grub

At this point, you should be able to reboot the VM and get the following screen:

GRUB selection menu

The only thing left to do is boot to "debian-installer" and follow the steps until you finish installing Debian.

Top comments (0)