How to automatically mount zfs file system on Linux/Unix/FreeBSD

I

have created a zfs file system called data/vm_guests on Ubuntu Linux server. After the server reboot, zpools do not automatically mount at /data/vm_guests. It is failing my KVM guest machines. How can I mount my ZFS (zpool) automatically after the reboot?

 

By default, a ZFS file system is automatically mounted when it is created. Any file system whose mountpoint property is not legacy is managed by ZFS.

List your pools

Type the following command:

# zpool list

 

Sample outputs:

NAME         SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT

data        1.48T   142G  1.35T         –     5%     9%  1.00x  ONLINE  –

nginxwww     131G  40.3G  90.7G         –    22%    30%  1.00x  ONLINE  –

Create zfs file system called data/vm_guests

Type the following command:

# zfs create data/vm_guests

Get mountpoint for data/vm_guests

# zfs get mountpoint data/vm_guests

 

Sample outputs:

Fig.01: Get the mountpoint for the dataset

Is it mounted?

# zfs get mounted data/vm_guests

 

Sample outputs:

Fig.02: Get the mountpoint status of the dataset

If not mounted, mount ZFS file system explicitly

You can explicitly set the mountpoint property for zfs file system on Linux/Unix/FreeBSD as shown in the following example:

# zfs set mountpoint=/YOUR-MOUNT-POINT pool/fs

# zfs set mountpoint=/my_vms data/vm_guests

# cd /my_vms

# df /my_vms

# zfs get mountpoint data/vm_guests

# zfs get mounted data/vm_guests

 

Sample outputs:

Fig.03: Modifying ZFS dataset mountpoints and mount ZFS file system as per needs

 

Please note that you can pass the -a option to zfs command to mount all ZFS managed file systems. For example:

# zfs mount -a

How do I see a list of all zfs mounted file system?

Tyep the following command:

# zfs mount

# zfs mount | grep my_vms

Unmounting ZFS file systems

# zfs unmount data/vm_guests

SEE ALSO

See zfs(8) command man page for more info:

$ man 8 zfs

How to create RAID 10 – Striped Mirror Vdev ZPool On Ubuntu Linux

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *