Installing Debian Etch over SSH or a rescue console in 10 steps
Who does not know such a situation: you get a new box in the data center but not with your favorite Debian but with $FOOBAR, or the hard-drive of your box just died and you need to reinstall the system without sitting in front of it. I think everyone knows this, or can imagine it. Here is a small howto you can follow to install Debian Etch (and Sarge, Lenny, Sid, whatever) on a remote system with only SSH enabled.
1. boot up the box in rescue mode
I don't want to destroy my server, so I use a bit of virtualization: I boot grml with qemu -hda etch -cdrom ~/grml_small_0.3.iso -boot d -m 256 -redir tcp:5555:10.0.2.15:22, setup ssh and I'm ready.
In the case of cases you'll have to boot up the machine into rescue mode by calling the data center or clicking a link in the configuration interface.
2. login as root into the box, this should be easy ;)
(I do ssh -l root -p 5555 localhost for the qemu-redirect)
3. create the needed partitions
I'll do a basic install: 100MiB /boot, 1.5GiB /, 400MiB swap (my qemu has only a 2GiB image here), you should have thought about your partitions before installing ;-)
Now I call cfdisk /dev/hda and create my paritions (you of course can use a partition-tool you want, but fdisk and cfdisk are usualy installed, others maybe not).
After that you need a filesystem - I prefer ext3, so I do mkfs.ext3 twice - you maybe want to tweak it with some options - feel free to do that and don't forget mkswap ;)
4. prepare for teh ownage
mkdir /mnt/etch
mount /dev/hda2 /mnt/etch
debootstrap etch /mnt/etch http://your.local.mirr.or/debian
Now a basic Debian Etch is installed, but we still need some more things there, so we chroot inside...
5. chroot
mount -t proc proc /mnt/etch/proc
chroot /mnt/etch /bin/bash
export LC_ALL=C
6. we need /dev ;-)
cd /dev && ./MAKEDEV generic
7. configure apt, install some bytes
edit /etc/apt/sources.list like the following
deb http://your.local.mirr.or/debian etch main contrib non-free
deb-src http://your.local.mirr.or/debian etch main contrib non-free
deb http://your.local.mirr.or/security etch/updates main contrib non-free
deb-src http://your.local.mirr.or/security etch/updates main contrib non-free
apt-get update
apt-get install locales
dpkg-reconfigure locales
dpkg-reconfigure debconf
dpkg-reconfigure passwd
apt-get install grub linux-image-2.6.18-4-686 libc6-i686 less
8. install grub (or lilo if you wish)
mount /dev/hda1 /boot
grub-install /dev/hda
update-grub
9. we should mount something after boot
$EDITOR /etc/fstab:
proc /proc proc defaults 0 0
/dev/hda2 / ext3 noatime,errors=remount-ro 0 1
/dev/hda1 /boot ext3 noatime,errors=remount-ro 0 1
/dev/hda3 none swap sw 0 0
10. who needs network?
the system should be bootable now, but you still need ssh and a propperly set-up network
apt-get install openssh-server, and
$EDITOR /etc/network/interfaces
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp
(usualy you will want to use static instead of dhcp here, but qemu has a nice dhcpd built-in)
You're ready, reboot and have fun with your box -> if it won't work, back to rescue mode and happy debugging!
Comments
Great job,
never did that but always needed a way to handle these problems =)
./added > favourites
mfg kjellski