Here we have two servers. we are going to attach an additional disk in one server and share the disk to the other server using NFS
server 1 - 172.31.23.64 (NFS server)
server 2 - 172.31.27.183 ( NFS client)
these are private IPs
we are attaching disk in NFS server .
STAGE 1 : ATTACH DISK IN VM AND MOUNT (NFS server)
Login into azure portal ,
- Go to the Azure portal to find the VM. Search for and select Virtual machines.
- Choose the VM from the list.
- In the Virtual machines page, under Settings, choose Disks.
Then attach a new disk,
- On the Disks pane, under Data disks, select Create and attach a new disk.
- Enter a name for your managed disk. Review the default settings, and update the Storage type.
- When you are done, select Save at the top of the page to create the managed disk and update the VM configuration.
Connect to the server via putty,
Once connected to your VM, you need to find the disk,
The output is similar to the following example
Here xvdf is the attached disk.
If you are using an existing disk that contains data, skip to mounting the disk. If you are attaching a new disk, you need to partition the disk.
parted /dev/xvdf --script mklabel gpt mkpart xfspart xfs 0% 100%
Then create a directory and mount the file system,
Use mount to mount the filesystem
mount /dev/xvdf1 /datadrive
Disk is mounted.
To ensure that the drive is remounted automatically after a reboot, it must be added to the /etc/fstab file.
Copy the UUID and save it in /etc/fstab
UUID=18d5b64a-0dfc-4b8d-8b15-a05950570399 /datadrive xfs defaults,nofail 1 2
STAGE 2 : MOUNT NFS FILE SYSTEM
NFS, stands for Network File System, is a server-client protocol used for sharing files between linux/unix to unix/linux systems. NFS enables you to mount a remote share locally. You can then directly access any of the files on that remote share.
I have two server
NFS server - 172.31.23.64 (in this server we already attached a disk)
NFS client - 172.31.27.183
Install and start needed services on both NFS server and client
yum install nfs-utils
systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap
We need to run above commands in both servers.
Login into NFS server,
We want to mount the /datadrive as NFS
chmod 777 /datadrive
Export shared directory on NFS Server:
systemctl restart nfs-server
Then Login into client server, we already enabled and installed all the needed things
Create a directory
Mount the share from server to client as shown below
mount -t nfs 172.31.23.64:/datadrive /backup
To verify ,
You need to add in /etc/fstab files
172.31.23.64:/datadrive /backup/ nfs rw,sync,hard,intr 0 0