I recently installed debian stable/squeeze on an old-ish laptop. The machine was already running squeeze, but I wanted to upgrade the hard drive from the original 80GB to a larger 250GB drive. I had an extra 250GB drive that came with my new laptop, but I replaced it with a 500GB drive as soon as I bought it.
The old laptop hard drive had an existing windows XP NTFS partition that I wanted to copy over to the 250GB drive before I installed debian. I didn't want to copy over the debian install from the 80GB drive. The fresh install on the old laptop was intended as a replacement machine for my wife's even-older laptop, which has started freezing frequently due to what I believe to be a failing motherboard. My wife doesn't want any of the developer stuff that I had on my old debian system. Instead, I was going to copy her data over from her laptop. Confusing enough?
I downloaded a x86 debian squeeze net-install image and copied it to a USB pen drive, but I discovered that, incredibly, my old laptop BIOS would not boot from USB. Lame.
linux installation methods
I've installed various linux distros over the years. The most complicated one was probably a slackware installation onto a 486 laptop with no optical drive, USB, or ethernet. I started out by booting an installer bootstrap image from a 3.5" floppy disk and finished that installation by mounting the rest of the installation media over NFS using a Null-Printer parallel cable with PLIP networking.
I've also set up automated kickstart installs of centos guests on Xen servers, and I've installed SuSE servers located halfway across the USA remotely over an IPMI console. I've installed headless servers from standard boot media using a console provided by a serial null-modem cable. In addition, I've done the usual, simple installs from optical media or USB. However, I had never installed linux from a PXE boot.
Over the years, I've burned way too many linux installation CDRs that I've used once, put in a desk drawer, and then threw away a couple years later when they were obsolete by several versions. I hate wasting stuff, and I decided to finally get around to learning about PXE booting so I can stop throwing away CDRs after a single use. Caveat: I realize that, going forward, almost all computers will support booting from USB, and for 1-off installations, that's the easiest option when it is available. In any case, it was not available for my old laptop.
pxe boot setup
Preboot Execution Environment (PXE) booting uses DHCP to discover PXE boot images available on the network. On my home network, I use a wireless router that runs openwrt for DHCP. I also have a little fanless, low-power mini-itx x86 server that I use as a file/media server.
I wanted to configure my openwrt DHCP server to direct PXE clients to installation media on my mini-itx server (hostname == "pizza").
Here is what I had to do:
Add this to /etc/config/dhcp:
# # Specify pxelinux.0 without a directory prefix # because we run tftpd in chroot (--secure) mode: # config boot option filename 'pxelinux.0' option serveraddress '192.168.1.77' option servername 'pizza'
tftpd on pizza
I'm using openbsd-inetd as my inetd server and running tftpd from inetd since I do not need to run it all the time. I configured tftpd-hpa on a server named pizza on my LAN.
Install and prepare tftpd
sudo apt-get install tftpd-hpa sudo mkdir -p /srv/tftp
Do not run as a standalone server:
/etc/init.d/tftpd-hpa stop rm /etc/init.d/S03tftpd-hpa
Configure inetd to run tftpd. Add this to /etc/inetd.conf:
# # We *might* want to change --timeout (default 900 or 15 minutes), which # is the timeout before the server will run after a connection is received before # it terminates. # # -s or --secure (chroot on startup) # # -u tftp is USER that the daemon will run as (default is nobody). # Installing the tftpd-hpa package creates a tftp user # tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -u tftp --secure /srv/tftp
Download the debian netboot image, and extract to /srv/tftp. We should see:
ls -1 /srv/tftp/ debian-installer pxelinux.0 pxelinux.cfg version.info
add options to boot SystemRescueCD with PXE
The debian installer netboot tarball variant does not include fdisk. I needed it. I also wanted to use ntfsclone to copy my NTFS partition. Therefore, I also downloaded SystemRescueCD to transfer my windows XP partition before proceeding with the debian installation.
NOTE: SystemRescueCD has become bloated. I've used it in the past, and years ago it used to be about 100MB. It now includes xorg and a bunch of GUI tools, and the size of the image is over 300MB. This is fine when booting from physical storage (USB drive or optical media), but it's slow to transfer an image this size over a LAN. I used SystemRescueCD to transfer the windows XP partition from my old hard drive to the new one during my installation, but next time I'll try the PLD rescue cd instead.
I downloaded it, copied the iso to my server, mounted it as a loopback, and copied the contents to /srv/tftp/system-rescue-cd/system-rescue-cd-2.4.0/:
### Do all this stuff as root mkdir -p /mnt/tmp mkdir -p /srv/tftp/system-rescue-cd/system-rescue-cd-2.4.0 cd /srv/tftp/system-rescue-cd ln -s system-rescue-cd-2.4.0 current cd current mount -o loop -tiso9660 /dev/shm/systemrescuecd-x86-2.4.0.iso /mnt/tmp cp -a /mnt/tmp/* .
Then I made an entry for systemrescuecd in my PXE boot configuration, which I put in /srv/tftp/sysrescue32.cfg:
label sysrescue32 menu label ^sysrescue32 kernel system-rescue-cd/current/isolinux/rescuecd append vga=788 initrd=system-rescue-cd/current/isolinux/initram.igz
Then I added a line for that config file to /srv/tftp/pxelinux.cfg/default:
# D-I config version 2.0 include debian-installer/i386/boot-screens/menu.cfg ### This is the line I added to the default config: include sysrescue32.cfg default debian-installer/i386/boot-screens/vesamenu.c32 prompt 0 timeout 0
imaging and installation
I'm not going to cover the actual debian installation in detail. Once I had openwrt's dnsmasq DHCP set up to point to the tftpd running via inetd on pizza, all I had to do to PXE boot was hit F12 when I booted the old laptop to select PXE as the boot option.
Then I was greeted with a debian splash screen, from which I could select either one of the debian boot options or my sysrescue32 SystemRescueCD boot option.
To complete my installation, I did (roughly):
- booted into SystemRescueCD, mounted my old hard drive with a USB enclosure,
- created a single NTFS partition on the new drive with fdisk
- imaged the old NTFS partition over the new partition with ntfsclone
- created a single VFAT (FAT32 LBA type 0x0C) partition with fdisk to use for shared data between windows XP and linux
- rebooted into the debian installer and installed debian (installing GRUB2 to the MBR)