Solved Getting image file from ZFS disk

I want to full back up my FreeBSD 12.2 system. I want a image file that be able to setup other computers. How?
 

SirDice

Administrator
Staff member
Administrator
Moderator
A reinstall is usually a lot quicker than restoring a backup. Separate data from the OS, backup that, because that's important. Document what you installed and how you configured it. An OS or a bunch of applications can always be easily reinstalled, your data however cannot be easily recreated.

Images are useful in situations where you need to spin up VMs for example, then you can quickly clone them. They're not that useful for installing on "iron".
 
To backup you only need "cp" in my humble opinion.
Some use "rsync", "clone" is also not bad.
That easy? LoL yea but sounds true. I can use rsync for do it faster. So can I copy /dev things too? and proc? and why "dd" command exist if its just that?
 
D

Deleted member 67440

Guest
If you have "something" to get the backup (in this example an hard disk, da1)

Code:
pkg install -y pv pigz
zpool create mybak da1
zfs snapshot -r zroot@mybackup
zfs send -R zroot@mybackup |pigz|pv >/mybak/c.zfs.gz
... or send to "something" (with ssh), USB key etc.

On the new one (for example da0 disk, but whatever), with attached da1
(the disk containing the backup, of course can be whatever, just a snippet)
Boot from ISO, USB Key, whatever (I use https://mfsbsd.vx.sk/)
Code:
gpart destroy -F da0
gpart create -s gpt da0
gpart add -a 4k -t freebsd-boot -s 512k -l boot da0
gpart add -a 4k -t freebsd-swap -s 16g -l swap0 da0
gpart add -a 4k -t freebsd-zfs -l zfs0 da0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0
gnop create -S 4096 /dev/gpt/zfs0
zpool create -f -o altroot=/mnt -O canmount=off -m none zroot /dev/gpt/zfs0.nop

Now restore the image
Code:
zpool import -o altroot=/mnt -f mybak
gzcat /mnt/mybak/c.zfs.gz | zfs receive -vF zroot
shutdown -r now
Shutdown not really necessay, but I get LOT LESS problems with a reboot

Code:
zpool import -o altroot=/mnt -f zroot
zpool set bootfs=zroot/ROOT/default zroot
shutdown -r now
 

SirDice

Administrator
Staff member
Administrator
Moderator
So can I copy /dev things too? and proc?
Why do you think you need to copy those? They're dynamic, virtual, filesystems (see devfs(5) and procfs(5)). Devices are created based on the hardware the machine has, and proc only contains information about things that are currently running on that machine.
 
D

Deleted member 67440

Guest
That easy? LoL yea but sounds true. I can use rsync for do it faster. So can I copy /dev things too? and proc? and why "dd" command exist if its just that?
dd is archaic, with zfs.
It is rarely used, often with virtual machines.
 
The question how do you copy /dev is however interesting. It is said you "make special files".
The freebsd installer does this for you ....
 
Why do you think you need to copy those? They're dynamic, virtual, filesystems (see devfs(5) and procfs(5)). Devices are created based on the hardware the machine has, and proc only contains information about things that are currently running on that machine.
Yea I mean this by saing cp not a very nice option. cp / thing copies that dynamic dirs too. So cp seems to not a very clean solution.
 
He wants a "ghost" image to blast on other computers, although this method will copy SSH keys, not change the hostname, etc.
SSH keys and I guess it will copy GUID and things like that too. Not very nice but maybe I can randomize them later by a script huh?
 
The "dumb" way to do this is to boot from some other media, don't mount the system and dd the disk to a file on some third media. This does not account for disk sizes, resizing the disk, and isn't space efficient.
 
I want to full back up my FreeBSD 12.2 system. I want a image file that be able to setup other computers. How?
The main and ZFS-native way is to use send streams. You could save a file of the output of "zfs send" and keep that around for future receive operations.
 
Top