On Mon, May 04, 2009 at 10:31:16AM +0200, Jonathan McKeown wrote: > On Friday 01 May 2009 22:43:51 Jerry McAllister wrote: > > On Fri, May 01, 2009 at 12:07:22PM -0500, Martin McCormick wrote: > > > Let's say we have a system that is backed up regularly and it > > > vanishes in a puff of smoke one day. One can get FreeBSD > > > installed on a new drive in maybe half an hour or so but we also > > > need to get back to the right patch level and then we can say we > > > are back where we started. > > > > What you want to do is use the fixit image to set up the disk. > > That means fdisk and bsdlabel and newfs it. You can actually > > use sysinstall to do this as well. Just let the installer come > > up and do the disk stuff, choose minimal install and then after > > it finishes making the disks, kill the rest of the install (or > > just let it finish and then overwrite it. > > > > But, I find it actually easier to do the fdisk, bsdlabel and newfs-s > > myself. But, then I am used to it. > > > > Right after you get done making sure where your fixit is living, > > then use fdisk and bsdlabel to check for the way you have the disk > > set up currently. Write it down or print it out and keep it > > near that installation/fixit disk. > > [Lots of good stuff about creating the partitions] > > > Now all you have to do is newfs each partition. Just take the > > defaults. Remember that newfs wants the full device spec, not > > just the drive identifier. > > If you have kept the right information beforehand, you can actually restore > your dumps onto ``bare metal'' without doing a partial install first, and > with the same newfs settings for each partition as you originally had. You > need to use bsdlabel and dumpfs -m and keep the output for rebuilding. The > rest of this message is the details.
If you have a specific reason to want your new filesystems' to have identical superblock info, you can use dumpfs -m, but you don't need to worry about all that. Just fdisk, bsdlabel and then let newfs take its defaults. You do not need an identical filesystem to do a restore(8) on it. Restore builds it from scratch in the correct way - in fact in a better way than what it was before the system was whacked. So, just build the new disk either manually or with sysinstall and then restore the dumps within the filesystems. Make sure you cd in to the mounted filesystem - note, since you are running from a fixit, you are making up new mount points and mounting the filesystems from the new disk. Something like: mkdir /newroot mount /dev/ad0s1a /newroot cd /newroot restore -rf /dev/nsa0 (replace /dev/nsa0 with wherever you are reading the dump. don't forget to position the tape with mt fsf nn if it is a tape) You can also skip the fdisk if you are running only FreeBSD from that disk and don't mind using what is called a 'dangerously dedicated' disk. It isn't really all that dangerous. No weird creatures will climb out and grab you by the throat at night. If you do dangerously dedicated, the device addressing leaves out the slice specifier (s1, s2, s3 or s4) and would look something like: /dev/ad0a instead of /dev/ad0s1a. ////jerry > > On your running system, create and keep two files. My system has one slice, > ad6s1, and the usual partitions - a for root, d for /tmp, e for /var, f > for /usr, and I've shown the commands you need, and the resulting file > contents on my current system, below: > > bsdlabel ad6s1 >ad6s1.label > > ad6s1.label contains: > > # /dev/ad6s1: > 8 partitions: > # size offset fstype [fsize bsize bps/cpg] > a: 1048576 0 4.2BSD 2048 16384 8 > b: 8388608 1048576 swap > c: 156296322 0 unused 0 0 # "raw" part, don't > edit > d: 20971520 9437184 4.2BSD 2048 16384 28552 > e: 1048576 30408704 4.2BSD 2048 16384 8 > f: 124839042 31457280 4.2BSD 2048 16384 28552 > > I usually put all the spare space on a disk into /usr, so changing the first > field on the f: line (the size) from 124839042 to * tells bsdlabel to do > exactly that in case the replacement disk is a different size from the > original. > > We now need the newfs settings for all the 4.2BSD filesystems except c, so > (in > sh syntax) > > for i in a d e f; do dumpfs -m ad6s1$i; done >newfscmds.ad6s1 > > newfscmds.ad6s1 now contains: > > # newfs command for ad6s1a (/dev/ad6s1a) > newfs -O 2 -a 8 -b 16384 -d 16384 -e 2048 -f 2048 -g 16384 -h 64 -m 8 -o > time -s 262144 /dev/ad6s1a > # newfs command for ad6s1d (/dev/ad6s1d) > newfs -O 2 -U -a 8 -b 16384 -d 16384 -e 2048 -f 2048 -g 16384 -h 64 -m 8 -o > time -s 5242880 /dev/ad6s1d > # newfs command for ad6s1e (/dev/ad6s1e) > newfs -O 2 -U -a 8 -b 16384 -d 16384 -e 2048 -f 2048 -g 16384 -h 64 -m 8 -o > time -s 262144 /dev/ad6s1e > # newfs command for ad6s1f (/dev/ad6s1f) > newfs -O 2 -U -a 8 -b 16384 -d 16384 -e 2048 -f 2048 -g 16384 -h 64 -m 8 -o > time -s 31209760 /dev/ad6s1f > > take out the -s 31209760 in the command for ad6s1f (this is the size of the > new filesystem and it defaults to the size of the partition - which we made > to take up the rest of the disk). > > Now you can save these two files somewhere. When it comes to a catastrophic > failure and restore, boot a liveCD. Use fdisk to create your single large > slice on the new disk with > > fdisk -BI ad6 > > Use > > bsdlabel -R ad6s1 ad6s1.label > > to restore the disklabel. > > If your device name is different from before, you need to edit > newfscmds.ad6s1 > to change the ad6 to the new device name wherever it occurs, but you then run > the newfs commands in the file to create your filesystems with the same > parameters (softupdates on/off, etc) as before. > > You now have the basic structure of your previous disk, ready to have the > root, /var/ and /usr dumps restored to make a running system identical to the > destroyed one, with one last step: > > bsdlabel -B ad6s1 > > to put the boot code on the slice. (I haven't tried this bit, so if you're > going to use the boot code from your root partition, which is stored > at /boot/boot, you'll need to check whether you can run bsdlabel -B on a > mounted disk. If you can, the command would be > > bsdlabel -B -b /mnt/boot/boot /dev/ad6s1 > > assuming you mounted /dev/ad6s1a on /mnt). > > If you have a different device name, of course, you also need to edit your > fstab before rebooting. > > Jonathan > _______________________________________________ > firstname.lastname@example.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org" _______________________________________________ email@example.com mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"