ZFS ZFS - restore /tmp

Did a pretty dumb mistake. I saved contents in a folder in /tmp (zroot/tmp - standard dataset created by installer) and did a reboot.
Can it be restored?
 
Unless you've specifically configured to clear /tmp/ your files should still be there.
 
Unless you've specifically configured to clear /tmp/ your files should still be there.
Looks like on at least FreeBSD-13 the default is to NOT clear tmp.
Check in /etc/rc.conf for a line like this:

clear_tmp_enable="YES"

If you do not have it, /tmp should be persistent across reboots. /etc/defaults/rc.conf has it as "NO"
 
Looks like on at least FreeBSD-13 the default is to NOT clear tmp.
Yep. And as long as you're still using the default zroot/tmp dataset then it should be fine. I usually configure my systems to use tmpfs(5) for /tmp. In that case everything is gone after a reboot.
 
  • Like
Reactions: mer
You can also set to clear /tmp (zroot/tmp) of all the programs automatically generated files, save temporary files and keep them between system reboots in /var/tmp (zroot/var/tmp). See hier(7)
 
Sadly, I enabled clear_tmp. Checked the script, it does "rm -rf" which means delete without any possibility for recovery, afaik. /var/tmp is empty besides ".vi.recover" which is empty as well... :,-(
Since it´s on ZFS - is there possibly a tool to recover deleted items there? Or is that recovery all based on snapshots (which I don´t have)?

Anyway - thanks for your help

Greetings from hell
Betzi
 
it does "rm -rf" which means delete without any possibility for recovery, afaik.
Yes, rm(1) on Unix/Unix-like systems is pretty definitive. Although there are recovery tools that could find deleted files but it'll highly depend on the used filesystem and none of them can guarantee they can get anything back.

Since it´s on ZFS - is there possibly a tool to recover deleted items there?
There is no 'undelete' function if that's what you're asking. As far as I know there are no recovery tools than can deal with ZFS either.
Or is that recovery all based on snapshots (which I don´t have)?
Yes, that's what snapshots are typically used for. But those need to have been created in advance of course.

I'm afraid you're going to have to chalk this one up as a learning experience. I would almost call it a "rite of passage", I believe we've all deleted or destroyed something we shouldn't have ;)
 
I found that there are in fact ZFS recovery tools - interestingly one for Windows! I unmounted the dataset to prevent further writes. Will check later.
 
I found that there are in fact ZFS recovery tools - interestingly one for Windows! I unmounted the dataset to prevent further writes. Will check later.
It is unlikely that anyone other than a super-expert (typically developer) will be able to successfully use those tools. File system data structures are complex, full of interrelationships that you have to get right, and mistakes when modifying them tend to have far-reaching effects.
 
Was busy (life...) before I finally got to work on this. Sharing the 2 approaches to recover files, I tried for afterworld.

1.) Mount ZFS pool via historic transaction groups (TGX) in order to access a previous state of the pool still available in the records. Here is a link outlining this a bit: https://lists.freebsd.org/pipermail/freebsd-hackers/2013-July/043131.html
In my case it failed because I changed the SSD cache a few days before I deleted my stuff so most historic TGX didn´t mount because they lacked the old cache device.

2.) UFS Explorer. This software - e.g. from a Linux thumbdrive or even from Windows - can scan the whole pool block for block and restore deleted files - in my case even from a RAIDZ2!
Took several days and I accidentially ran the scan with the professional version for which there is no hobbyist licence. Should have used the RAID version instead, but now I was unable to just export my large files.
But as the trial allows to export files smaller than a certain size, I was able to mount the recovered Virtualbox images and export the missing configs from their folder tree - which I could combine with older backups of my VirtualBox images.
I cannot confirm that the whole 4GB disk image would have been restored without a fault, but all the files I exported from there where uncorrupted. Great software and worth a tr(y/ial) in case of anyone repeating my stupidity.

Thanks to everyone commenting!

P.S. Even more stupid after learning, how easy ZFS snapshots can be used and cron scripted!
 
Back
Top