accidentally mount empty dataset on /

Hi,
I just broke my machine with the following comand
sudo zfs create -o mountpoint=/ pool/scratch
I thought the mounting point will be /scratch instead of /, Now I got an empty root file system, any idea How I can rescue my machine

Thanks
 
I think you may have to boot to some other media (e.g. USB, use the memstick installer in "Live CD"/Shell mode), and correct the problem there. You can import the pool and while doing so, tell it to either not mount the filesystems, or to use an alternate root (or both). Then simply change the mountpoint, and boot back to your original install.

Also, this would be better posted in the 'storage' section.
 
I think you may have to boot to some other media (e.g. USB, use the memstick installer in "Live CD"/Shell mode), and correct the problem there. You can import the pool and while doing so, tell it to either not mount the filesystems, or to use an alternate root (or both). Then simply change the mountpoint, and boot back to your original install.

Also, this would be better posted in the 'storage' section.

Thanks for reply, I know how to boot into a live CD but I don't know how to import the zpool without auto-mounting, Could you give me more detail of how to do that?
 
but I don't know how to import the zpool without auto-mounting
The easiest is to import with the -R option set.

Code:
         -R root
                 Sets the "cachefile" property to "none" and the "altroot"
                 property to "root"
Ignore the 'cachefile' for now, it's the 'altroot' we're after.
Code:
     altroot
         Alternate root directory. If set, this directory is prepended to any
         mount points within the pool. This can be used when examining an
         unknown pool where the mount points cannot be trusted, or in an
         alternate boot environment, where the typical paths are not valid.
         altroot is not a persistent property. It is valid only while the
         system is up.  Setting altroot defaults to using cachefile=none,
         though this may be overridden using an explicit setting.

Import the pool with altroot set to /tmp/zroot/ or something similar. Once it's imported you can change the mountpoint of the offending dataset to something more sensible.
 
Back
Top