Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Jan 2009 22:10:17 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Grant Peel <gpeel@thenetnow.com>
Cc:        FreeBSD Questions List <freebsd-questions@freebsd.org>
Subject:   Re: Replace SCSI Drive
Message-ID:  <49652849.7030400@infracaninophile.co.uk>
In-Reply-To: <9F57CF00DDE541E69F500E26B652DDED@GRANTPC>
References:  <9F57CF00DDE541E69F500E26B652DDED@GRANTPC>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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--



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?49652849.7030400>