I would like to know if it is possible to continue restoring partitions after having restored the root partition.

The FAQ mentions that the new root filesystem should be ready enough so you can reboot and continue restoring the rest of the filesystems in single user mode.

I tried to restore without rebooting but I get errors relating to hardlinks when restoring the /usr partition.(I mount every partition to /mnt and umount after every partition has been restored)

Would mounting to /usr instead of /mnt be possible?

The reason I ask this is because I try to make the disaster recovery procedure as simple as possible, by booting a customized install cd with an added restore script that uses fdisk and disklabel to recreate all partitions based on the size of the new harddisk and uses restore to retrieve the dumped partitions backups from tape.

Can I avoid to reboot in single user mode?

The restore script I want to use:

_disk="wd0"


#_disk=`dmesg | grep dkcsum | sed 's/^dkcsum://;s/matched.*$//;s/^[ \t]//;s/[ \t]*$//'`
_mem=`dmesg | grep "real mem" | sed 's/^real mem.*(//;s/K)//'`



fdisk -e $_disk <<EOF reinit update write quit EOF

K="1024"
M=$(($K * $K))

echo "\nCalculating partition sizes..."

# grep: find the line with "unused"
# sed: drop c:
# sed: drop everything starting with "unused" and onwards
# sed: drop any leading spaces on the line
# sed: drop single character followed by spaces until end of line
# sed: drop trailing spaces
DISKSIZE=`disklabel $_disk | grep unused | sed 's/c://;s/unused.*$//;s/^[ \t]*//;s/.[ \t]*$//;s/[ \t]*$//'`


echo "\ndisksize \t\t\t\t$DISKSIZE\n"

FS=4.2BSD

offset_a=63 # Default offset
size_a=$(($DISKSIZE / 10)) # 10% of disksize echo "size partition a for mountpoint / \t\t$size_a\n"
offset_b=$(($size_a + $offset_a))
size_b=$(($_mem * $K / 512)) # two times amount of RAM (real mem) for swap
echo "size swap \t\t\t\t$size_b\n"
offset_d=$(($size_b + $offset_b))
size_d=$((120 * $M / 512)) # use 120MB echo "size partition d for mountpoint /tmp \t$size_d\n"
offset_e=$(($size_d + $offset_d))
size_e=$((200 * $M / 512)) # use 200MB
echo "size partition e for mountpoint /var \t$size_e\n"
offset_g=$(($size_e + $offset_e))
size_g=$(($DISKSIZE * 4 / 10)) # use 40% of disksize
echo "size partition g for mountpoint /usr \t$size_g\n"
offset_h=$(($size_g + $offset_g))
size_h=$(($DISKSIZE * 25 / 100)) # use 25% of disksize
echo "size partition h for mountpoint /home \t$size_h\n"
totalsize=$(($size_a + $size_b + $size_d + $size_e + $size_g + $size_h))


if [ $totalsize -ge $DISKSIZE ]; then
echo "Combined size of the partitions exceeds the size of the disk\n"
echo "Disksize $DISKSIZE < Totalsize $totalsize\n"
exit 1
else
echo "Total space used \t\t\t$totalsize\n"
fi
# Done calculating, now time to interact with disklabel tool.
#
echo "Creating partitions ...\n"
disklabel -f /tmp/fstab.${_disk} -E ${_disk} << __EOT > /dev/null
z
w
a a
$offset_a
$size_a
$FS
/
a b
$offset_b
$size_b
swap
a d
$offset_d
$size_d
$FS
/tmp
a e
$offset_e
$size_e
$FS
/var
a g
$offset_g
$size_g
$FS
/usr
a h
$offset_h
$size_h
$FS
/home
w
__EOT
echo "...partition creation completed\n"


# create filesystems for mountpoints
echo "Creating filesystems on the partitions...\n"
diska="${_disk}a"
newfs -q /dev/$diska
echo "...created filesystem on $diska\n"
diskb="${_disk}b"
newfs -q /dev/$diskb
echo "...created filesystem on $diskb\n"
diskd="${_disk}d"
newfs -q /dev/$diskd
echo "...created filesystem on $diskd\n"
diske="${_disk}e"
newfs -q /dev/$diske
echo "...created filesystem on $diske\n"
diskg="${_disk}g"
newfs -q /dev/$diskg
echo "...created filesystem on $diskg\n"
diskh="${_disk}h"
newfs -q /dev/$diskh
echo "...created filesystem on $diskh\n"

#
mount /dev/$diska /mnt
cd /mnt

# restore mountpoint /
echo "Restoring mountpoint / on partition $diska...\n"
restore -rs 1 -b 64 -f /dev/rst0

# write new mbr to disk
fdisk -i $_disk

# install bootblocks to boot from
cp /usr/mdec/boot /mnt/boot
/usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd0

cd /
umount /mnt

## FAQ says you can reboot in single user mode now and continue restore
## I want to continue now with the next backupset on the tape

# Restore of the other partitions

# restore mountpoint /tmp
echo "Restoring mountpoint /tmp on partition $diskd...\n"
mount /dev/$diskd /mnt
cd /mnt
restore -rs 2 -b 64 -f /dev/rst0
cd /
umount /mnt
# restore mountpoint /var
echo "Restoring mountpoint /var on partition $diske...\n"
mount /dev/$diske /mnt
cd /mnt
restore -rs 3 -b 64 -f /dev/rst0
cd /
umount /mnt


# restore mountpoint /usr
echo "Restoring mountpoint /usr on partition $diskg...\n"
mount /dev/$diskg /mnt
cd /mnt
restore -rs 4 -b 64 -f /dev/rst0
cd /
umount /mnt

## Restore of backupset of mountpoint /usr to /mnt gives errors creating hardlinks, how can I avoid that?

# restore mountpoint /home
echo "Restoring mountpoint /home on partition $diskh...\n"
mount /dev/$diskh /mnt
cd /mnt
restore -rs 5 -b 64 -f /dev/rst0
cd /
umount /mnt


echo "Restoring of backupsets completed, rewinding tape...\n" mt -f /dev/rst0 rewind

echo "Done, halting system now...\n"
halt



Reply via email to