Novell Home

NFS Saves the Day

Novell Cool Solutions: Feature
By Scott M. Morris

Digg This - Slashdot This

Posted: 26 Jan 2005
 

A few weeks ago, I wrote an article about creating and mounting CD images. This helped us eliminate the need for constantly inserting and removing our CDs all the time to install software. Well, what if I have a whole network of SUSE machines? Is there a way to apply this concept to an entire network? It would save a lot of time to set up one machine to share its imaged install discs with all the others on the network. So, let's take a look at how to do this.

Overview

Let's begin by reviewing the steps that we are going to take to set this up. First, we will need to make the disc images. Then, we'll mount the images. Third, I'll share a script with you that can mount them automatically. Next, we need to set the machine up to be an NFS server. Also, we'll see how to set up the other machines on the network to use these mounted, shared images. Finally, on the network client machines, we'll set up YAST to use these images as software installation sources.

Make Disc Images

So, the first step is to make disc images out of the installation discs. I would recommend doing this on a server. I have a SUSE Linux Enterprise Server machine that I'm going to use to make SUSE 9.2 Professional disc images. So hop on your server and pop open a terminal window. We're going to make a folder where these images will live. Make a directory called /isos:

linux:/ # mkdir /isos

Once you have created your folder, put the first disc in the CD drive. For my example, this will be SUSE 9.2 Professional Disc 1. Then, run this command, where /dev/cdrom is your CD-ROM:

linux:/ # dd if=/dev/cdrom of=/isos/suse1.iso

That will take a good while. When done, rip the rest of the CDs. If you are making SUSE 9.2 Professional disc images, you will have 5 CDs. If you are making discs for Novell Linux Desktop or SUSE Linux Enterprise Server, you may have 4. However many discs you have, your output will look something like this:

linux:/ # dd if=/dev/cdrom of=/isos/suse1.iso
1329044+0 records in
1329044+0 records out
linux:/ # eject /dev/cdrom
linux:/ # dd if=/dev/cdrom of=/isos/suse2.iso
1328528+0 records in
1328528+0 records out
linux:/ # eject /dev/cdrom
linux:/ # dd if=/dev/cdrom of=/isos/suse3.iso
1332328+0 records in
1332328+0 records out
linux:/ # eject /dev/cdrom
linux:/ # dd if=/dev/cdrom of=/isos/suse4.iso
1326644+0 records in
1326644+0 records out
linux:/ # eject /dev/cdrom
linux:/ # dd if=/dev/cdrom of=/isos/suse5.iso
1323516+0 records in
1323516+0 records out
linux:/ # eject /dev/cdrom
linux:/ #

Mount the Images

Okay, so now we have our images. Let's mount those babies. Make a folder called /suse. Then, we'll make a subdirectory for each image. These subdirectories are going to be the folders to which we mount the disc images:

linux:/ # mkdir /suse
linux:/ # mkdir /suse/1
linux:/ # mkdir /suse/2
linux:/ # mkdir /suse/3
linux:/ # mkdir /suse/4
linux:/ # mkdir /suse/5
linux:/ #

Keep in mind that you may have to switch to the 'su' user to do this.

Now that the folders are created, let's mount the images. Switch to 'su' and run the 'mount' command as in this example:

[2309][user@linux:~]$ su
Password:
linux:/ # mount -o loop -t iso9660 /isos/suse1.iso /suse/1

Run this command for each successive image, changing the filename and target mount directory accordingly:

[2309][user@linux:~]$ su
Password:
linux:/ # mount -o loop -t iso9660 /isos/suse1.iso /suse/1
linux:/ # mount -o loop -t iso9660 /isos/suse2.iso /suse/2
linux:/ # mount -o loop -t iso9660 /isos/suse3.iso /suse/3
linux:/ # mount -o loop -t iso9660 /isos/suse4.iso /suse/4
linux:/ # mount -o loop -t iso9660 /isos/suse5.iso /suse/5
linux:/ #

Great, the discs are ripped and mounted. Now, we need a script to automate mounting the images. Copy and paste the following into a file called mntimg.sh. You may want to put it in /isos with the disc images:

#!/bin/bash
mount -o loop -t iso9660 /isos/suse1.iso /suse/1
mount -o loop -t iso9660 /isos/suse2.iso /suse/2
mount -o loop -t iso9660 /isos/suse3.iso /suse/3
mount -o loop -t iso9660 /isos/suse4.iso /suse/4
mount -o loop -t iso9660 /isos/suse5.iso /suse/5

Save that script and make it executable, as in this example:

[2313][user@linux:~]$ chmod +x mntimg.sh

Now, next time you reboot the server and need to mount the images again, you just run that script as root.

Configure NFS Server

