Here’s a quick tip for anyone who is tinkering with a Solaris box, and it stems from a question I get from folk who are new to Solaris, and that is “How do I mount a CD ROM?”. The short answer is to use the mount command, but there is a little more to it. You need to know what device your CD drive is, and the easiest way to find out if you don’t already know, is to use the iostat command, specifically running it with -En so that the (iostat -En) results look like this:
c0t0d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: ST3120026A Revision: 8.01 Serial No: 4JT0S129
Size: 120.03GB <120034123776 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0
c0t2d0 Soft Errors: 4 Hard Errors: 0 Transport Errors: 0
Vendor: TSSTcorp Product: CDW/DVD TS-H492C Revision: SI00 Serial No:
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 4 Predictive Failure Analysis: 0
From the output you can see that one drive is a hard drive by the line Model: ST3120026A and Size: 120.03GB, and the other drive is the CD ROM then because it says Vendor: TSSTcorp Product: CDW/DVD. There you go, find the one that says it’s a CD ROM and we know the device we need to mount is c0t2d0.
Now we have to decide where to mount the CD ROM to. You can use /mnt like we use for everything else, but for me (this is just my preference), I created a directory called /cdrom and just use it as my normal mount point for my CD ROM. This way, if I have something else mounted to /mnt, which is not uncommon, I don’t have to shift things around. Ultimately, the command I use to mount my CD ROM to /cdrom looks like this:
mount -F hsfs /dev/dsk/c0t2d0s2 /cdrom
See, easy isn’t it? We use our mount command, tell it to use the “hsfs” file system, the device (/dev/dsk/c0t2d0s2) and where to mount it (/cdrom). No fuss, no muss. Now, to unmount it, it would simply be:
umount /cdrom
Even easier! I love it. Here are a couple things to remember, mounting manually will not work correctly if you have the volume manager and automounter running (i.e. vold). I normally turn that off anyway, call me a control freak, but I like to decide when and where stuff gets mounted on my box, besides of you JASS your system, it turns it off for you. Also, in case you didn’t know, you have to be root to mount and unmount disks, but you have sudo installed right? Thought so!
Because I am lazy, another thing I do is put my mount and unmount operations into scripts. You can either link the scripts to something already in your path, or set your path to include your scripts directory where ever they are located. This means that I can pop in a CD, type “mcd” and it gets mounted to /cdrom. When I am done, I can type “umcd” and it gets unmounted and ejected. I love simple, simple is good.
For your benefit, I will include source of the scripts below. They are quite simple, but some people reading this might be just starting out and it could be helpful. Let’s start with mcd:
#!/bin/bash mount -F hsfs /dev/dsk/c0t2d0s2 /cdrom
and now, umcd:
#!/bin/bash umount /cdrom eject /dev/dsk/c0t2d0s2
The only thing you need to do to use these yourself, is change the device to whatever your CD ROM is on your machine. Now, go mount and unmount till you can’t stand it anymore!





