Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Mar 2007 11:52:18 -0400
From:      Jerry McAllister <jerrymc@msu.edu>
To:        John Levine <johnl@iecc.com>
Cc:        freebsd@dfwlp.com, freebsd-questions@freebsd.org
Subject:   Re: Moving paritions around
Message-ID:  <20070330155217.GC59175@gizmo.acns.msu.edu>
In-Reply-To: <20070330025031.73483.qmail@simone.iecc.com>
References:  <20070330025031.73483.qmail@simone.iecc.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Mar 30, 2007 at 02:50:31AM -0000, John Levine wrote:

> I set up my laptop to dual boot between W1nd@ws and FreeBSD.  When I
> first set it up I made the partitions the same size, but since then I
> found I do a lot more with FreeBSD so I'd rather give it more space.
> 
> So the last time I had to reinstall Windows from scratch, I made its
> partition smaller.  Now there's a big chunk of free space between
> the two partitions.  Should I expect the following to work?
> 
> (back everything up, duh)

Yes.   Use dump(8) to back up each of the FreeBSD filesystems.

> Boot from a CD, change the partition table to make the FreeBSD partition
> start right after the Windows partition

Well, sort of maybe.    Do you mean the partition table or slice table?

First, I am guessing that you used some utility to officially shrink 
the slice (windows primary partition) where MS-Win is installed.

You need to rebuild the slice table.    You can do it in two ways.
One would be just make a slice that covers all the space you want
to use.   The other would be leave the existing slices in place and
make an extra one to use up the newly freed space.   Either/both of
these would be handled by the fdisk utillity.   If you use sysinstall
it sort of obscures the fact that it is using fdisk.    Probably, since
you have backed everything up and are sort of starting from scratch
on FreeBSD, you want to do the first.

So, delete the existing FreeBSD slice with fdisk (or in sysinstall)
and then create a new one that encompasses all the left over space.

> Use dd to move down the existing FreeBSD partition data so it starts
> at the beginning of the new partition

No, this is no good.   You cannot reuse the old partition data on the
new slice because the new slice is a different size.   You need to
create new partitions within the newly enlarged slice with bsdlabel 
(or if you use method 2, then you don't muck with anything in the 
old slice partition table.   You just create a new one in the new
slice, probably with just one partition - but don't bother with this.
Use method 1)

Use fdisk to delete that old FreeBSD slice and create a new one that
includes both the newly free space and the old FreeBSD space and make
sure the MBR is written (it should already be there actually) and the
slice is marked as bootable.    Lets say it becomes slice 2 on drive 0.
You will need to create a config file to make the fdisk work easily.
Probably sysinstall is easier for this.

Then run bsdlabel to write the boot sector on the slice and then
edit it.   You can use sysinstall for this too since you are already
in it from the fdisk, but it is easy to use directly as well.
  bsdlabel -w -B ad0s2    (or da0s2 if it is SCSI)  This writes the 
                          boot sector.
then
  bsdlabel -e as0s2       This causes an edit session to start.  Edit only
                          the parts below the line that has 
                           #    size    offset    fstype     etc
                          Don't change the 'c:' line.

Then do a newfs on each partition created in bsdlabel (except swap) 
and restore(8) the dumps and you are ready to go.

Now, if you are not already at FreeBSD 6.2, then this would be the
best time to just install it, csup everything including system, ports
and docs to the latest and  make build, install, reboot and merge, etc
 rather than bother moving over your old system as is.   Of course you 
have made and checked the dumps so you can get back your own data.

> 
> Use growfs to give the extra space to my /usr filesystem, which is at
> the end of the existing partition

No, you don't want to muck with growfs here.  You are expanding a
slice, not a filesystem.

> 
> Or should I just back it all up to a USB disk, reformat, and restore it,
> which will take considerably longer?

Yup, this is what you should do and essentially what I describe above.
If you can plug in and use a USB disk, so much the better.  You do
need to dump each filesystem separately, except don't bother with swap
and /tmp, or course.    Use dump(8)/restore(8) for the backups.  dd will 
not get you what you want.

////jerry

> 
> R's,
> John
> 
> 
> 
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070330155217.GC59175>