Okay, sweet. So on our server, we have made and mounted the images. Let's set up the NFS Server so we can share them with the rest of the network.

To do this, fire up YAST. From the options at the left, select NETWORK SERVICES. Then, from the options on the right, select NFS SERVER:

Another window appears, called "Configuration of the NFS server." In this window, we select the "Start NFS server" radio button, and click NEXT:

Another page comes up, called "Directories to export to the others." This is where we tell the NFS Server what to export, or share, with the rest of the network:

Now, click on the ADD DIRECTORY button. A small window asking which directory to export appears. Type the location to which the first image is mounted. This is /suse/1:

Click OK. Another window comes up. I leave the defaults and click OK:

The directory and host appear in the "Directories to export to the others" window:

Alrighty, so add the rest of the directories /suse/2 through /suse/5 the same way. When finished, your window should look something like this:

Click FINISH. YAST saves the configuration and starts up the server. You are now back to the original YAST screen, which you can close.

Excellent! We've ripped the CDs, mounted them, and exported them through NFS. This makes them available to the other computers on the network. Now, we have to run through how to connect these other computers to our server. This will allow these other machines to see these images. Then, we won't have to switch CDs every time we want to install software. That will be very nice.

Set Up Clients

Alright, hop on one of the other machines on the network. First, we need to create some mount points. This is basically where we want the folders to show up that we are going to share from the server. So, pull up a terminal window. Then, create folders where we want to mount the images from the server:

linux:/ # mkdir /suse
linux:/ # mkdir /suse/1
linux:/ # mkdir /suse/2
linux:/ # mkdir /suse/3
linux:/ # mkdir /suse/4
linux:/ # mkdir /suse/5
linux:/ #

That's pretty simple. So, we have the shared folder on the server, and a place for it to live on our client machine. Now, let's make the connection, and mount the folders from the server to our mount points.

Run YAST. From the options on the left, select NETWORK SERVICES. When the options on the right come up, select NFS CLIENT:

A window appears called "Configuration of the NFS client." Click ADD:

Another window comes up asking us what to add and where to put it:

In the box called "Host name of the NFS server", it's just asking for the IP address of the server where the images live. Put in the server's IP address there.

Quick Note: If you're unsure how to get the server's IP address, go to the server, open a command prompt, and type '/sbin/ifconfig' and press ENTER. It will probably be an IP address of the 192.168.x.x or 10.x.x.x variety.

My server's IP address is 192.168.0.1, so that's what I'm going to put in there.

Now we need to put something in the 'Remote filesystem' box. To do this, click on the SELECT button. A list of directories exported by the server appears:

Select '/suse/1' and click OK. That name now appears in the "Remote filesystem" box.

In the 'Mountpoint (local):' box, type in /suse/1. So, your window should look like this, now:

When you've got all these fields filled in, click OK. The server, its folder, and the local mountpoint appear for the first disc:

Go through and add the rest of them. When you're done, it should look like this:

When it does, click FINISH. YAST writes the configuration, starts up the NFS Client, and takes us back to the original YAST window. Leave this window open.

Configure Installation Sources

Great! We are almost done. Now, we have to add these installation sources to YAST so we can install software from them. This is very simple. From the options on the left of the YAST window, click SOFTWARE. From the options on the right, click on CHANGE SOURCE OF INSTALLATION:

Another window will appear, called "Software Source Media." In this window, select the first option, and then click the ENABLE OR DISABLE button. This will change the STATUS column to OFF:

Now, click on the ADD drop-down box. Select LOCAL DIRECTORY. It will pop open another small window. We need to tell it where the first folder is located. Since we have mounted it from a remote machine to a local directory with NFS, we can put in the local directory. This, of course is /suse/1. Type this in and click OK:

Your first folder will appear in the list. Do this for all the remaining folders, /suse/2 through /suse/5. If a warning appears, it is safe to click "Continue." When you are done, your window should look a lot like this:"

When you're done adding all the folders, click FINISH. YAST now knows to look at the locally mounted folders from the server.

Test Setup

Okay, let's test out our setup. If it isn't already open, run YAST now. Select SOFTWARE from the left, and INSTALL AND REMOVE software from the right:

It pops open up another window. From the FILTER drop-down box, select PACKAGE GROUPS. Now, we need to install a program that isn't already installed. For this example, let's install Maelstrom (it could be anything you want, though). Check the box next to the program:

To finish, click the "Accept" button in the lower right corner of the window. If YAST installs the program properly, it will not prompt you for any install CDs. It will install the program and then quit.

You are now able to run through these last three sections (Set Up Clients, Configure Installation Sources, and Test Setup) on each of the client machines on your network. This will enable you to use the one set of images on your server to install all the software on the network client machines. That is pretty slick.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell