Moving Freebsd to a new Server

Jerry McAllister jerrymc at msu.edu
Thu Jun 7 17:55:06 UTC 2007


On Thu, Jun 07, 2007 at 03:38:01AM -0400, Ian Lord wrote:

> Hi,
> 
> We were in a rush to install a freebsd server without proper hardware on
> hand, so we used Microsoft Virtual Server and install Freebsd on it.
> 
> I would like to move the freebsd installation to a real server and was
> wondering how to do so.
> 
> I searched around and the solution seems to be to dump the hard drive
> content and restore it on the new server.

Yes, I have written this essential thing with slight variations several
times in the questions list.   You might want to search in the archives.

> Does anyone knows a good walkthrough of the entire process, I didn't find
> anything in the handbook beside moving freebsd to a new harddrive which I
> cannot do from the same machine.
> 
> Basically, I need a way to dump the hd to file, transfer the file over
> whatever media (dvd, network, etc) and restore on the new machine. 
> 
> I'm not even sure if I need to install freebsd on the new machine or not
> since I guess I cannot overwrite the partition on which freebsd is running
> :-)

Hmmm.  I am not sure what you are implying here.   
Do you mean that the new server already has (the latest) FreeBSD installed
on it?   If so, and your data and such are conveniently organized, then
you can just make sure the needed ports are [freshly] installed and then
merely transfer over the data you need.   That would be best.

But, if you really need to move everything from the old system over
to the new server systemr, then yes dump/restore is the best.

First, build the Disk structure on the new server.  You can do that
by using the install CD to do a minimal install or just use the 
fixit and run fdisk, bsdlabel and newfs from it to create the slice,
partitions and file systems respectively.   Neither is more difficult,
but using the installer does some of the keeping track for you while
you are doing things whereas doing the fdisk,bsdlabel,newfs gives you
a little more direct control.

Under either path, you must get the disk prepared and write the FreeBSD MBR
make a slice for FreeBSD, make it bootable and make at least one partition
for root (preferably divide things a little better, but...) and one
partition for swap (I suggest making root, swap, /tmp, /usr, /var /home).
In this case, you probably want to divide it according to the older
machine's pattern, using updated sizes based on the new disk.

Then, you want to transfer things.
For each filesystem on the old system  --- skip swap and /tmp
write the filesystem out using dump(8) to some media where there
is enough room and that can be reached by the new machine in some way.

    dump 0aLf /directory_or_device_name_rootdump /
    dump 0aLf /directory_or_device_name_usrdump /usr
    dump 0aLf /directory_or_device_name_vardump /var
    dump 0aLf /directory_or_device_name_homedump /home
etc
(NOTE, make those directory_or_device_name things something reasonable, 
     like the directory or device where you are writing the stuff)

Then boot the fixit on the install CD on the new server
and use it to restore those filesystems in place.   If there is
room, you can just copy the dump file to a big space on the new
server (such as to /newhome) using whatever is appropriate - ftp/scp
probably and restore from there.    

You will need to create mount points and mount the new filesystems.
So, do something like this while in fixit.
    mkdir /newroot
    mount /dev/ad0s1a /newroot
    mkdir /newusr
    mount /dev/ad0s1e /newusr
    mkdir /newvar
    mount /dev/ad0s1f /newvar
    mkdir /newhome
    mount /dev/ad0s1g /newhome

(Here I am presuming the partition names e, f, g.   root has to be 'a')

If you really wrote these to something like a CD, then you will also
have to mount that.  Probably the /cdrom mountpoint will already exist
but if not, then make it.  Then mount it.
    mount_cd9660 /dev/acd0 /cdrom


So, lets assume you have copied the dump[s] to /home on the new
machine.   You could do it directly from the CD if that is where it is.
      (You may need to do each filesystem one at a time to have enough
       room to do it, especially for /home if it is large)
Then do:

    cd /newroot
    restore rf /newhome/rootdump 
    rm /newhome/rootdump
    cd /newusr
    restore rf /newhome/usrdump
    rm /newhome/usrdump
    cd /newvar 
    restore rf /newhome/usrdump
    rm /hewhome/vardump
    cd /newhome
    restore rf homedump
    rm /newhome/homedump
  (if there is plenty of room, done worry that you are restoring to 
   the same directory /newhome, that you are reading from.  It will 
   work just right.   But the /newhome filesystem will have to be
   double the size of the homedump file
If you are reading directly from the CD, then it would look like
    cd /newroot
    restore rf /cdrom/rootdump      (providing you used my name conventions)

Then try rebooting and hopefully it will all be happy.

////jerry

> 
> Any help/reference would be appreciated
> 
> Thanks in advance
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list