Let’s assume you rendered your FreeBSD system unbootable.. Yeah, happens to the best, but how can you still copy the data stored on a ZFS to another machine? You probably just shouted RSYNC - but it’s not that easy.
You would need a FreeBSD live os (either on a USB pen drive or on a CD/DVD) and boot into that system. However, by default you do not have network, the ZPool is not mounted, there is no rsync and SSH is not running, and the live os is not writable, which brings another few issues…
This is a step-by-step how-to through all the obstacles. Just boot into your live os (get it from freebsd.org) and go on with the following…
By default your live system does not have networking setup correctly.
ifconfig to see if the network interface is up. If it’s not you can bring it up using:
(assuming your inteface is called em0)
If it is up, you need to configure it. When you’re using a DHCP server you can just ask for an IP address using:
Otherwise you need to configure the addresses manually:
Afterwards you should be able to ping other machines, such as
Mount the ZPool
Your ZPool won’t be mounted by default; you need to do it manually. To list all pools available on that machine just call:
This searches through the devices in
/dev to discover ZPools. You may specify a different directory with
-d (see man page for zpool).
To actually import and mount your ZPool you need to provide its name, for example:
This will import the ZPool
zroot. Moreover, the argument
-o altroot=/mnt will mount it to
/mnt instead of
/ and the
-f will mount it even if it may be in use by another system (here we’re sure it isn’t, aren’t we?).
Create some Writeable Directories
The next problem is, that you do not have permissions to write to
/etc, which you need to e.g. create SSH host keys etc.
However, that’s also not a big issue as we have the
unionfs filesystem! :)
UnionFS will mount a directory as an overlay over another directory.
Let’s assume you have some space in
$SPACE (maybe in the ZPool that you just mounted or on another USB drive), then you can just create a few directories:
and mount it as
unionfs to the root’s equivalents:
Now we can write to
/etc, while the actual changes will be written to
$SPACE/etc! Isn’t that a great invention?
Start the SSH service
/etc is writable we can start caring about the SSH daemon.
First, we need to configure it to allow root to login.
Add the follwing line to the
Then, we can start the ssh daemon using:
It will automatically create host keys and all the necessary things for a first start of SSH.
If that was successful, port
22 should now be open:
Set root Password
To be able to login you of course need to set a root password:
Aftwerwards, you should be able to login through SSH from any other machine. Go ahaed and give it a try!
Install and Run rsync
Almost there, but the freeBSD live image doesn’t come with
So we need to do it manually:
This will first tell us that not even
pkg is installed, but answering the question with
y it will automatically install itself.
And as everything is mounted as UnionFS, the stuff will actually be installed to
$SPACE/... instead of
However, you should now be able to do the rsync job from where ever you want :)
- ssh (11) ,
- rsync (2) ,
- zfs (1) ,
- freebsd (2) ,
- recovery (1) ,
- fail (17) ,
- network (72) ,
- remote (16)