How To Create Network Drive in Redhat Linux
How To Create Network Drive in Redhat Linux
.91) on which we want to create shared folder, issue following command # vi /etc/exports Add the entry like below /u01/backup 194.126.63.61
194.126.63.61 is the IP Address of the client where you will access this folder
First portion of the entry is which folder you want to share and other is which IP address you want to allow to access this folder. After adding this entry issue following command # /etc/init.d/nfs start On the client where we want to access previously created shared folder First in /mnt folder, create a new folder with the name you want to have as shared folder. Like below # cd /mnt # mkdir backup ( backup is the name you want to have as your share folder) Then issue below command
Mount Drives Under RedHat This document covers how to mount, partition, and format drives. This includes CD-ROM, floppy, and hard drives. Using dmesg To Find Drives Before you can mount drives, you need to know how to reference them. Each device under UNIX is listed under the /dev/ directory. Therefore a tape drive might be /dev/st0, and a SCSI hard drive might be /dev/sda.
You cannot access these directories directly to access your files. Hence why you must mount devices. To see a list of your devices, it's best to call up your kernel boot messages. This can be done using the "dmesg" program. Here is a sample output from typing "dmesg" as root:
hda: Maxtor 91728D8, ATA DISK drive Partition check: hda: hda1 hda2 hda3 hdc: SONY CDU4811, ATAPI CD/DVD-ROM drive Attached scsi tape st0 at scsi0, channel 0, id 5, lun 0
As you can see there's a hard drive under /dev/hda, a CD-ROM drive under /dev/hdc, and a tape drive under /dev/st0. Additionally, the hard drive has multiple partitions (1, 2, and 3). Thus to access each partition we would mount as /dev/hda1, /dev/hda2, or /dev/hda3.
Using the Mount Command The mount command is what allows devices to be tied in to directories. If typed by itself, it will give a listing of how drives are mounted. Here's a brief example:
Mounting a CD-ROM Drive CD-ROM drives that are IDE are labeled as follows in Linux: /dev/hda /dev/hdb /dev/hdc /dev/hdd Primary Master Primary Slave Secondary Master Secondary Slave
If one were to guess, /dev/hdc is usually a good bet for CD-ROM drives in a typical system. Although it's still best to do a dmesg to find out where your CD-ROM drive really is located. To mount a CD-ROM drive that resides under /dev/hdc, we would type the following command:
mkdir /mnt/cdrom
Mounting Hard Drives Mount hard drives often means you will deal with partitions. Partitions are different storage areas on your hard drive. Much like rooms in a house. Partitions are set up by you, or the person/company that set up your hard drive. Sometimes there aren't multiple partitions on a drive. But in the Linux world, this would be extremely rare. Again, we would look for our hard drive in the dmesg log. On most IDE systems, the hard drive is going to be /dev/hda. Next we need a directory to mount to. We might make the following directories: /mnt/hda1 /mnt/hda2 /mnt/hda3 From there we could mount each partition to a directory. Be sure not to mount a drive that's already mounted! Chances are, some, if not all partitions of you Linux system are already mounted! Read Using the Mount Command above.
Advanced - Loopback / Image File Mounts Sometimes entire file systems are stored in one file. This is called an "image." When an image file is mounted, it will appear as an entire hard drive partition. Uses of images vary, but often they are used for embedded systems, or small Linux-on-disk distributions. Mounting an image requires the use of the loopback driver. Generally this is already installed in your kernel. An image file will typically have a .img extension. To use the loopback device, pass the loop option into the mount command. For example, to mount an image file called /root/boot.img onto the directory /mnt/image you would type the following (be sure to make a directory called /mnt/image!):
/home/music
192.168.1.210(rw)
In this example we said to export /home/music only to the machine with IP address 192.168.1.210. The (rw) means allow that machine to both read and write to the directory. Now you need to put these changes into effect by restarting NFS. This can be done by typing the following as root on the server:
/etc/init.d/nfs restart
You also need to set permissions in the file system for NFS to read and write to the directory. On modern Red Hat machines this can be done by typing:
/home/music
192.168.1.15(rw,insecure)
Slow Mounts In Linux: If mounts are taking forever on your Linux machine(s) file locking may be to blame. This can be fixed by passing the nolock option in on the client side. For example: