Summary of Steps
Create a large partition to hold the CD Image Files.
Copy the CD to an image file using the dd command.
Mount the CD image file within the directory tree.
Share the directory on the network using Samba, NFS, etc.
Also, make sure you've read Section 1, “Introduction” and Section 1.2, “Things You'll Need”.
Choose (or create) a file system with the largest available disk space on it. Keep in mind that CD-ROM's can hold around 640MB of data, so if you want to share 8 full CD's on your network, you'll need 5.1GB of space available.
Login as root or "su" to root.
bash#
df -hFilesystem Size Used Avail Use% Mounted on /dev/hda5 1.4G 82M 1.3G 6% / /dev/hda1 15M 827k 14M 6% /boot /dev/hda7 2.4G 1008M 1.3G 43% /usr /dev/hda8 23.6G 11.7G 11.7G 50% /home
Here the /home
filesystem has the most available space,
so it is the most suitable filesystem to use for dumping the CD images to.
bash#
cd /homebash#
mkdir imagebash#
cd image
Now, copy the CD to an ISO image. You must know the device name
of your CD-ROM drive (usually /dev/cdrom
,
it could be /dev/scd0
for
SCSI CD-ROM's) I'll use the Mandrake distribution CD-ROM as an Example:
bash#
dd if=/dev/cdrom of=mndrk81.iso
The “if=” is the input file, the “of=” is the output file. You should see a message stating the number of records in and number of records out.
If you see i/o errors, they will most likely be due to the lead-in and lead-out runoutblocks on the CD. If the number of records in and number of records out do not match you may have a problem, otherwise the image will most likely be alright, but you can never know if the errors happened while reading the ISO part of the CD or not (due to dust or scratches on the CD).
Other utilities to read CD's exist, like readcd or sdd.
More information about making 1:1 copies of CD's exists in the [CD-Writing-HOWTO], see Section 1.3, “Suggested Reading and References”.
My thanks to Giblhauser Carl Michael for the runoutblock information.
The next step is to mount the ISO image file. Let's create
a directory under /mnt
to place the mounted file.
bash#
cd /mntbash#
mkdir isobash#
cd isobash#
mkdir mndrk81
Now mount the ISO image file to this newly created directory
bash#
mount -o loop,unhide -t iso9660 -r /home/image/mndrk81.iso /mnt/iso/mndrk81
The “-o loop” means use the option that mounts a file as a block device. The unhide option shows hidden files. The “-t iso9660” means that the file is in the iso9660 CD-ROM format. The “-r” means to mount read-only.
Thanks to Amar Chaouche for pointing out the unhide option for the mount command.
Now you can:
bash#
cd mndrk81bash#
ls -al
You should see a listing (ls) of the files and directories that are on the actual CD (only now they're inside the ISO image file, and that's what you're currently looking at!)
Now that we've manually mounted the image, and made sure it works,
an entry needs to made in the /etc/fstab
file so that the image is
remounted on the next system startup. It's important to make the
entry AFTER the entry for the parent filesystem, e.g.
/home
(I use vim,
but emacs, joe, pico
or jed will work just as well):
bash#
vim /etc/fstab
After the line that looks like the following (or whichever filesystem you've placed your images):
/dev/hda8 /home ext2 defaults 1 2
Insert the following line with your text editor:
/home/image/mndrk81.iso /mnt/iso/mndrk81 iso9660 ro,loop,auto,unhide 0 0
You'll need to have Samba installed and working to perform the next steps (that's outside the scope of this instruction, see Section 1.3, “Suggested Reading and References”). If it's not yet installed, consult your Linux distribution's instructions for installing the Samba package. Or you can visit the Samba website at http://us1.samba.org/samba/samba.html for installation instructions, binaries, and/or the source code.
To share your mounted CD's on a windows network, simply create
a stanza in the /etc/smb.conf
file similar to the following:
[cdimages] comment = All Shared CD Images path = /mnt/iso public = yes writable = no
This will share all the subdirectories under the
/mnt/iso
directory
on the network. To mount the share to a local drive (in this case
the I: drive), bring up an MS-DOS Prompt on the Windows machine and
type the following:
C:\>
net use I: \\yourlinuxmachine\cdimages
Each CD image will now appear as a subdirectory on the I: drive of your Windows machine.
To mount ONLY the Mandrake CD image to a drive letter (we'll use M:,
the root drive of which, will correspond exactly to the CD as if it
was just inserted in the CD-ROM drive), create the following stanza
in the /etc/smb.conf
file.
[mndrk81] comment = Mandrake Linux 8.1 path = /mnt/iso/mndrk81 public = yes writable = no
Then, at your MS-DOS Prompt, mount it with the following command:
C:\>
net use m: \\yourlinuxmachine\mndrk81
The Samba smb.conf file stanzas presented here are simplified, and not secure. Many more options exist for a Samba share which limit who can mount the shares, control how user authentication is performed, and whether the share is even browseable through Network Neighborhood on the Windows machines.
Make sure that NFS is running and configured correctly on
your Linux machine, then add the following to the /etc/exports
file using your own preferred options:
# sample /etc/exports file /mnt/iso (ro,insecure,nohide,all_squash)
The nohide option will allow you to mount a parent directory, without explicitly mounting all exported subdirectories beneath it.
Now try running:
bash#
exportfs -r
This should re-export everything in your /etc/exports
file.
Now, when typing “showmount -e yourlinuxmachine
”
you should see that the /mnt/iso
directory is included in the exports list.