Posts Tagged ‘Linux’

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.

How to Get Linux Version, Build, and Distribution

Getting the Linux Version, build, and Distribution is easy. In the example below, I  ran the command on a Dell Optiplex 755 running CentOS 4.6. Just run the command below in a terminal window and the output will display useful information:

cat /proc/version

Linux version 2.6.9-67.0.15.ELsmp (mockbuild@builder10.centos.org) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)) #1 SMP Thu May 8 10:52:19 EDT 2008