Resizing Partitions, Losing Windows XP...

backyard backyard1454-bsd at yahoo.com
Fri Sep 22 13:53:05 PDT 2006



--- Jeff Cross <jeff.cross at averageadmins.com> 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?
> 
> Any assistance is greatly appreciated!
> 
> Jeff Cross
> http://www.averageadmins.com/

> 
Yes failrly easily you can back everything up to
"tape"

first you must find a suitable backup medium such as a
USB hard drive. 
I use a 5 gig seagate drive I picked up along the way.
This allows a typcial root, var and about 5.6 gig of
stuff on /usr. With compression things aught to work.
You might want to clean up /usr/ports/distfiles,
/usr/obj, and 
run a "cd /usr/ports; make -DNOCLEANDEPENDS clean" to
get rid of any "unnecessary" files, but this is up to
you.

then...

I would suggest booting to safe mode on your current
FreeBSD install first of all

then do a

#fsck -p
for paranoia

#swapon -a
for swap

# mount -a -o ro

to mount the partitions read only. this isn't required
but if the drives are rw you need -L as a switch to
the dump command below.
mount -u /tmp
dump will use /tmp

then mount you backup media whereever you want I will
use /mnt as my mount point I also assume you have
separate partions for each drive.

then this monster will backup everything

(dump -0 -C 32 -f - / | bzip2 | dd of=/mnt/root.dbz2)
&& (dump -0 -C 32 -f - /var | bzip2 | dd
of=/mnt/var.dbz2) && (dump -0 -C 32 -f - /usr | bzip2
| dd of=/mnt/usr.dbz2)

then grab a coffee and wait for the tapes to be made.

now to restore there are better ways to do it but this
method has worked for me...

reboot with the FreeBSD install disk

go to fdisk and delete the old slices and create the
new slice. Use all disk, I would not do this
dangerously dedicated keep it compatible I've had boot
issues with boot drives in dangerously dedicated mode.
hit w to write the table it will ask if you are sure
say yes and install the boot loader you want, standard
MBR or the boot manager, your choice.

reboot

load up the cd and do bsdlabel mode
setup root, usr, var, tmp, swap whatever you use as a
partitioning scheme. this tool will require a root
partitio to be specified to work. then w to write the
label

now go to fixit mode on the cd and you'll be at a
prompt. if your backup media was Fat32, ext2,
basically anything but UFS1 or 2 you will type
sysctl kern.module_path="/dist/boot/kernel" to let the
kernel find the right modules to support fat32 then I
generally do a mkdir /TAPE and mount the backup media
there. you should also have the swap already loaded
and root will be mounted on /mnt usr will be /mnt/usr
and var will be /mnt/var
next type 

#mdconfig -a -t swap -s 512m

this will give you a md node prolly md1 512m is what I
use (512 mb of swap) but less may work fine.

#newfs md1

mkdir /junk; mount /dev/md1 /junk; cp /tmp/* /junk/;
umount /junk; mount /dev/md1 /tmp

restore will need this tmp directory to have space or
things will get messy

then I would 
#umount /mnt/var /mnt/usr /mnt 

then I usually reformat the partitions to get rid of
annoying error messages about directories alrady being
present during the restore

#newfs -O 2 -L root -n /dev/ad0s1a (adjust your device


as required the -L option isn't necessary

#newfs -0 2 -L var -U -n /dev/ad0s1d
#newfs =O 2 -L usr -U -n /dev/ad0s1e

again adust the devices as required

then remount root to /mnt
then
#bzip2 -dc /TAPE/root.dbz2 | (cd /mnt; restore -r -f
-)
mount var and usr then repeat for them with "cd
/mnt/usr" and "cd /mnt/var" as required. make any
changes to /mnt/etc/fstab as required, unmount
everything and you should be good to go for a reboot.
you may get some "expected 23423234 got 234253546"
messages in the restore. a few of them aren't a
problem. As suggested by others MAKE SURE YOUR DUMPS
ARE GOOD PRIOR TO DOING THE RESLICING AND
PARTITIONING!!!! you can use that restore command to
restore to whereever you want with the right change
dir so find some free space and doit. even if you run
a newfs on the windows slice and mount it unlabeled
just to see the dumps are good, and assuming you don't
care about windows being lost.

after the reboot delete the restoresymtable files on
each of the filesystems 

of course if you know fdisk and bsdlabel from the
command line using a freesbie live cd would prolly
make this easier and not require a reboot after the
fdisk...

I have had issues with the drives being able to boot
up  so I generally like to use grub. so readup on
manually installing the MBR or boot manager just in
case. I think my last restore I just chose the
standard MBR and everything went fine.

good luck

-brian


More information about the freebsd-questions mailing list