Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
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. – John Burton Feb 4 '10 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 – John Burton Feb 4 '10 at 15:22

look in to link what we do with redhat or centos to install on remote if can help you

share|improve this answer

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.

share|improve this answer
Thanks, although this appears to need an initial boot from CD which I was hoping to avoid. – John Burton Feb 4 '10 at 15:16

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.

share|improve this answer

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.

share|improve this answer
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. – John Burton Feb 4 '10 at 15:14

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

share|improve this answer

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 . If you don't mind waiting, you could use the tiny gPXE image from to boot Debian Live (which I believe then lets you install to the hard disk) over the Internet.

share|improve this answer

just boot Jeoss by ssh on rescue mode you can then mount your faulty HDD for fixing it

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.