I have a small linux server that I need to reinstall linux on (Debian stable 64 bit x86).

I have physical access to the machine but it doesn't have any external devices such as a cdrom and does not appear to be able to boot from a network or USB stick.

It does have an existing installation of linux on though and I can ssh to the machine and have root access but it's badly broken and I have no real idea what state the machine is in so wish to wipe it out and do a completely fresh install.

Is there any way I can do this using only remote access using ssh and what i can download to the machine?

9 Answers 9


The way to achieve your goal, without having the ability to boot from cd/network/external device, is to use the existing installation to install a fresh OS to another filesystem and then, once you're done, tell the bootloader to boot to the new filesystem. This was much more common in times past (perhaps 10 years or more ago) than it is now, and if you search you will find discussion of exactly this. I have done this in the distant past with slackware, gentoo, linuxfromscratch and others, but I think it can be done, without too much effort, with most modern linux/BSD distributions.

For example, in Slackware's setup you can specify a 'target' which by default is /, but you would set it to where you had mounted your secondary filesystem.

Gentoo's installation handbook makes it quite clear; all you would need to think about would be the sections on 'preparing your disks' and 'configuring your bootloader'.

Having said all that, this is not trivial and if you don't have a good understanding of how things work, you're unlikely to get it right the first time. It will be an interesting educational experience, but since you have physical access, you'll probably get a quicker, better result by working out how to remove the constraint that means you can't use a more typical installation process. In other words, add a cd drive or something.

  • Thanks, I did some reading and it looks like I could reformat my swap parition as a filesystem and install a minimum system in there. Then boot off that and reinstall into the main filesystem... Seems a lot of work though, it likely will be easier to obtain and install a CD after all. Feb 4, 2010 at 15:21
  • I'll accept this answer as it gave me what i needed to google for, but thanks for all the other answers too, will +1 as appropriate Feb 4, 2010 at 15:22

Even though this article talks about Suse instead of Debian, the process is much the same. It seems that the author is installing linux remotely through SSH much like you are talking about. Take a look at the screen shots and you should be able to work through this.

Good luck and hope this helps some.

  • Thanks, although this appears to need an initial boot from CD which I was hoping to avoid. Feb 4, 2010 at 15:16

look in to link what we do with redhat or centos to install on remote http://kbase.redhat.com/faq/docs/DOC-10526 if can help you


You can use debootstrap to install to another partition (aside: hopefully you already use lvm for partitioning flexibility), and reboot to that partition. A neat trick trick to reboot without changing your bootloader is kexec.

Once your system is stable, you'll have to tell the bootloader about the new partition; you can use grub-reboot to boot the new entry and grub-set-default for a permanent change to the new entry.


You need to remaster Debian ISO image.

TL;DR; Download ISO from here Ciborski's guide to remote Debian installation over SSH

Long answer: To do this you should read Debian GNU/Linux Installation Guide and modify boot parameters in /iso/isolinux and /iso/boot so it boots with auto parameter. This will make the installer skip keyboard configuration, language, etc.

You also need to include preseed file in the ISO regarding network configuration.

Example that works for me:

d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto

d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain

d-i hw-detect/load_firmware boolean true

d-i anna/choose_modules string network-console
d-i preseed/early_command string anna-install network-console
d-i network-console/password password root
d-i network-console/password-again password root

However if you need a quick and dirty solution you can just download premade ISO with Debian 9 x86_64 from my website https://tomasz.ciborski.com/debian-installation-over-ssh/

Result: ssh installer console


i don't think this is possible. when you connect via ssh to your machine and then wipe out everything, your ssh server is gone and with him your connection.

when your server has no cd/dvd drive and does not boot from usb/network, how did you install your server the first time?

one possibility are remote management cards (e.g. rsa, ilo, ...). with them you can attach iso images or local cd/dvd/usb drives to the server and install from these devices.

  • I installed first time using a CDROM "borrowed" from another machine, and of course will do that again if necessary. But it's not at all convenient at the moment to do so, hence the question. Feb 4, 2010 at 15:14

You might want to take a look at debootstrap to do what @dotplus suggested.


To clarify your original question, by "small server", I'm guessing you don't mean server class hardware with additional features that let you simulate an attached CD-ROM or get remote console access out-of-band, correct? It's just a desktop PC being used as a server?

To answer, it's certainly possible to initiate the installation of a Linux distribution from an existing OS via ssh. I have done a similar thing a number of times, usually with Red Hat-derived distros, but the principles should apply here.

Copy the installation kernel and initrd to /boot of the old OS, edit the boot configuration (GRUB/LILO/whatever) so that the default is to boot the install kernel, along with arguments from the install media boot config (isolinux.cfg if it's a traditional CD or DVD), add in whatever arguments you need to allow the install init system to find the install media (in my case I usually did an NFS install). Once the installation routine is bootstrapped it is no different to an installation started from PXE/DVD/any other method.

Depending on boot arguments passed to the kernel/init/installer, you can either start an interactive install that you take control of somehow (I have used Red Hat's vnc installation feature [I have no idea if Debian offers a similar facility], usually connecting to a listening viewer running on my desktop; in your case, you coudl go and stand in front of the machine) or have the installation entirely scripted, such that once it boots from the installation kernel, you do not need to interact with it until it reboots into your newly installed OS. Be warned that with this method, if you are wiping out the old OS, should it fail after having repartitioned or mkfs'ed the /boot FS, you will be left with an un-bootable system, so I recommend testing any scripted installation thoroughly first.

In my case, this has saved me a great deal of time (much of the work for unattended installs already having been done), in your case, if it's just for one machine, you might find it less work to take another approach.

Regarding network booting, it's perfectly possible to have GRUB or LILO boot a gPXE image that then can do PXE on your NIC. Get a prebuilt .lkrn image from http://rom-o-matic.net/gpxe/gpxe-1.0.0/contrib/rom-o-matic/ . If you don't mind waiting, you could use the tiny gPXE image from http://boot.kernel.org/ to boot Debian Live (which I believe then lets you install to the hard disk) over the Internet.


just boot Jeoss by ssh on rescue mode you can then mount your faulty HDD for fixing it http://www.vercot.com/~jeoss/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .