Unlike many other filesystems, ZFS mounts the pools and filesystems that you create automatically.

If you create a ZFS pool pool1, it will automatically mount it in the /pool1 directory of your computer.

If you create a ZFS filesystem documents on pool pool1, it will automatically mount it in the /pool1/documents directory of your computer.

In the same way, if you create another ZFS filesystem downloads on pool pool1, it will automatically mount it in the /pool1/downloads directory of your computer. You get the idea.

In this article, I am going to show you how to mount ZFS pools and filesystems in other directories of your computer. So, let’s get started.

Table of Contents

  1. Filesystem Properties for Configuring ZFS Mounting Behavior
  2. Changing Mount Path of ZFS Pools
  3. Changing Mount Path of ZFS Filesystems
  4. Disable Mounting for ZFS Pools
  5. Conclusion
  6. References

Filesystem Properties for Configuring ZFS Mounting Behavior

The mounted property of the ZFS filesystem is used to find out whether a ZFS pool/filesystem is mounted on your computer or not. If a ZFS pool/filesystem is mounted on your computer, the mounted property will be set to yes. If a ZFS pool/filesystem is not mounted on your computer, the mounted property will be set to no.

NOTE: mounted is a read-only property, and you can’t change that from one value to the other. ZFS will automatically change the value of the mounted property depending on whether a ZFS pool/filesystem is mounted or not.

The canmount and mountpoint properties of the ZFS filesystem are used to configure the mounting behavior of the ZFS pools and filesystems.

ZFS uses the canmount property of a pool/filesystem to determine whether the pool/filesystem can be mounted or not.

ZFS uses the mountpoint property of a pool/filesystem to determine the directory path where it will mount the pool/filesystem.

The canmount property can have the values: on, off, or noauto. The default is on for new ZFS pools and filesystems. If this property is set on a ZFS pool, it is not inherited by the filesystems created on that pool.

  • canmount=on — The ZFS pools and filesystems that have canmount set to on can be mounted automatically on the directory path set by the mountpoint property.
  • canmount=noauto — The ZFS pool/filesystem that has canmount set to noauto can be mounted on the directory path set by the mountpoint property of the pool/filesystem. However, ZFS won’t do it automatically. You will have to do it manually instead.
  • canmount=off — The ZFS pools and filesystems that have canmount set to off can’t be mounted.

When you create a ZFS pool pool1, the mountpoint of the pool pool1 is set to /pool1, and canmount is set to on. When you create a new ZFS filesystem documents on the pool pool1, the mountpoint for the filesystem is set to /pool1/documents, and its canmount is set to on by default. In the same way, if you create another ZFS filesystem downloads on the pool pool1, the mountpoint for the filesystem is set to /pool1/downloads, and its canmount is set to on by default.

You should know the basic theory to understand how the ZFS pools/filesystems mounting process works. In the next sections, I will show you several practical examples of what I have discussed in this section. Let’s move on.

Changing Mount Path of ZFS Pools

For the demonstration, I will create a new ZFS pool using the vda and vdb storage devices, as seen in the screenshot below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-01.png" data-lazy- height="541" src="data:image/svg xml,” width=”974″>

To create a new ZFS pool pool1 using the vda and vdb storage devices in mirror configuration, run the following command:

$ sudo zpool create -f pool1 mirror vda vdb

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-02.png" data-lazy- height="108" src="data:image/svg xml,” width=”974″>

A new ZFS pool pool1 should be created. The mountpoint should be set to /pool1, as seen in the screenshot below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-03.png" data-lazy- height="331" src="data:image/svg xml,” width=”974″>

As you can see, the ZFS pool pool1 is mounted (mounted is yes). It can be mounted (canmount is on), and its mount directory path is /pool1 (mountpoint is /pool1).

$ sudo zfs get mounted,canmount,mountpoint pool1

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-04.png" data-lazy- height="372" src="data:image/svg xml,” width=”974″>

You can verify that the ZFS pool pool1 is mounted on the /pool1 directory of your computer from the output of the df command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-05.png" data-lazy- height="364" src="data:image/svg xml,” width=”974″>

To change the mount path of the ZFS pool pool1 to /mypool, set the mountpoint property of the ZFS pool pool1 as follows:

$ sudo zfs set mountpoint=/mypool pool1

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-06.png" data-lazy- height="122" src="data:image/svg xml,” width=”974″>

