Enable mount in Linux
Error: RPC Mount export: RPC: unable to receive; errno = No route to host
First, enable the Portmap service.
Service Portmap start
Iptables-A input-p tcp -- dport 111-M state -- state new-J accept
Iptables-A input-p udp -- dport 111-M state -- state new-J accept
Edit # vi/etc/sysconfig/nfs
Mountd_port = "4002"
Statd_port = "4003"
Lockd_tcpports = "4004"
Lockd_udpport = "4004"
Service NFS start
Iptables-A input-p tcp -- dport 2049-M state -- state new-J accept
Iptables-A input-p udp -- dport 2049-M state -- state new-J accept
Iptables-A input-p tcp -- dport 4002: 4004-M state -- state new-J accept
Iptables-A input-p udp -- dport 4004-M sate -- state new-J accept
Process:
I. server-side settings
Server-side settings are all set in the/etc/exports file. The format is as follows:
Directory host name 1 or IP1 (parameter 1, parameter 2) host name 2 or ip2 (parameter 3, parameter 4)
The above format indicates that the same directory is shared to two different hosts, but the permissions and parameters provided to the two hosts are different. Therefore, the permissions obtained by the two hosts are set separately.
You can set the following parameters:
RW: read/write permission;
RO: Read-Only permission;
No_root_squash: if the user logging on to the NFS host is a root user, the user has the root permission. this parameter is insecure and is not recommended.
Root_squash: log on to NFS
Nobody identity;
All_squash: No matter what users log on to the NFS host, they will be reset to nobody.
Anonuid: sets all users logging on to the NFS host to the specified user ID, which must exist in/etc/passwd.
Anongid: Same as anonuid, but changed to group ID!
Sync: data is synchronized to the storage.
Async: The data is temporarily stored in the memory and not directly written to the hard disk.
Insecure allows unauthorized access from this machine.
For example, you can edit/etc/exports as follows:
/Tmp * (RW, no_root_squash)
/Home/Public 192.168.0. * (RW) * (RO)
/Home/test 192.168.0.100 (RW)
/Home/Linux * .the9.com (RW, all_squash, anonuid = 40, anongid = 40)
After setting, run the following command to start NFS:
/Etc/rc. d/init. d/Portmap start (Portmap is started by default in RedHat)
/Etc/rc. d/init. d/nfs start
Exportfs command:
If we modify/etc/exports after starting NFS, do we have to restart NFS? At this time, we can use the exportfs command to make the change take effect immediately. The command format is as follows:
Exportfs [-aruv]
-A: All content in Mount or unmount/etc/exports
-R: Re-mount the directory shared in/etc/exports
-U: umount directory
-V: when the export is used, the detailed information is output to the screen.
Example:
[Root @ test root] # exportfs-RV <= All are re-export once!
Exporting 192.168.0.100:/home/test
Exporting 192.168.0. *:/home/Public
Exporting * .the9.com:/home/Linux
Exporting *:/home/Public
Exporting *:/tmp
Reexporting 192.168.0.100:/home/test to Kernel
Exportfs-au <= All are uninstalled.
Customer segment operation: You need to enable (Portmap + nfslock)
1. The showmout command is helpful for NFS operations and troubleshooting. Let's take a look at the usage of showmount.
Showmout
-A: this parameter is generally used on the NFS server and is used to display the Cline machine that has mounted the local NFS directory.
-E: displays the export directory on the specified NFS server.
For example:
Showmount-e 192.168.0.30
Export list for localhost:
/Tmp *
/Home/Linux * .linux.org
/Home/Public (everyone)
/Home/test 192.168.0.100
2. Mount the NFS directory:
Mount-t nfs hostname (orip):/directory/Mount/Point
Example:
Linux: Mount-t nfs 192.168.0.1:/tmp/mnt/nfs
Solaris: Mount-f nfs 192.168.0.1:/tmp/mnt/nfs
BSD: Mount 192.168.0.1:/tmp/mnt/nfs
This article is from the "seven" blog, please be sure to keep this source http://liuyu.blog.51cto.com/183345/272466
Enable mount in Linux