Posts Tagged ‘mount’

Setting up NFS on RHEL

What I’ve recently learned is how to use NFS to share folders between two Red Hat Enterprise Linux 5 machines. They are both on the same network and for simplicity have had firewall disabled (firewall settings were not required in my setup). Below are some tips I used on each of the respective machines in no particular order. Additionally, all steps were performed using the root login.

Machine A (contains file to share)

  1. Make sure NFS service is running. You can do this by typing ps aux | grep nfs in the terminal.
  2. To start the NFS service, type /etc/rc.d/init.d/nfs start or /etc/rc.d/init.d/nfs restart in the terminal.
  3. If you want the NFS service to start automatically at boot up, add /etc/rc.d/init.d/nfs start or /etc/rc.d/init.d/nfs restart to the /etc/rc.d/rc.local file.
  4. Next, we need to specify the share specifics. This involves specifying the folder path, the remote machine (Machine B), and the share permissions. The information goes into /etc/exports. Use the following format: /mnt/shareThisFolder machineBName(ro). After updating the file, make sure to restart the NFS service (#3 above).

Machine B (wants access to remote files)

  1. We need to mount the folder we shared earlier on Machine A. The changes go into /etc/fstab file. We need the remote machine name, remote filepath (should be same as the earlier specified location), local filepath. Use for the following format: machineAName:/mnt/shareThisFolder /mnt/filesFromMachineA nfs rsize=8192, wsize=8192,timeo=14,intr 0 0. After saving the file, type mount -a in the terminal to start the share.

Troubleshooting:

  1. Some issues I kept running into was mount failed XXXXXXXX, reason given by server permission denied. This happened to me because though I had started the NFS service on Machine A, I had failed to specify the folder to share. After adding those details (and restarting the NFS service), I was able to mount from Machine B.
  2. NFS has been working for a few weeks, but has suddenly stopped working. The host computer had been rebooted. The solution is to run the following under the root account in this order:/etc/rc.d/init.d/nfslock restart
    /etc/rc.d/init.d/portmap restart
    /etc/rc.d/init.d/nfs restart

    Make sure none of the operations failed, then try remounting. A more long term solution to this is to insure that nfslock, portmap, and nfs autostart during RHEL bootup. Type /usr/sbin/ntsysv from the terminal and make sure those three are checked!

Installing an Internal Hard Drive on Linux

Mounting an internal hard drive in Linux is not quite as simple as installing a hard drive on a Windows machine. After installing the hard drive, there are only a few steps that I will cover below. First, before this will work, you need to make sure the motherboard recognizes there is a new hard drive. Many of the SATA driven computers require entering the BIOS and Enabling the particular SATA port number.

  1. Run fdisk -l to list all the disk, their capacity, and their space available. There may be many more drives listed than you actual have running, so you will need to identify which drive is new. The best way to do this is to look at the drive capacity. Remember thatt 1024 MB =  1 GB. In the example below, we will assume that /dev/sdb1 is our new drive.
  2. Next,  we add the following command to our fstab file located in the /etc directory. Edit the fstab file with your favorite editor and add /dev/sdb1 /mnt/hd1 ext3 defaults 0 0. Save and Close the file. Not that /mnt/hd1 can be any directory in the machine that you want.
  3. At the prompt, type mount -a to remount all the locations listed in the /etc/fstab file. You can now see a drive called hd1 in the /mnt directory.

Mount USB External Hard Drive to Linux Box

To mount a USB External Hard Drive to a Linux Box, first make sure the unit is plugged in and powered on. Depending on your linux distribution, the hard drive may automatically mount. If this is not the case, mounting the external hard drive is not a very complicated tasks.

To begin, you will need to know where the hard drive is located. In most cases, the location is /dev/sda1 (though this is not always the case). However, if this isn’t the case, you can run the df command into you console. This will return a list of devices where you will most likely be able to find your drive by means of the hard drive max capacity.

Now, assuming the external hard drive is found at /dev/sda1. A great default place to mount the drive is in the /mnt/usbdrive. You will first need to make sure the folder already exists. If the folder does not exist, it can be created by using the command mkdir ‘/mnt/usbdrive‘. Then, use the below command into your terminal:

mount /dev/sda1 /mnt/usbdrive ext3 default 0 0

In the above example, mount is the command, /dev/sda1 is where the hard drive is currently located and /mnt/usbdrive is the folder in which you want the mount the hard drive. The next ext3 is the hard drive file system (Click here for information on Linux File Systems). The next input ‘default’ tells the default settings to be used. The first zero means to back up the file system using the dump utility and the second zero tells the OS whether to process the hard drive if fsck is run.

To have the Linux distribution automatically mount the drive on boot, you will need to add an entry (line) to the /etc/fstab file. In this case, it will be exactly the same as the mount command, except you will not need the mount command:

/dev/sda1 /mnt/usbdrive ext3 default 0 0

Now you have your external that is mounted when the Linux operating system boots up.