As you can see, the mountpoint property of the ZFS pool pool1 is set to /mypool:

$ sudo zfs get mountpoint pool1

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-07.png" data-lazy- height="308" src="data:image/svg xml,” width=”974″>

The mount path of the ZFS pool pool1 should be changed to /mypool, as seen from the output of the df command below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-08.png" data-lazy- height="350" src="data:image/svg xml,” width=”974″>

Changing Mount Path of ZFS Filesystems

In this section, I am going to show you how to change the mount path of ZFS filesystems.

Create new ZFS filesystem documents on the ZFS pool pool1 with the following command:

$ sudo zfs create pool1/documents

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-09.png" data-lazy- height="122" src="data:image/svg xml,” width=”972″>

A new ZFS filesystem documents should be created on the ZFS pool pool1, and its mountpoint should be set to /mypool/documents, as you’ve changed the pool pool1’s mountpoint to /mypool earlier:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-10.png" data-lazy- height="391" src="data:image/svg xml,” width=”974″>

As you can see, the ZFS filesystem documents are mounted (mounted is yes). It can be mounted (canmount is on), and its mount directory path is /mypool/documents (mountpoint is /mypool/documents):

$ sudo zfs get mounted,canmount,mountpoint pool1/documents

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-11.png" data-lazy- height="256" src="data:image/svg xml,” width=”974″>

The ZFS filesystem documents should be mounted on the /mypool/documents directory of your computer, as seen from the output of the df command below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-12.png" data-lazy- height="400" src="data:image/svg xml,” width=”974″>

To change the mount path of the ZFS filesystem documents to /mydocs, set the mountpoint property of the ZFS filesystem documents as follows:

$ sudo zfs set mountpoint=/mydocs pool1/documents

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-13.png" data-lazy- height="95" src="data:image/svg xml,” width=”974″>

As you can see, the mountpoint property of the ZFS filesystem documents is set to /mydocs:

$ sudo zfs get mountpoint pool1/documents

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-14.png" data-lazy- height="320" src="data:image/svg xml,” width=”974″>

The mount path of the ZFS filesystem documents should be changed to /mydocs, as seen from the output of the df command below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-15.png" data-lazy- height="406" src="data:image/svg xml,” width=”974″>

Disable Mounting for ZFS Pools

At times, you may only want to mount the ZFS filesystems of a ZFS pool but not the pool itself. In that case, you can disable mounting for the said ZFS pool and only set mount paths for the filesystems on that ZFS pool.

I will create a new ZFS pool using the storage devices vdc and vdd to demonstrate it:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-17.png" data-lazy- height="547" src="data:image/svg xml,” width=”974″>

To create a new ZFS pool pool2 using the vdc and vdd storage devices in mirror configuration, run the following command:

$ sudo zpool create -f pool2 mirror vdc vdd

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-18.png" data-lazy- height="106" src="data:image/svg xml,” width=”974″>

A new ZFS pool pool2 should be created and its mountpoint should be set to /pool2.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-19.png" data-lazy- height="424" src="data:image/svg xml,” width=”974″>

As you can see, the ZFS pool pool2 is mounted (mounted is yes). It can be mounted (canmount is on), and its mount directory path is /pool2 (mountpoint is /pool2):

$ sudo zfs get mounted,canmount,mountpoint pool2

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-20.png" data-lazy- height="270" src="data:image/svg xml,” width=”974″>

The ZFS pool pool2 should be mounted on the /pool2 directory of your computer, as seen from the output of the df command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-21.png" data-lazy- height="393" src="data:image/svg xml,” width=”974″>

Since you don’t want ZFS to mount the ZFS pool pool2, set the canmount property of the ZFS pool pool2 to off as follows:

$ sudo zfs set canmount=off pool2

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-22.png" data-lazy- height="124" src="data:image/svg xml,” width=”974″>

As you can see, even though the ZFS pool pool2 is not mounted (mounted is no) and mounting is disabled (canmount is off) for the pool, the mountpoint property is set to /pool2. The ZFS filesystems you create on the pool pool2 will use it to set its mountpoint property. It will not inherit the mounted and canmount property from the pool pool2:

$ sudo zfs get mounted,canmount,mountpoint pool2

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-23.png" data-lazy- height="358" src="data:image/svg xml,” width=”974″>

