# Installing a partition from a partition image



## balanga (Apr 2, 2020)

Apologies, if this is a naive question, but I'm not sure of the answer...

If I have a working FreeBSD system can I dd() a partition as a file, ie `dd if=/dev/da0s2 of=/mnt/backup/partion.img`  and subsequently run dd to copy to another partition, will I then have a working system on the target system? ...assuming the new system is correctly partitioned and bootable, and with a correctly amended /etc/fstab


----------



## SirDice (Apr 2, 2020)

Yes, that should work.


----------



## VladiBG (Apr 2, 2020)

using dd will work but you will end up with copy the free space which will be time consuming and you will end up with a bigger .img file. It's better to use dump/restore for UFS or send/receive for ZFS.


----------



## balanga (Apr 2, 2020)

Or would I be better off using tar() in order not to waste unused space?


----------



## T-Daemon (Apr 2, 2020)

There is also this tool,  sysutils/ufs_copy . It claims to be a fast copy utility for UFS filesystem, doesn't copy free blocks, can compress saved file, can make snapshots, here the manual:


			https://people.freebsd.org/~simokawa/ufs/README


----------



## tingo (Apr 2, 2020)

The "canonical" tools for doing filesystem backups and restore under FreeBSD are dump(8) and restore(8). They are (like many mature unix type tools) not (newbie)user friendly, but they are not very hard to learn either.


----------



## Alain De Vos (Apr 2, 2020)

I copied many times a freebsd partition & installation with just "cp -axf"


----------



## balanga (Apr 3, 2020)

T-Daemon said:


> There is also this tool,  sysutils/ufs_copy . It claims to be a fast copy utility for UFS filesystem, doesn't copy free blocks, can compress saved file, can make snapshots, here the manual:
> 
> 
> https://people.freebsd.org/~simokawa/ufs/README



I'd never heard of this program before, so thanks for making me aware of it.


----------



## balanga (Apr 3, 2020)

Alain De Vos said:


> I copied many times a freebsd partition & installation with just "cp -axf"


It's always useful to know what options people use. I'd never used -x or -f before, but having '-axf' sounds like a good default.

Maybe I should create an alias of 'xcopy' which invokes 'cp -axf'...


----------

