On Fri, Sep 22, 2006 at 02:50:31PM -0500, Jeff Cross wrote:

> Jerry McAllister wrote:
> > On Fri, Sep 22, 2006 at 01:23:28PM -0500, Jeff Cross wrote:
> > 
> >> I really like the way I have my stuff setup within FreeBSD and would
> >> hate to have to recreate a lot of it as well as install applications
> >> over again.  Could I do a dump of my current FreeBSD partition, reformat
> >> and partition the whole drive, install FreeBSD, and then restore my data
> >> to the new partition or would this cause issues?
> > 
> > That would be one good way of doing it.    Just make sure and check
> > your dumps before wiping everything. (create a scratch space.  Cd to it
> > and read a few things back from the dumps and check them.   
> > 
> > You don't need to reformat the drive - that is too low level for this.
> > Just fdisk it and put all the disk in one slice - slice 1.  Make that 
> > slice marked bootable.    Then use bsdlabel (disklabel pre 5.xxx) to 
> > divide up the slice in to partitions.   They will need to be the
> > same partition identifiers (a-h) as used currently.  Finally, 
> > use newfs to build filesystems on the partitions (except for swap)
> > and then restore the dumps to their original partitions.
> > Make sure you mount the partition as something and then cd in to
> > that appropriate partition to do the restore.
> > 
> > You will need to do the wiping and rebuilding from some other
> > media such as a fixit CD or another bootable disk.   You can't
> > wipe the slice that you are running from.
> > 
> > 
> > An alternative would be to leave the existing slice alone, but
> > use fdisk to mark the MS slice as a FreeBSD slice (not bootable)
> > and then either create one single partition in that slice or 
> > divide it as you choose and use newfs to create file systems.
> > Then, create a mount point for each new partition you made (put
> > them in /etc/fstab and mount them up.  Then move some of your big
> > directories in the existing FreeBSD slice over then and made 
> > symlinks to them.    That way you would free up room in the FreeBSD
> > bootable slice, but not have to dump/restore and rebuild everything.
> > It is quicker and works just as well, but slightly less clean, though
> > it could be helpful if your file systems are too large for your
> > backup media.
> > 
> > ////jerry
> > 
> >> Any assistance is greatly appreciated!
> >>
> >> Jeff Cross
> >> http://www.averageadmins.com/
> > _______________________________________________
> > freebsd-questions@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to "[EMAIL PROTECTED]"
> > 
> > 
> This sounds scary, I mean ok, but will doing what you have mentioned in
> this post do anything for the MBR?  Is that why I would be setting the
> bootable flag in fdisk?  I am currently using NTLOADER to boot Windows
> XP and FreeBSD 6.1-SECURITY.

There is a command line '-B' flag to fdisk that makes it write the MBR.
Setting the slice as bootable during the fdisk session just sets a 
flag for it.   Then in bsdlabel you need to tell it to write
the boot sector for that slice.   That flag is also '-B' but the one
in bsdlabel writes the slice's boot code and the one in fdisk writes
the whole drive's MBR.  Note that a drive's MBR runs, checks for
bootable slices, gives you a menu to choose bootable slices and when
you choose, loads the boot code from that slice and transfers control
to it.    Actually, you don't really really need an MBR if there is
only one slice and it is bootable.  But, skip that.   Do it the whole
hog way.    In the bsdlabel man page there is an example group of
commands that do just what you want - wipe the disk, fdisk it to
a single slice and do the bsdlabels (two of them in a row) to set
it up.   In the second one, you get an edit screen and in that you
set up the partition with identifiers and sizes you want.  When you
tell it to write and exit (standard 'ESC : w q' you use in vi) it
writes out the label.

>From man bsdlabel: 
                     dd if=/dev/zero of=/dev/da0 bs=512 count=32
                     fdisk -BI da0
                     dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
                     bsdlabel -w -B da0s1
                     bsdlabel -e da0s1

The one block dd makes sure the disk is wiped and may not be needed.
I would skip the second dd -- I never use it.   Notice it is
referencing slice 1 on da0 whereas the first dd is referencing 
the drive itself without a slice.   The first one would nuke the MBR,
the second one would nuke the partition table and boot code on slice 1.

The first bsdlabel writes the boot code in slice 1.
The second bsdlabel sets up an edit session for the partition table.

After this, you just need to do a newfs for each partition you 
create except the one for swap (partition b).
Partition a should be root.
Partition label c is for the whole drive, not a real partition.
After a, b and c, the rest is up to you how to use the identifiers.

bsdlabel is much more forgiving about formats for partition sizes nodays, 
but I like to still figure it out in number of blocks (512 bytes each)

As a sample, here is the partition setup from my desktop machine
which has FreeBSD on the third slice (Diagnostics on 1, XP on 2, FBSD on 3)
This is a 37.3 GB slice.

#-> bsdlabel ad0s3

# /dev/ad0s3:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   524288        0    4.2BSD     2048 16384 32776 
  b:  2572288   524288      swap                    
  c: 78316875        0    unused        0     0        # "raw" part, don't edit
  d:  1048576  3096576    4.2BSD     2048 16384     8 
  e:  4194304  4145152    4.2BSD     2048 16384 28552 
  f:  6291456  8339456    4.2BSD     2048 16384 28552 
  g: 63685963 14630912    4.2BSD     2048 16384 28552

Note, don't modify any of the stuff above the partition table, even
if it looks wrong to you.

Also note that nowdays you can put in * for offsets and also * for the 
last partition and bsdlabel will figure those things out for you and
make the last partition take up all the remainder of the slice.

And NOTE.   The disk name will be adx for sata and dax for SCSI
where 'x' is the drive number starting with 0.    If you have just
one drive, it will be either ad0 or da0.

Really, this all works - but do make a reliable backup in case 
you fat-finger something along the way.

Good luck, have fun,


> Jeff Cross
> http://www.averageadmins.com/
freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to