Hard drive restoration from rsync backups
Contents:
Conventions:
- [machine-name] is the name of the machine to be backed up, such as remus for remus.rutgers.edu
- [disk-device] is the device file for the disk currently being restored to, such as /dev/hda
- [partition] is the device file for a partition, such as /dev/hda1 for Linux or /dev/dsk/c0t0d0s0 for Solaris
- [raw-partition] is the character device file for Solaris, such as /dev/rdsk/c0t0d0s0
- [volume-label] is the label of a partition, often the mountpoint (such as /usr), also possibly SWAP-[partition] for swap.
- [mountpoint] is the mountpoint under consideration where the restored filesystem is being constructed.
- [backup-mountpoint] is where the backup we are restoring from is mounted
Caveats:
- This will have to be modified if LVM is in use
- This does not assume the use of lilo
General Info:
- A DOS partition table can only contain 4 partitions. The partitions specified in the partition table at the start of a disk are called the "physical" partitions, there can only be 4 of these per disk. To allow for additional partitions, a partition can be set up as "extended", which allows it to contain its own partition table and set of partitions. The partitions within the extended partition are called "logical". Typically the last physical partition, #4, is set as the extended partition. The logical partitions within it are numbered from #5.
- Partition types 5 (extended) and 85 (Linux extended) are treated the same by linux, but 85 will not be read by DOS. This is provided so that extended partitions can be created above the limitations of DOS, without DOS fdisk crashing when trying to read them. For Linux-only systems you should be able to use either; fdisk seems to default to 5.
Fedora Core hard drive restoration
How to get the information you'll need for the restore:
- If you can still access the corrutped disk:
- run mount, note what partitions are mounted at what points in the filesystem, filesystem types, and sizes
- run fdisk on the drives, print current partition table
- check /etc/fstab for partition labels (first column)
- If machine has configuration in ~watrous/Config/ on farside:
- examine ~watrous/Config/[machine-name] to get partition table (sizes, types) and filesystem (mountpoints) information
- check /etc/fstab in backup for partition labels (first column)
- Otherwise get what you can from /etc/fstab in the backup until we get a regular partition table and filesystem backup system in place
Restoring a backup
- boot into rescue mode using the same version of Fedora Core as was installed (as the filesystems created by one may not be compatible with another), refuse any assistance (skip finding and mounting of filesystems, we don't care what's currently on the drive)
- for each disk:
- Run fdisk [disk-device].
- Create a new partition table by entering o
- Create new physical partitions (<= #4):
- enter n to begin
- enter p to create a physical partition
- enter partition number
- hit return to accept the precalculated start cylinder
- enter the size of the partition (+100M for 100 megabytes, for example)
- repeat for each physical parition
- If there are logical partitions (> #4):
- create an extended partition (should always be #4 if there are partitions >= 5)
- enter n to begin
- enter e to create the extended partition
- accept the defaults for start and end cylinder
- Create new logical partitions (>= #5) in numerical order
- enter n to begin
- accept the default start cylinder
- enter the size of the partition (+100M for 100 megabytes)
- repeat for each logical partition
- Change type of partitions
- if any partition (besides the extended partition) is not type 83 (Linux), such as swap partitions (which should be 82)
- enter t to change partition type
- if prompted, enter the number of the partition (if there is only one partition it will be assumed that it is being changed)
- enter the hex code for the new type of this partition
- Enter p to view the partition table
- Enter w to write the partition table to the disk
- Create file systems for each partition
- For ext2 run mkfs.ext2 -L [volume-label] [partition]
- For ext3 run mkfs.ext3 -L [volume-label] [partition]
- For swap run mkswap -L [volume-label] [partition] (however note that not all versions of mkswap support labelling, leave out -L [volume-label] in these cases, or if there is no label to use)
- proceed to setup each drive
Mount the filesystems
- Before a filesystem can be mounted all those logically containing it must be mounted, i.e. / must be mounted before /usr, which much be mounted before /usr/share (assuming that all of these are seperate filesystems)
- Create a directory to mount at, ex. mkdir [mountpoint], mkdir [mountpoint]/usr
- Set the user and group ownership of the new directory to root, and permissions to 0755, unless you know better (this is a reasonable default in case the filesystem fails to mount, when mounted the permissions of the root of the mounted filesystem will override this).
- Mount the filesystem into that directory, ex. mount -t ext3 [partition] [mountpoint] for / or mount -t ext2 [partition] [mountpoint]/usr for /usr, depending on the filesystem type
- proceed to mount all filesystems
Mount the backup
- create a mount point, mkdir [backup-mountpoint]
- mount backup from hold:
mount -t nfs hold:/backup/backups/[machine-name]
- The directory mounted contains each backup in its own directory. The directories are named in YYMMDD.hhmm format. Locate the most recent one. (either sort by name with ls or by last modification date with ls -tr)
Restore the backup
- change into the directory to restore from, ex. cd [backup-mountpoint]/060606.0616/
- Run find . -depth -print | cpio -pdumv [mountpoint]. This will copy all of the files while maintaining modification dates, permissions, ownership, and directory structure.
install boot block
- with grub
- chroot [backup-mountpoint]
- run grub-install [boot-device], where [boot-device] is the device to install grub on (most likely the device for the drive (install to the MBR) if this is only a Linux machine)
Solaris 8 hard drive restoration
How to get the information you'll need for the restore:
- If original machine is still running:
- run format, check each drive, run verify to see the partition table on each drive
- run /usr/bin/uname -i to find the platform name
- If machine has confgiuration in ~watrous/Config on farside
- examine ~watrous/Config/[machine-name] to get partition table (sizes, tags) , filesystem types, and platform
- Otherwise
- check /etc/vfstab in the backup, note the block device (first field), character device (second field), mountpoint (third field), and filesystem (fourth field), not sure how to figure out platform
Restoring a backup
- Boot into Solaris 8 install, get a shell (Ctrl-C, return, 0, 0, return)
- Set up label (partition table) on each disk:
- run format
- enter the number of the disk to be setup from the list of available disks
- if disk is not formatted ([disk formatted] does not appear) enter format and follow the prompts
- enter modify to change the partition table
- choose to set the disk to "all free hog", which will start you with an empty partition table, answer yes when asked to confirm
- confirm
- choose a partition to set as free hog (you won't have to enter a size for this, it gets whatever is left over)
- enter a size for each partition as prompted
- confirm
- enter a name for the partition table (as far as I know this doesn't matter, I use "partition-table", with quotes)
- confirm (type yes)
- enter print to view table
- change partition tags and flags
- enter partition number
- enter a tag name
- enter flags (wu for swap, wm for msot everything else)
- accept the already entered values for partition start, end
- enter label to write to the disk
- enter quit to go up to the format menu
- enter verify to check the state of the partition table
- enter quit to leave format
- create filesystems
- UFS
- run newfs [raw-partition]
- swap - do nothing
- anything else - ?
- mount filesystems
Note:
Before a filesystem can be mounted all those logically containing it must be mounted, i.e. / must be mounted before /usr, which much be mounted before /usr/share (assuming that all of these are seperate filesystems)
- make a mountpoint, ex. mkdir [mountpoint] for /, mkdir [mountpoint]/usr for /usr
- Set the user and group ownership of the new directory to root, and set permissions to 0755, unless you know better (this is a reasonable default in case the filesystem fails to mount, when mounted the permissions of the root of the mounted filesystem will override this).
- Mount the filesystem into that directory, ex. mount [partition] [mountpoint] or mount [partition] [mountpoint]/usr
- mount backup
- make a mountpoint for the backup
- mount -F hold:/backup/backups/[machine-name] [backup-mountpoint] (you may have to use hold's IP if DNS isn't working)
- The directory mounted contains each backup in its own directory. The directories are named in YYMMDD.hhmm format. Locate the most recent one (either sort by name with ls or by last modification date with ls -tr
- restore backup
- change into the directory containing the backup you want to restore, etc. cd [backup-mountpoint]/060606.0616/
- Run find . -print -depth | cpio -pdumv [mountpoint], where /mnt/root is where you mounted the root filesystem. This will copy all of the files while maintaining modification dates, permissions, ownership, and directory structure.
You can exclude certain directories by piping the output of find through grep, ex. find . -print -depth | grep -v "^\./grad" | cpio -pdumv [mountpoint] to exclude /grad, pipe through additional greps for additional restrictions
- write boot block
- run installboot /usr/platform/[platform]/lib/fs/ufsbootblk [raw-partition], where [platform] is the platform that was used in the original system and [raw-partition] is the partition to which the root filesystem was installed.
- if the partitions you have created are not the same as the original configuration, edit the mounted etc/vfstab so the correct partitions will be mounted, most likely the first two columns will be all you need to change
- set up devices
- If a tarball of the devices exists:
- retrieve it from whereever we decided to keep them
- extract them into the new filesystem with tar xvf [devices.tar] -C [mountpoint], where [devices.tar] is the tar with the devices.
- otherwise you'll need to recreate them, as the backup is stored on a Linux machine which mangles the device numbers
- remove the dev and devices trees: rm -rf [mountpoint]/dev [mountpoint]/devices
- regenerate the devices: devfsadm -r [mountpoint]
- This may still not be right, especially if you are restoring a machine that was upgraded to Solaris 8 from an earlier version. Check that the major number of the devinfo device (ls -l [mountpoint]/devices/pseudo/devinfo@0:devinfo) is the same as the number the kernel you're installing expects (grep devinfo [mountpoint]/etc/name_to_major). If not:
- remove dev/msglog: rm [mountpoint]/dev/msglog (if that device is broken the system will not be able to perform its reconfiguration boot, removing it causes writes to it to create a regular file, which will soon after be replaced with the proper device)
- remove the devinfo devices: rm [mountpoint]/devices/pseudo/devinfo*
- create new devinfo device:
mknod [mountpoint]/devices/pseudo/devinfo@0:devinfo c [devmajor] 0, where [devmajor] is the device major number you got from grep devinfo [mountpoint/etc/name_to_major].
- touch [mountpoint]/reconfigure to force Solaris to recheck its devices when it starts up.
- reboot