From owner-freebsd-questions@FreeBSD.ORG Wed Jan 7 22:10:40 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29BBD1066264 for ; Wed, 7 Jan 2009 22:10:40 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 1639F8FC1C for ; Wed, 7 Jan 2009 22:10:37 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id n07MAN7e033490; Wed, 7 Jan 2009 22:10:31 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.7.2 smtp.infracaninophile.co.uk n07MAN7e033490 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1231366231; bh=X1Optg/bhzdYtG D4ixCuFkpBj04OvbzOixAP0V5+dAo=; h=Message-ID:Date:From:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Cc:Content-Type: Date:From:In-Reply-To:Message-ID:Mime-Version:References:To; z=Mes sage-ID:=20<49652849.7030400@infracaninophile.co.uk>|Date:=20Wed,=2 007=20Jan=202009=2022:10:17=20+0000|From:=20Matthew=20Seaman=20|Organization:=20Infracaninophile|User -Agent:=20Thunderbird=202.0.0.19=20(X11/20090104)|MIME-Version:=201 .0|To:=20Grant=20Peel=20|CC:=20FreeBSD=20Quest ions=20List=20|Subject:=20Re:=20Repl ace=20SCSI=20Drive|References:=20<9F57CF00DDE541E69F500E26B652DDED@ GRANTPC>|In-Reply-To:=20<9F57CF00DDE541E69F500E26B652DDED@GRANTPC>| X-Enigmail-Version:=200.95.6|Content-Type:=20multipart/signed=3B=20 micalg=3Dpgp-sha256=3B=0D=0A=20protocol=3D"application/pgp-signatur e"=3B=0D=0A=20boundary=3D"------------enigB3240BA9C6241FCA4B8460BB" ; b=kmArYNOwDUFBLXDhzjlH9kbG3oLwf8iKEaazPted1lk03OlnLpmi+fUgquMVB3s 3PJ6YWRGB6TGoiZYxbb/okAJsOvDDRUn1LFomTyAKEd3vq0i//Feid62kW0PeFX5Ncm L5Knn39xpKxxxUWhr6OxMXy4xq8yYDcmKUDsrYbnc= Message-ID: <49652849.7030400@infracaninophile.co.uk> Date: Wed, 07 Jan 2009 22:10:17 +0000 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.19 (X11/20090104) MIME-Version: 1.0 To: Grant Peel References: <9F57CF00DDE541E69F500E26B652DDED@GRANTPC> In-Reply-To: <9F57CF00DDE541E69F500E26B652DDED@GRANTPC> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB3240BA9C6241FCA4B8460BB" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (smtp.infracaninophile.co.uk [IPv6:::1]); Wed, 07 Jan 2009 22:10:31 +0000 (GMT) X-Virus-Scanned: ClamAV 0.94.2/8842/Wed Jan 7 14:06:50 2009 on happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: FreeBSD Questions List Subject: Re: Replace SCSI Drive X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jan 2009 22:10:46 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB3240BA9C6241FCA4B8460BB Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Grant Peel wrote: > !. Can I use a FreeBSD bootable installation disk (6.4) made from an > ISO image, to boot my PC and make the filesystems on the 36GB drive, > without actually installing FreeBSD? (Please feel free to tell me > exactly how :-)). http://www.freesbie.org/ Except that site seems to be down at the moment. Yes, you can use disk1 from the Installation set as a live filesystem, an= d from there you can manipulate other hard drives attached to the machine. However, expect to do everything from the command line and take care to familiarise yourself with the necessary procedures before starting. > 2. Once I get that drive to the network center, and restore the dumps > to it, how do I ensure the drive is bootable? (I assume I actually do > that in the previous step). Well, if you install a minimal FreeBSD system on your 36GB drive using th= e installation media, you could test booting from it while it is still in y= our PC. Then you can duplicate the data from the remote server onto the driv= e (using dump and restore or how you will) which won't touch the boot block= s on the disk. It should 'just work' but watch out that you keep disk devi= ces in /etc/fstab in synch with where the OS finds the drive. You can fix an= incorrect fstab from the system console in single user mode: it would be = a good idea to write yourself a little cheat sheet on how to do that before= you start. > 3. Is it possible to skip step one altogether and use the > instructions in the man pages regarding "Restoring a filesystem" and > makeing the 'Pristine' filesystem? If so, again, how do I ensure the > disk is bootable? Of course. You can take a blank disk to your datacenter and initialise i= t entirely from your existing server. A neat trick would be to set up geom= mirroring between the old and new disks but you really need a disk of the= same size as the original (or larger) to do that properly. Failing that to replace an existing disk with a duplicate: 0) You've backed everything up already, haven't you? i) install new drive into server. Note: you may need to use /boot/load= er.conf settings to hard-wire your original disk to appear as da0 if your n= ew disk probes before the old one. Or make sure the SCSI ID of the new dri= ve is=20 larger than the ID of the old one -- the boot drive is typically in= stalled at SCSI ID 0 so that should happen by default. =20 ii) reboot from the old disk. iii) identify the device node for the new disk from the messages in=20 /var/run/dmesg.boot I'm going to assume /dev/da1 (with the origina= l system on /dev/da0) but make the appropriate substitutions in the following if that is not the case. iv) Two choices here. You can either do this the hardcore way (branch = a) or the way of least resistance (branch b) v-a) Slice the disk allocating all the space for FreeBSD, making it boot= able at the same time: # fdisk -B -I /dev/da1 vi-a) Write a BSD partition table into the slice, then set up your requir= ed FreeBSD=20 partitions: # bsdlabel -w da1s1 auto # bsdlabel -e da1s1 'bsdlabel -e' will pop you into an editor (vi by default) with a co= py of the partition table. Edit this to suit -- feel free to add any ext= ra lines to create additional partitions: you've got partitions a (tradition= ally the root) b (swap) and d, e, f, g, h (data partitions) to play with. = Save the=20 edited partition table and bsdlabel will write it to the disk when = you exit the editor. Don't futz with the 'c' partition (traditionally the w= hole disk) -- 'bsdlabel -w' will already have put in the correct values for yo= u. Note that bsdlabel understands the 'size' parameter either as secto= rs or, when given the appropriate suffix as kilobytes (k), megabytes (M), gigab= ytes (G), %age of available space (%) or you can just say '*' meaning 'everyt= hing else' You can also just put in '*' in the 'offset' column and bsdlabel wi= ll calculate the value for you, ordering the partitions on the drive in the orde= r given in the label. vii-a) Create file systems on your new partitions -- repeat for each of t= he 4.2BSD type=20 partitions set up in the previous stage: # newfs /dev/da1s1a=20 # newfs -U /dev/da1s1d ... etc. ... Traditionally softupdates is not enabled on the root partition, alt= hough it does no harm to enable it nowadays. (At one time it caused problems= updating the=20 system when the root partition was reasonably full, but that bug wa= s squashed=20 long ago.) alternatively: v-b -- vii-b) Make a backup copy of /etc/fstab. Fire up sysinstall and u= se the menu=20 items under the 'Custom Install' to achieve the desired result. No= te: you aren't=20 going to go on to install any of the base system so be sure to chos= e the options=20 to *W*rite out the settings at each stage. Do the 'Partition' and = 'Label'=20 actions (to your *new* disk, obviously), then quit from sysinstall.= If necessary copy back the saved version of /etc/fstab The two branches join again: viii) reboot to single user mode. (ie. 'shutdown -r now' then catch the = system as it is coming back up, and hit '4' in the boot menu for single user.= ) Once you get a single user shell, remount the root filesystem read-write: # mount -u / Then mount your newly created partitions under /mnt -- note: you ha= ve to give all of the relevant parts in the mount commands as there's not= hing in /etc/fstab to give the system any hints: # mount -t ufs -o rw /dev/da1s1a /mnt # mkdir -p /mnt/var # mount -t ufs -o rw /dev/da1s1d /mnt/var # mkdir -p /mnt/usr # mount -t ufs -o rw /dev/da1s1e /mnt/usr ... etc ... The above is an illustration and will need to be modified to accord= with the way your system is laid out. Refer to /etc/fstab for how the parti= tions (a, d, e, f etc) map onto the various mount points (/, /usr, /var, /hom= e etc.) -- you want to create the same layout but using the partitions from= the new disk (da1) all transposed to the equivalent locations under /mnt ix) Now, dump and restore each of the filesystems from the old drive on= to the equivalent partitions on the new drive. You can dump the old p= artitions while they are unmounted -- and in fact this is advantageous as it = ensures you will get definitely not get bitten by files changing on you dur= ing the course of the dump. Stuff on the root partition rarely changes muc= h at all, so dumping that while it's mounted isn't a problem in practice[*]: # dump -0 -a -C 32 -f - /dev/da0s1a | ( cd /mnt ; restore -rf - ) # dump -0 -a -C 32 -f - /dev/da0s1d | ( cd /mnt/var ; restore -rf -= ) # dump -0 -a -C 32 -f - /dev/da0s1e | ( cd /mnt/usr ; restore -rf -= ) ... etc ... =20 mutatis mutandem as for the mount commands in (viii). There will be some extraneous '.restoresymtable' files left lying a= round the duplicated partitions. These can eventually be deleted as descr= ibed in=20 restore(1). x) shut the system down. Extract the old system disk and keep in a sa= fe place in case of emergencies. Rejumper the new disk to the SCSI ID= formerly used by the old disk. Reassemble the machine. Reboot. xi) ... and you should have a perfectly working system duplicated onto = the new hard drive. You're done. This is by no means a trivial operation, and there are plenty of ways to = fat-finger your server to death when using these low-level commands. It = will help if you can=20 scare up some spare kit to practice on before working on your live server= =2E If it all goes a bit pear-shaped then the backout path is to replace= the original system disk, remove the new disk and then reboot. If you'v= e managed to scribble all over your live system disk, then you're going to need the full backups mentioned in (0).= Do you know how to restore your server from scratch? Cheers, Matthew [*] See also the -L flag for dump(1). --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enigB3240BA9C6241FCA4B8460BB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkllKE8ACgkQ8Mjk52CukIzHtwCfdnKM94SlIV8aI146frYfeDDj G2cAmQFj0VA9dPS8nuUFNDvpCgu7d237 =MMWT -----END PGP SIGNATURE----- --------------enigB3240BA9C6241FCA4B8460BB--