Methods to Percentage ZFS Filesystems with NFS

0 1

You’ll proportion your ZFS swimming pools and filesystems the usage of the NFS (Community Report Gadget) file-sharing protocol and get admission to them from far flung computer systems very simply.

On this article, I’m going to turn you easy methods to proportion ZFS swimming pools and filesystems the usage of the NFS dossier sharing carrier and get admission to them from far flung computer systems. So, let’s get began.

Desk of Contents

  1. Community Diagram
  2. Putting in NFS Server
  3. Putting in NFS Consumer
  4. Developing ZFS Swimming pools and Filesystems
  5. Sharing ZFS Swimming pools with NFS
  6. Sharing ZFS Filesystems with NFS
  7. Mounting NFS Shared ZFS Swimming pools and Filesystems
  8. Mechanically Mounting NFS Shared ZFS Swimming pools and Filesystems
  9. Permit Writes to the NFS Shared ZFS Swimming pools and Filesystems
  10. Unsharing ZFS Swimming pools and Filesystems
  11. Conclusion
  12. References

Community Diagram

On this article, I can configure an Ubuntu 20.04 LTS laptop (Hostname: linuxhint, IP: 192.168.122.98) as an NFS server and configure an Ubuntu 20.04 LTS laptop (Hostname: nfs-client, IP: 192.168.122.203) as an NFS Jstomer. Either one of those computer systems are within the subnet 192.168.122.0/24. I can configure the NFS server in some way that most effective computer systems/servers on this subnet will be capable of get admission to the NFS server.

Determine 1: NFS server and Jstomer hooked up to the community subnet 192.168.122.0/24

Putting in NFS Server

You will have to have the NFS server package deal put in at the laptop from the place you need to proportion your ZFS swimming pools/filesystems by the use of NFS.

In the event you’re the usage of Debian 10 or Ubuntu 20.04 LTS, you’ll set up the NFS server package deal in your laptop as follows:

$ sudo apt set up nfs-kernel-server -y

As soon as the NFS server package deal is put in, the nfs-server systemd carrier must be lively.

$ sudo systemctl standing nfs-server.carrier

In the event you’re the usage of CentOS 8/RHEL 8, learn the object Methods to Configure NFS Server on CentOS 8 for help on putting in NFS server in your laptop.

Putting in NFS Consumer

You will have to have the NFS Jstomer package deal put in at the laptop from the place you’re going to be getting access to your ZFS swimming pools/filesystems by the use of NFS.

In the event you’re the usage of Debian 10 or Ubuntu 20.04 LTS, you’ll run the next command to put in the NFS Jstomer package deal in your laptop:

$ sudo apt set up nfs-common -y

Developing ZFS Swimming pools and Filesystems

On this segment, I’m going to create a ZFS pool pool1 the usage of the garage units vdb and vdc in replicate configuration.

To create a brand new ZFS pool pool1 the usage of the garage units vdb and vdc in replicate configuration, run the next command:

$ sudo zpool create -f pool1 replicate vdb vdc

A brand new ZFS pool pool1 must be created and the ZFS pool pool1 must be mechanically fastened within the /pool1 listing.

Create a ZFS filesystem fs1 within the ZFS pool pool1 as follows:

$ sudo zfs create pool1/fs1

A brand new ZFS filesystem fs1 must be created and mechanically fastened within the /pool1/fs1 listing.

Sharing ZFS Swimming pools with NFS

To proportion the ZFS pool pool1 by the use of NFS, you need to set the sharenfs belongings of your ZFS pool accordingly.

To permit everybody at the community learn/write get admission to to the ZFS pool pool1, you’ll set the sharenfs belongings of the ZFS pool pool1 as follows:

$ sudo zfs set sharenfs=”rw” pool1

Or,

$ sudo zfs set sharenfs=”rw=*” pool1

To permit each and every laptop/server at the community subnet 192.168.122.0/24 learn/write get admission to to the ZFS pool pool1 most effective, you’ll set the sharenfs belongings of the ZFS pool pool1 as follows:

$ sudo zfs set sharenfs=”[email protected]/24″ pool1

To permit most effective the pc with the IP cope with 192.168.122.203 learn/write get admission to to the ZFS pool pool1, you’ll set the sharenfs belongings of the ZFS pool pool1 as follows:

