howto: restore to new disk
2005-09-09
Recently the firewall box' hard drive developed a squeal. Not good, especially when it changes note! This brief howto describes restoring a working system to a new hard drive with a clean install of Slackware-current (10.2 beta).
contents
what
The risk with high uptime boxen is that the hard drive may fail to spin up after a power cycle. When the hard drive bearing started squealing after 14 months operation, I decided it would be a good idea to replace the drive prior to failure.
The box deltree is an old pentium 233/mmx with 96MB memory. Could it handle an 80GB drive? Checked that by borrowing a 40GB HDD from another box. Not a problem, go buy a new 80GB drive and plan the replacement.
preparation
- plan drive layout
- fdisk + reboot
- format
- copy install source
- make boot floppies
- halt + swap drives
plan drive layout
old drive layout
I'm writing this after the event, the old hard drive is mounted in a different machine as /dev/hdb.
# fdisk -l /dev/hdb Disk /dev/hdb: 3243 MB, 3243663360 bytes 128 heads, 63 sectors/track, 785 cylinders Units = cylinders of 8064 * 512 = 4128768 bytes Device Boot Start End Blocks Id System /dev/hdb1 1 4 16096+ 83 Linux /dev/hdb2 5 28 96768 82 Linux swap /dev/hdb3 29 192 661248 83 Linux /dev/hdb4 193 785 2390976 5 Extended /dev/hdb5 193 232 161248+ 83 Linux /dev/hdb6 233 248 64480+ 83 Linux /dev/hdb7 249 256 32224+ 83 Linux /dev/hdb8 257 768 2064352+ 83 Linux /dev/hdb9 769 784 64480+ 83 Linux # df Filesystem 1K-blocks Used Available Use% Mounted on [...] /dev/hdb3 661220 339916 321304 52% /mnt /dev/hdb5 156155 25343 122750 18% /mnt/var /dev/hdb6 62437 154 59059 1% /mnt/usr/local /dev/hdb8 2064252 894100 1170152 44% /mnt/home /dev/hdb9 62437 2 59211 1% /mnt/home/ftp/upload
new drive layout
Basically the same layout with a little more elbow room and a pair of 32GB archive partitions. This box has been in use for 14 months and the requirements are known and settled. Make all partitions reiserfs, put entire ftp directory into its own partition and add a couple of large partitions, one for install source, the other an archive at the slow end of the drive, not normally mounted.
# fdisk -l Disk /dev/hda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 4 32098+ 6 FAT16 /dev/hda2 * 5 260 2056320 83 Linux /dev/hda3 261 292 257040 82 Linux swap /dev/hda4 293 9728 75794670 5 Extended /dev/hda5 293 324 257008+ 83 Linux /dev/hda6 325 356 257008+ 83 Linux /dev/hda7 357 388 257008+ 83 Linux /dev/hda8 389 1412 8225248+ 83 Linux /dev/hda9 1413 5508 32901088+ 83 Linux /dev/hda10 5509 9728 33897118+ 83 Linux # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda2 2056252 478928 1577324 24% / /dev/hda5 256996 41852 215144 17% /var /dev/hda6 256948 32928 224020 13% /usr/local /dev/hda8 8224960 495892 7729068 7% /home /dev/hda7 256948 33080 223868 13% /home/ftp /dev/hda9 32900044 5520728 27379316 17% /home/install /dev/hda10 33896048 1362304 32533744 5% /home/archive
- Constraints
- The drive may have up to four primary partitions, one of which may be labelled extended that may contain logical partitions. Maximum number of partitions is 16, some systems allow more, some ignore partitions greater than 16.
- Sizing
- Experience helps here, as sizing depends on many factors, when in doubt, leave some unallocated space for later.
- Layout
- I plan new layout on paper, so the plan for the new layout
above looks something like:
1 32MB 4 spare 2 2GB 256 / 3 256MB 32 swap 4 - ext 5 256MB 32 /var 6 256MB 32 /usr/local 7 256MB 32 /home/ftp 8 8GB 1024 /home 9 32GB 4096 /home/install 10 32GB - /home/archive
- The number in the third column above is the cylinder count, a multiple of eight gives integer 4k partition sizes.
- Place the busiest partitions near front of drive, for example the Seagate drive I use has a 2:1 data rate difference from outer to inner edge of the disk (58 - 28 MB/s). Also think of head movement, that's why I clustered the small partitions together.
- The small dos primary is so I may later add cdrom and other boot options via dos as box cannot boot cdrom.
- The number in the third column above is the cylinder count, a multiple of eight gives integer 4k partition sizes.
fdisk + reboot
I prefer fdisk, but you should use tools that you feel comfortable with. It is vital you reboot after writing out a new partition table, prior to formatting the new partitions.
format
You may prefer to defer formatting to the install phase, I needed to format drive in order to copy install source, so I formatted the whole thing. I choose Reiserfs-3 as it has not let me down. Choose the filesystems you prefer.
copy install source
Skip this if you prefer a CD or NFS install, I find a hard drive install convenient as it sidesteps the issue of which of the three NICs will the slack installer see first?
make boot floppies
Skip this. Unless you cannot boot CDROM. Write and verify the three boot floppies, this is covered in the Slackware documentation.
halt + swap drives
Ready to install. Shutdown the box and swap hard drives. While one may argue that the install be done on another box, this is part of acceptance testing for the new hard drive in its intended role.
installation
Install Slackware as per the rich documentation elsewhere.
restore procedure
In this section we restore the box' personality, user data files, to the fresh Slackware system to bring back the firewall function.
backups
Normal backups for this system are one tarball for the OS with kernel configs, /etc, usr/local; and another for the web data area. OS is reinstalled, install area is local copy of files available from the Internet thus no need to backup. In choosing what to backup consider cost of replacing missing data: download time, creation time, backup capacity and convenience.
localnet controller
Mount old HDD partitions and use rsync to take an archive copy remove old hard drive. Edit/merge system config files:
- /etc/fstab;
- /etc/lilo.conf.
- /etc/modules.conf
- /etc/rc.d/rc.local
- /etc/dnsmasq.conf
- /etc/exports
- /etc/syslog.conf
- /etc/inetd.conf
- /etc/hosts (+ extra files for dnsmasq)
(Optional) Compile or reinstall custom kernel, this box' kernel is compiled on another box, once NFS is working install custom kernel, reboot.
Restore localnet file server data, in this case rsync copy the /home/share tree from backup. Check for correct localnet operation.
ADSL
Time to reinstate world access, copy config files from backup:
- /etc/ppp/ip-up
- /etc/ppp/ip-down
- /etc/ppp/auth-up
- /etc/ppp/auth-down
- /etc/ppp/adsl-lost
- /etc/ppp/chap-secrets
- /etc/ppp/pppoe.conf
- /etc/resolv.conf
- /etc/rc.d/rc.firewall
Run adsl-start and verify ADSL connection, firewall and world access.
servers
- apache
- restore /etc/apache/httpd.conf, rsync copy /home/web from archive, `apachectl graceful`
- ftp
- restore /etc/vsftpd.conf, rsync /home/ftp from backup, restart vsftpd
- samba
- restore /etc/samba/smb.conf, restart samba
- ntp
- restore /etc/ntp.conf, ntpdate <server>, kick ntpd
repeat dd copy boot_image to floppy verify floppy until floppy == image commands: dd if=/path/to/bootdisk/bare.i of=/dev/fd0 cmp /path/to/bootdisk/bare.i /dev/fd0 quite painless really.
gotchas