6

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 NAME PROPERTY VALUE SOURCE 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.)

5
  • 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. Commented Oct 28, 2019 at 1:03
  • 1
    @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! Commented Oct 28, 2019 at 8:04
  • 1
    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). Commented Oct 28, 2019 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 :-) Commented Oct 29, 2019 at 5:06
  • 1
    and with zfs, you can do something similar with zfs set canmount=noauto. Commented Oct 29, 2019 at 6:09

1 Answer 1

3

I tried zfs set canmount=noauto <dataset> and then rebooted, but the datasets were still mounted.

I found the answer for OpenZFS versions 2.2.0 and higher at https://serverfault.com/a/1148641/127791: just add the -u flag to the zfs set mountpoint command, i.e. zfs set -u mountpoint=/location <dataset>. All good after reboot.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.