$ sudo zfs set sharenfs=”rw=192.168.122.203″ pool1

You’ll use the colon (:) image to permit get admission to to the ZFS pool pool1 from more than one community subnets or IP addresses as neatly.

As an example, to permit the community subnets 192.168.122.0/24 and 192.168.132.0/24 learn/write get admission to to the ZFS pool pool1, you’ll set the sharenfs belongings of the ZFS pool pool1 as follows:

$ sudo zfs set sharenfs=”[email protected]/24:@192.168.132.0/24″ pool1

In the similar method, to permit most effective the computer systems with the IP addresses 192.168.122.203 and 192.168.122.233 learn/write get admission to to the ZFS pool pool1, you’ll set the sharenfs belongings of the ZFS pool pool1 as follows:

$ sudo zfs set sharenfs=”rw=192.168.122.203: 192.168.122.233″ pool1

You’ll check whether or not the sharenfs belongings is as it should be set at the ZFS pool pool1 as follows:

$ sudo zfs get sharenfs pool1

Sharing ZFS Filesystems with NFS

To proportion the ZFS filesystem fs1 by the use of NFS, you need to set the sharenfs belongings of the ZFS filesystem accordingly.

To permit everybody at the community learn/write get admission to to the ZFS filesystem fs1, you’ll set the sharenfs belongings of the ZFS filesystem fs1 as follows:

$ sudo zfs set sharenfs=”rw” pool1/fs1

Or,

$ sudo zfs set sharenfs=”rw=*” pool1/fs1

To permit each and every laptop/server at the community subnet 192.168.122.0/24 learn/write get admission to to the ZFS filesystem pool1/fs1, you’ll set the sharenfs belongings of the ZFS filesystem pool1/fs1 as follows:

$ sudo zfs set sharenfs=”[email protected]/24″ pool1/fs1

To permit most effective the pc with the IP cope with 192.168.122.203 learn/write get admission to to the ZFS filesystem pool1/fs1, you’ll set the sharenfs belongings of the ZFS filesystem pool1/fs1 as follows:

$ sudo zfs set sharenfs=”rw=192.168.122.203″ pool1/fs1

You’ll use the colon (:) image to permit get admission to to the ZFS filesystem fs1 from more than one community subnets or IP addresses as neatly.

As an example, to permit the community subnets 192.168.122.0/24 and 192.168.132.0/24 learn/write get admission to to the ZFS filesystem pool1/fs1, you’ll set the sharenfs belongings of the ZFS filesystem pool1/fs1 as follows:

$ sudo zfs set sharenfs=”[email protected]/24:@192.168.132.0/24″ pool1/fs1

In the similar method, to permit most effective the computer systems with the IP addresses 192.168.122.203 and 192.168.122.233 learn/write get admission to to the ZFS filesystem pool1/fs1, you’ll set the sharenfs belongings of the ZFS filesystem pool1/fs1 as follows:

$ sudo zfs set sharenfs=”rw=192.168.122.203: 192.168.122.233″ pool1/fs1

You’ll check whether or not the sharenfs belongings is as it should be set at the ZFS filesystem pool1/fs1 as follows:

$ sudo zfs get sharenfs pool1/fs1

Mounting NFS Shared ZFS Swimming pools and Filesystems

To mount the ZFS swimming pools and filesystems that you simply’ve shared by the use of NFS in your laptop (NFS Jstomer), you wish to have to understand the IP cope with of your NFS server.

You’ll run the `hostname -I` command in your NFS server to seek out the IP cope with of your NFS server. In my case, the IP cope with is 192.168.122.98.

As soon as you recognize the IP cope with of the NFS server, you’ll listing all of the to be had NFS stocks out of your laptop as follows:

$ showmount -e 192.168.122.98

As you’ll see, the ZFS pool pool1 and the ZFS filesystem fs1 are indexed as NFS stocks /pool1 and /pool1/fs1 respectively.

Create a listing /mnt/pool1 for mounting the NFS proportion /pool1 (ZFS pool pool1) as follows:

$ sudo mkdir -v /mnt/pool1

You’ll mount the NFS proportion /pool1 (ZFS pool pool1) from the NFS server 192.168.122.98 at the /mnt/pool1 listing of your laptop (NFS Jstomer) as follows:

$ sudo mount -t nfs 192.168.122.98:/pool1 /mnt/pool1

