Solved Migration to new hard drive


Well-Known Member

Reaction score: 19
Messages: 275

Is there a nice liveCD with FreeBSD I could use to copy my install to the new hard drive? I visited distrowatch and it did not show any live FreeBSD releases. I figured I'd boot from an external media and cp -a all contents of partitions to the new drive while both drives are attached, old and new.


Beastie's Twin

Reaction score: 2,120
Messages: 5,073

You can use the FreeBSD memstick installer for such usage. There is a LiveCD mode on it.
You want something like this:
cp -vipr /source /destination

The more appropriate way is with dump(8) and restore(8).
That way all the bootsector bits are written if you are using MBR.

I have also used dd to write an image of the source disk and then write it out to the new device.
It does copy everything including blank space which can be time consuming.
It also required that the destination be bigger than the source.



Reaction score: 744
Messages: 1,159

You can use the FreeBSD memstick installer for such usage. There is a LiveCD mode on it.
You want something like this:
cp -vipr /source /destination

Perhaps you meant -R, since -r actually means -RL, and this would follow symbolic links, i.e. copy the linked file instead of copying the link. -RL is useful if you copy parts of a file system and want to make sure that it is self-contained. On the other hand, if we want to clone the whole file system, we want to maintain the symbolic links because otherwise we end up with two or more separate files, which later on may lead to confusion.

For example, on a pristine FreeBSD installation /etc/unbound is linked symbolically to ../var/unbound, and with the -r = -RL option, we would end up with two different unbound configuration locations, and I am not even sure which would be actually used by local_unbound.

Another obstacle of cp(1) is, that it does not maintain hard links. Hard links are always copied as separate files, so the resulting clone would occupy more space than the original file system.

Coming from macOS, I was always using a tool named ditto(1) for this kind of copying tasks. I was missing this for FreeBSD, and therefore I developed a tool for FreeBSD which works alike, although it got different options and a different name, namely clone(1). It is in the ports - sysutils/clone. For cloning the whole root UFS2 file system to another empty UFS2 volume mounted at /mnt, by maintaining all attributes, extended attributes, ACLs, sym- and hard links we would execute as user root:
# clone / /mnt

For completeness, net/rsync would also be suitable for creating exact clones of whole file systems:
# rsync -axAHX --fileflags / /mnt

For ZFS volumes we would use the zfs send | zfs receive combo instead.