How can I change the mount point for a ZFS pool/dataset that is currently in use? I don't mind if it doesn't change immediately and I need to reboot, but I can't work out how to do it:

$ zfs set mountpoint=/srv/oldpool pool
umount: /srv/pool/dataset1: target is busy.
cannot unmount '/srv/pool/dataset1': umount failed

$ zfs get mountpoint pool
pool  mountpoint  /srv/pool     local

It refuses to make the change unless it can unmount all the datasets successfully.

When the system boots, the ZFS volumes are immediately in use so it would be nice to be able to change the mount point for the next boot, but it doesn't look like that's possible?

I'd like to avoid having to boot into single-user mode if possible!

(The reason for asking is I've copied the pool off failing disks onto a new pool on different disks, and now I want to swap everything over to the new pool by mounting it in place of the old one.)

  • either boot to single-user OR kill every process that has an open file on that dataset. your best option is to boot to single-user, import the new pool to the correct place, then import the old pool with a different mountpoint (be wary of datasets in the old pool that don't just inherit the root of their mountpoint from the old pool, you'll have to remount them manually) and run a final zsend to copy over everything that changed on the old pool since the last zsend. – cas Oct 28 '19 at 1:03
  • @cas: I'm the only one using it so no issues with data loss or seamless transfer, it just strikes me as odd that you can't set a new mount point to be used the next time you reboot! – Malvineous Oct 28 '19 at 8:04
  • You sort of can, when you import a pool. Look up altroot in man zpool. e.g. when you create a new pool to replace and old one, you set the altroot so the whole new pool gets temporarily mounted at that point. then you zfs send the old pool to the new. then export the old pool and reboot. It's not as flexible as what you're asking for, but like i said shutdown anything with open files on a dataset and you'll be able to unmount it. same as any other mounted filesystem (you can't unmount an xfs or ext4 fs with open files on it either). – cas Oct 28 '19 at 9:33
  • Interesting. To be fair with xfs or ext4 you can go edit /etc/fstab to set the new mount point and when you reboot it'll be applied :-) – Malvineous Oct 29 '19 at 5:06
  • and with zfs, you can do something similar with zfs set canmount=noauto. – cas Oct 29 '19 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.