The NFS proportion /pool1 must be fastened at the /mnt/pool1 listing of your laptop (NFS Jstomer).

In the similar method, create a brand new listing /mnt/fs1 for mounting the NFS proportion /pool1/fs1 (ZFS filesystem fs1) as follows:

Mount the NFS proportion /pool1/fs1 (ZFS filesystem fs1) from the NFS server 192.168.122.98 at the /mnt/fs1 listing of your laptop (NFS Jstomer) as follows:

$ sudo mount -t nfs 192.168.122.98:/pool1/fs1 /mnt/fs1

The NFS proportion /pool1/fs1 (ZFS filesystem fs1) must be fastened at the /mnt/fs1 listing of your laptop (NFS Jstomer).

Mechanically Mounting NFS Shared ZFS Swimming pools and Filesystems

You’ll mount the NFS stocks /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) in your laptop (NFS Jstomer) mechanically at boot time.

To try this, open the /and so forth/fstab dossier with the nano textual content editor as follows:

Upload the next strains on the finish of the /and so forth/fstab dossier.

# Mount NFS stocks
192.168.122.98:/pool1                       /mnt/pool1      nfs       defaults          0          0
192.168.122.98:/pool1/fs1     /mnt/fs1          nfs       defaults          0          0

If you’re completed, press + X adopted through Y and to save lots of the /and so forth/fstab dossier.

For the adjustments to take impact, restart your laptop (NFS Jstomer) as follows:

The following time your laptop (NFS Jstomer) boots, the NFS stocks /pool1 (ZFS pool pool1)and /pool1/fs1 (ZFS filesystem fs1) must be fastened within the /mnt/pool1 and /mnt/fs1 directories respectively.

Permit Writes to the NFS Shared ZFS Swimming pools and Filesystems

In the event you attempt to write to the NFS stocks /pool1 (ZFS pool pool1) or /pool1/fs1 (ZFS filesystem fs1) out of your laptop (NFS Jstomer) at this time, you’re going to get the Permission denied message as proven within the screenshot under.

To unravel this drawback, you’ll do one of the most following:

  1. Set 0777 permission at the /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) listing of the NFS server in order that everybody can write to the ZFS pool pool1 and filesystem fs1. This system has large safety dangers. So, I don’t counsel it until you’re the usage of it for trying out functions.
  2. Create a gaggle nfs-users (let’s say) at the NFS server and at the NFS Jstomer computer systems from which you need to jot down for your NFS stocks. Then, alternate the gang of the /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) directories of the NFS server to nfs-users. Additionally, set staff write permissions (0775) for the directories /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) directories of the NFS server. This manner, you’ll create new customers at the NFS Jstomer computer systems, set nfs-users as their number one staff, they usually must be capable of write to the NFS stocks with none issues.

NOTE: NFS maps the UID (Consumer ID) and GID (Staff ID) of the NFS Jstomer computer systems with the UID and GID of the NFS server. So, if a person/staff can write to an NFS proportion at the NFS server, then the similar person/staff with the similar UID/GID must additionally be capable of write to that NFS proportion from the NFS Jstomer laptop.

On this segment, I’m going to turn you easy methods to arrange the essential customers and teams at the NFS server and Jstomer computer systems with the intention to write to the NFS stocks.

At the NFS server, create a brand new staff nfs-users and set the GID (Staff ID) of the nfs-users staff to 2000 as follows:

$ sudo groupadd –gid 2000 nfs-users

At the NFS Jstomer computer systems, create a brand new staff nfs-users and set the GID (Staff ID) of the nfs-users staff to 2000 as neatly.

$ sudo groupadd –gid 2000 nfs-users

At the NFS server, alternate the gang of the /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) directories to nfs-users as follows:

$ sudo chgrp -Rfv nfs-users /pool1

Permit staff learn and write permissions for the /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) directories as follows:

$ sudo chmod -Rfv 0775 /pool1

The crowd of the /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) directories must be modified to nfs-users and staff learn/write permissions must be set as neatly.

$ ls -lhd /pool1
$ ls -lhd /pool1/fs1

For the adjustments to take impact, reboot the NFS server as follows:

Now, you need to create the essential person accounts in your NFS Jstomer computer systems with the intention to write to the NFS stocks.

