Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configure NFS service under Ubuntu

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Configure nfs server

The steps to install and configure the nfs service under ubuntu are as follows:

1. Install nfs

Ubuntu does not have an nfs server installed by default, so we first install the nfs server side:

$sudo apt-get install nfs-kernel-server

Some documentation suggests that apt-get is also needed to manually install nfs client nfs-common and portmap, but this is unnecessary because apt will install them for us automatically when installing nfs-kernel-server.

/etc/exports

The directories and permissions that nfs allows to mount are defined in the file/etc/exports.

For example, if we want to share the rootfs directory under the root directory, we need to add the following line to the end of the/etc/exports file:

/rootfs *(rw,sync,no_root_squash)

where: /rootfs is the directory to share,

* Represents allowing access to all network segments,

rw is read-write permission,sync is synchronous writing of data to memory and hard disk,

no_root_squash is the permissions of the user of the nfs client share directory. If the client is using root, then the client has root privileges for the share directory.

3. Restart service

$sudo /etc/init.d/portmap restart

$sudo /etc/init.d/nfs-kernel-server restart

4. Test nfs

You can run the following command to display the shared directory:

$showmount -e

Or you can mount it on your local disk using the following command, for example,/rootfs under/mnt:

$sudo mount -t nfs localhost:/rootfs /mnt

You can run df to see if the mount is successful. After viewing, you can uninstall it using the following command:

$ sudo umount /mnt

------------------------------------------------

About NFS Configuration Errors

ubuntu test native nfs error: mount.nfs:access denied by server while mounting...

I believe there should be some people who make this mistake. It doesn't matter. I'll help you fix it later.

First run sudo vim /etc/exports

Add after its text

/home/work 192.168.1.*(rw,sync,no_root_squash)

Then save the exit.

Note that the host IP above may not be wildcard with *, otherwise access will be denied on the client, but what if we want to set up local area network access? What to do, use subnet mask for example: 10.1.60.0/255.255.254.0 to make 10.1.60.* and 10.1.61.* You can also use the 10.1.60/23 method to determine subnets.

/home/work means shared directory, of course, you can change it to your favorite directory, 192.168.1.*, The first three digits are the ip address of your host. The ifconfig command will do.)

rw: read/write permission, the parameter of read-only permission is ro;

sync: data is written to memory and hard disk synchronously, or async can be used, in which case the data is temporarily stored in memory instead of being written to hard disk immediately.

no_root_squash: Attribute of the NFS server shared directory user, if the user is root, then the shared directory has root privileges.

Then execute the following command:

Start port mapping: #sudo

/etc/rc.d/init.d/portmap start (if not found, execute #sudo /etc/init.d/portmap start)

If this step is unsuccessful, the connection will eventually fail.

Start NFS service: #sudo /etc/rc.d/init.d/nfs start (can't find it again, execute #sudo)

/etc/init.d/nfs start or #sudo /etc/init.d/nfs-kernel-server start)

These two were successfully implemented.

Then it will show [OK].

Last execution: #sudo mount -t nfs www.example.com/mnt 192.168.1.101:/home/work

192.168.1.101 is the IP address of your own host. You can also use 127.0.0.1 instead of your own host IP address. You can also connect to it./ Home/work is the path you just added to etc/exports.

If something goes wrong again at this step, re-#sudo vim /etc/exports and change " 192.168.1.* "*" instead of "*," just this one star!

Execution: # ls /mnt

Congratulations, do you have the content in/home/work under mnt?

Uninstall: #sudo mount/mnt/

If the above operation is done, or not, I think you should restart the machine to try it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report