As you can see, the ZFS pool pool2 is not mounted anymore:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-24.png" data-lazy- height="381" src="data:image/svg xml,” width=”974″>

Now, create a new filesystem downloads on the ZFS pool pool2 with the following command:

$ sudo zfs create pool2/downloads

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-25.png" data-lazy- height="127" src="data:image/svg xml,” width=”974″>

As you can see, the ZFS filesystem downloads set its mountpoint property using the mountpoint property of the ZFS pool pool2 only. So, its mountpoint is set to /pool2/downloads by default:

$ sudo zfs get mounted,canmount,mountpoint pool2/downloads

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-26.png" data-lazy- height="247" src="data:image/svg xml,” width=”974″>

The ZFS filesystem downloads should also be mounted on the /pool2/downloads directory of your computer, as seen from the output of the df command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-27.png" data-lazy- height="389" src="data:image/svg xml,” width=”974″>

If you don’t want the filesystems, you create on the ZFS pool pool2 to use the mountpoint property. You can set the mountpoint property of the ZFS pool pool2 to none. This way, the mountpoint property of the ZFS filesystems on the pool pool2 will also be set to none and will be unmounted by default. You will have to set a mountpoint value for the filesystems you want to mount manually.

You can set the mountpoint property of the ZFS pool pool2 to none as follows:

$ sudo zfs set mountpoint=none pool2

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-28.png" data-lazy- height="112" src="data:image/svg xml,” width=”974″>

The mountpoint property of the ZFS pool pool2 should be set to none, as seen in the screenshot below:

$ sudo zfs get mounted,canmount,mountpoint pool2

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-29.png" data-lazy- height="293" src="data:image/svg xml,” width=”974″>

The mountpoint property of the ZFS filesystem downloads should also be set to none as seen in the screenshot below:

$ sudo zfs get mounted,canmount,mountpoint pool2/downloads

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-30.png" data-lazy- height="289" src="data:image/svg xml,” width=”974″>

Create a new ZFS filesystem videos on the pool pool2 as follows:

$ sudo zfs create pool2/videos

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-31.png" data-lazy- height="114" src="data:image/svg xml,” width=”814″>

The mountpoint of the newly created filesystem videos should also be set to none, as seen in the screenshot below:

$ sudo zfs get mounted,canmount,mountpoint pool2/videos

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-32.png" data-lazy- height="222" src="data:image/svg xml,” width=”974″>

Neither the downloads nor the videos filesystem of the ZFS pool pool2 should be mounted on your computer, as seen from the output of the df command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-33.png" data-lazy- height="356" src="data:image/svg xml,” width=”974″>

To mount the downloads filesystem of the ZFS pool pool2 to /mydownloads directory of your computer, set the mountpoint property of the filesystem as follows:

$ sudo zfs set mountpoint=/mydownloads pool2/downloads

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-34.png" data-lazy- height="83" src="data:image/svg xml,” width=”972″>

In the same manner, to mount the videos filesystem of the ZFS pool pool2 to /myvideos directory of your computer, set the mountpoint property of the filesystem as follows:

$ sudo zfs set mountpoint=/myvideos pool2/videos

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-35.png" data-lazy- height="104" src="data:image/svg xml,” width=”974″>

The mountpoint property of the downloads and videos filesystem of the ZFS pool pool2 should be set to /mydownloads and /myvideos, respectively as seen in the screenshot below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-36.png" data-lazy- height="449" src="data:image/svg xml,” width=”974″>

The downloads and videos filesystems of the ZFS pool pool2 should be mounted on the /mydownloads and /myvideos directory of your computer respectively, as shown from the output of the df command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/mount-zfs-filesystems-in-different-directoris-37.png" data-lazy- height="427" src="data:image/svg xml,” width=”974″>

Conclusion

This article has shown you the effects of setting different values for the canmount, mounted, and mountpoint properties on ZFS pools and filesystems. I have also shown you how to mount ZFS pools and filesystems in different directories than their default ones. In addition, I presented how to disable mounting for the ZFS pools and manually mount filesystems from the mount-disabled ZFS pools.

References

[1] Ubuntu Manpage: zfs — configures ZFS file systems

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/photo2-150×150.png" height="112" src="data:image/svg xml,” width=”112″>

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.