Create a brand new person alex (let’s say) with the UID 5001 (in order that they don’t intrude with the customers already to be had within the NFS server) and set the main staff of the person to nfs-users as follows:

$ sudo useradd -m -s /bin/bash -u 5001 -g nfs-users alex

A brand new person alex with the UID 5001 and number one staff nfs-users (GID 2000) must be created at the NFS Jstomer laptop.

Now, restart the NFS Jstomer laptop for the adjustments to take impact.

As soon as the NFS Jstomer laptop boots, the NFS stocks /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) must be fastened.

The NFS stocks /pool1 (ZFS pool pool1) and /pool1/fs1 (ZFS filesystem fs1) must even have the right kind listing permissions.

$ ls -lhd /mnt/pool1
$ ls -lhd /mnt/fs1

Now, log in because the person alex at the NFS Jstomer laptop as follows:

The person alex must be capable of create information at the NFS proportion /pool1 (ZFS pool pool1) and get admission to them as you’ll see within the screenshot under.

$ echo ‘[pool1] Hi global’ > /mnt/pool1/hi.txt
$ ls -lh /mnt/pool1
$ cat /mnt/pool1/hi.txt

The person alex must additionally be capable of create information at the NFS proportion /pool1/fs1 (ZFS filesystem fs1) and get admission to them as you’ll see within the screenshot under.

$ echo ‘[fs1] Hi global’ > /mnt/fs1/hi.txt
$ ls -lh /mnt/fs1
$ cat /mnt/fs1/hi.txt

At the NFS server, the UID (Consumer ID) of the information that the person alex comprised of the NFS Jstomer laptop must be 5001 and the gang must be nfs-users as you’ll see within the screenshot under.

$ ls -lh /pool1
$ ls -lh /pool1/fs1

If you wish to get to the bottom of the UIDs to usernames in your NFS server, you will have to create the similar person with the similar UID (as you may have created at the NFS Jstomer laptop) at the NFS server.

For a small collection of customers, you’ll run the similar useradd command on each the NFS server and Jstomer computer systems to unravel this drawback. If you need to set up numerous customers, then it’ll be a large number of paintings to do that manually. As a substitute, you can use NIS (Community Knowledge Server) or LDAP (Light-weight Listing Get admission to Protocol) to mechanically sync the customers between your NFS server and NFS Jstomer computer systems.

For help on configuring NIS in your NFS server and Jstomer computer systems, take a look at the next articles:

For help on configuring LDAP in your NFS server and Jstomer computer systems, take a look at the next articles:

Unsharing ZFS Swimming pools and Filesystems

If you wish to prevent sharing the ZFS pool pool1 you’ll have to set the sharenfs belongings of the ZFS pool pool1 to off as follows:

$ sudo zfs set sharenfs=off pool1

NFS sharing must be disabled for the ZFS pool pool1 as you’ll see within the screenshot under.

$ sudo zfs get sharenfs pool1

In the similar method, you’ll prevent sharing the ZFS filesystem fs1 through atmosphere the sharenfs belongings of the ZFS filesystem fs1 to off as follows:

$ sudo zfs set sharenfs=off pool1/fs1

NFS sharing must be disabled for the ZFS filesystem fs1 as you’ll see within the screenshot under.

$ sudo zfs get sharenfs pool1/fs1

Conclusion

On this article, I’ve proven you easy methods to proportion ZFS swimming pools and filesystems and get admission to them remotely the usage of the NFS file-sharing protocol. I’ve additionally proven you easy methods to mechanically mount ZFS swimming pools/filesystems that you simply’ve shared with NFS on NFS Jstomer computer systems at boot time. I’ve proven you easy methods to set up get admission to permissions for the NFS stocks and make allowance write get admission to to the NFS stocks from the NFS Jstomer computer systems as neatly.

References

[1] Ubuntu Manpage: zfs – configures ZFS dossier techniques
[2] Sharing and Unsharing ZFS Report Methods – Oracle Solaris Management: ZFS Report Methods
[3] Synopsis – guy pages segment 1M: Gadget Management Instructions
[4] nfssec Manpage segment 5 – Oracle Solaris Documentation
[5] centos – NFS default to 777 – Server Fault
[6] Bankruptcy 4. Exporting NFS stocks Pink Hat Endeavor Linux 8 | Pink Hat Buyer Portal

Leave A Reply

Your email address will not be published.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.