# How to move my FreeBSD to HDD



## phpwolf (Jun 24, 2013)

Hello,

I have a FreeBSD-9.1 perfectly installed/configured on an external HDD (USB HDD device) and I want to clone/copy/move this entire system to my internal HDD. On the external HDD I have this:


```
Filesystem 1K-blocks     Used     Avail Capacity  Mounted on
/dev/da0p2 298599604 16333612 258378024     6%    /
devfs              1        1         0   100%    /dev
```

and I want to copy/clone this to /dev/ada0p2.

Is it okay to copy everything from /dev/da0p2 to /dev/ada0p2, modify /etc/fstab from /dev/ada0p2/ to recognize my / partition and then `boot0cfg` on /dev/ada0? Is there another way to copy the system from a device to another?

Thank you,
phpwolf


----------



## wblock@ (Jun 24, 2013)

Yes, this can be done.

Set up the new drive: Disk Setup On FreeBSD.  That shows setting up split filesystems.  If you want to duplicate the single-filesystem setup you have now, just create a single freebsd-ufs partition for it.  Be sure to give it enough space to hold everything.  This setup includes writing the bootcode.  boot0cfg(8) will not work on GPT setups (not correctly, anyway) and is not needed unless you want to boot multiple operating systems from different partitions.

Backup Options For FreeBSD shows the details, including copying from one drive to another.


----------



## jalla (Jun 24, 2013)

You should use dump/restore to do the actual copying of the system. I assume you want to keep the single partition layout, in that case your course of action would be something like this:

```
# mount /dev/ada0p2 /mnt
# cd /mnt
# dump -L0f - /dev/da0p2 | restore -rf -
```
Next modify /mnt/etc/fstab as appropriate. Depending on what partitioning scheme you use, you may want to install bootcode with boot0cfg().

On reboot, go into the BIOS configuration and change _the_ boot order to boot from _the_ internal HDD first.


----------



## wblock@ (Jun 25, 2013)

dump(8) will go faster with -b64, nearly twice as fast when I benchmarked it.  -a is a good idea, increasing -C to 16 or 32 might make it faster (I've never timed that, but people have a lot of unused memory these days).


----------



## SirDice (Jun 25, 2013)

I've never used it myself but you could have a try with sysutils/clonehdd.


----------



## jozze (Jun 25, 2013)

Apart from other valuable pieces of advice, you can consider creating a snapshot of your filesystem, and then using the dd command to write it somewhere else. It is a bit tricky though.

Fist read through this how-to. As you can see, you cannot create a snapshot of the root (/) partition, but there is a "workaround": you boot your system from the LiveCD, mount your root partition (let's call it /dev/ada1p2) in /mnt, your "usr" partition in /mnt/usr and so on. After that you can create a snapshot somewhere under /mnt, since that filesystem is writable. Make sure, that if you're creating a snapshot of partition "A", it has to be saved under "B", or you might be in for a surprise, since a snapshot, while making a snapshot, could then try to make a snapshot of itself.

Then you use the dd command to simply copy the entire filesystem to a different location.


----------

