Solved How to mount another zfs hard disk?

Hi,
I have a problematic hard disk that was removed from a FreeBSD machine. This hard disk may have some useful data that I'm looking for. I've packed the disk using a USB storage box, connecting to a computer is not a problem. Then the question is, how do I mount this disk on a FreeBSD system. What I'm interested is the data in the disk, so if anyone tells me how to access the data on a Windows 10 system, I'd be grateful as well.
 
I don't think Windows can deal with ZFS, other than offer you the option to format it to NTFS - thus destroying all data.
You may be better off using an install USB stick and booting into a life system. Here, some Linux versions may come with ZFS enabled in the life system. The FreeBSD install stick should be able to handle it directly. For how to force it into a different directory instead of the old mount points, see the man page for ZFS.
 
I don't follow.
Why bother with linux or FreeBSD install memory stick? I'm hoping to plug the hard disk in question to a working FreeBSD system, type some commands or tweak a few conf files, then I'm all set.
Does it not work this way?

I don't think Windows can deal with ZFS, other than offer you the option to format it to NTFS - thus destroying all data.
You may be better off using an install USB stick and booting into a life system. Here, some Linux versions may come with ZFS enabled in the life system. The FreeBSD install stick should be able to handle it directly. For how to force it into a different directory instead of the old mount points, see the man page for ZFS.
 
Then the question is, how do I mount this disk on a FreeBSD system. What I'm interested is the data in the disk, so if anyone tells me how to access the data on a Windows 10 system, I'd be grateful as well.

From this quote it is not clear to me whether you want to read this ZFS UFS disk (it is one, right?) on a windows or FreeBSD system.
 
I don't think there exist ufs/zfs drivers for Windows.
So best boot freebsd and copy the relevant ufs/zfs files , to a fat32 or ntfs filesystem. Then these files will be accesible in Windows.
 
FTR: yes, there is a ZFS implementation for windows - but last time I checked it was still highly experimental and of course (because windows...) not trivial to get running.


I'd be careful connecting a disk directly used by ZFS (i.e. whole disk without a GPT/partition table) to a windows box - even if you decline the "format new disk" dialogue, it tends to just "repair" the (or write a new) GPT/partition table and nukes whatever was on the first few sectors. Been there with an external disk containing a zfs pool, which a colleague connected to his windows 10 client...
 
Guys, didn't know my English is this poor. One more try.
The hard disk I'm talking about was taken out from a FreeBSD laptop a few days ago because it was detected some serious errors. It was ZFS formatted. It may still have some useful data I forgot to back up and now I would like to try to get the data. I have access to computers running FreeBSD or Windows, so in the original post I said I'm ok using either system to get the data on the disk.
Now from the replies so far it looks to me that using Windows to access the data on a ZFS disk is not the way to go. In this case, what should I do in FreeBSD system?
 
if anyone tells me how to access the data on a Windows 10 system, I'd be grateful as well
Install Hyper-V on the Windows 10. Create an VM gen2 and install FreeBSD on it(same version or newer than the ZFS version of the disk). Attach the disk on your Hyper-V host and mark it OFFLINE under windows disk management and then present it as physical hard-disk to the FreeBSD VM. Then start the FreeBSD and identify the disk using camcontrol devlist then import it using zpool import -f -o altroot=/mnt -d {device}

The same can be done if you attach the disk on physical computer which already have FreeBSD installed instead of trying to access in under Windows 10.

1676561680634.png
1676562241749.png


zpool-import(8)
 
what should I do in FreeBSD system?

Attach disk, import pool without mounting anything ( zpool import -N) and maybe run a scrub to see how badly damaged the data is. checking the smart data before/during/after scrub might also be helpful to get an idea how critical the state of that disk might be.

Then just mount the datasets readonly ( zfs mount -o ro) you want to get data off somewhere (e.g. /mnt) or zfs send|recv the whole dataset to another pool.
If the disk is heavily increasing its bad sector count during the scrub, I'd stop that ( zpool scrub -s) and just try to zfs send|rcv the most important datasets ASAP.
 
The hard disk I'm talking about was taken out from a FreeBSD laptop a few days ago because it was detected some serious errors.
You should clone this disk with dd command, instead of mounting it directly. You can clone it to another empty disk, or to a file. Target hard disk should not utilize SMR technology. No extended tests, like scrub, should be done with malfunctioning drive before this step.
 
Well, just writing down what I learned.

# zpool import -f -o altroot=/mnt/mydata mypool only imports or mounts /usr, /var, /temp and /zroot.

I have to run # zfs mount -o mountpoint=/mnt/temp mypool/ROOT/default to mount other or whole file system. It is worth mentioning that the whole file system is then mounted to /mnt/mydata, not /mnt/temp as I specified in the command line.

Then # zfs umount /mnt/mydata only unmounts what was mounted by # zfs mount. Those that were imported don't get unmounted.

BTW, either # zfs umount or # zfs unmount is valid.
 
Here is an annoying issue.

There was one time, I didn't specify altroot and ran zpool import -af, the whole file system on this newly attached disk was mounted to / of the host system, and it has confusing and annoying behaviors:
1. It overlays the existing home directory, and many others, on the host.
2. If I keep this disk attached and reboot the system, the pool is imported during boot and again overlays the existing home directory.

Running zpool export mypool fails. No supprise as the pool is being used.

How do I get rid of this auto-importing behavior during boot?
 
How do I get rid of this auto-importing behavior during boot?
Information about the imported pools are stored in a zpool.cache file. To get rid of the unwanted pool remove /etc/zfs/zpool.cache, then reboot the system.

The unwanted pool shouldn't be imported anymore. Now create a new cache file:

zpool set cachefile=/etc/zfs/zpool.cache zroot

Documentation regarding zpool.cache: OpenZFS - The /etc/zfs/zpool.cache file and how to generate a new one.

FreeBSD has a second cache file, /boot/zfs/zpool.cache, which contains information only of the installed pool, not later imported pools.
 
This works. Great. Thanks for the insight.

zpool set cachefile=none mypool serves the purpose as well.


Information about the imported pools are stored in a zpool.cache file. To get rid of the unwanted pool remove /etc/zfs/zpool.cache, then reboot the system.

The unwanted pool shouldn't be imported anymore. Now create a new cache file:

zpool set cachefile=/etc/zfs/zpool.cache zroot

Documentation regarding zpool.cache: OpenZFS - The /etc/zfs/zpool.cache file and how to generate a new one.

FreeBSD has a second cache file, /boot/zfs/zpool.cache, which contains information only of the installed pool, not later imported pools.
 
Back
Top