Thursday, March 15, 2007

Volume Management of a Floppy Disk in Solaris

In Windows, you pop a floppy in the drive and just use it. Sometimes you do a quick format and maybe once or twice in a lifetime you do a long format. And besides all that, who still uses floppies anyway? Well, that doesn't matter for now. It's the principle that we care about. So onward...

Insert the floppy into the drive (make sure you set the tab on it to be writable). Then run through the following:

First, you need to mount the floppy
# volcheck

Then you need to see if the system see's the floppy
# cd /floppy/floppy0

If all goes well, you should see something like "unnamed". That's because you have a dos formatted 1.44" floppy disk that has the name "unnamed". Check it to see if anything is on it.
# ls -l /floppy/unnamed

If you see some contents there, then everything is working so far. Now you might want to format the disk. First you have to unmount it.
# eject floppy

This might seem kinda weird to Windows users. When we think of "eject" we think of the floppy physically leaving the machine and therefore wouldn't be readable. But in Solaris, eject simply means to remove the file system from the device. More about that later. But for now, let's format it.
# fdformat -b MyDisk -t dos /vol/dev/rdiskette0/nomedia

So essentially I am saying to create a new dos (pcfs) file system on this disk (fdformat -t dos). It will wipe out any data that is already there. I am also telling it to give it the name "MyDisk". We choose the raw device to format and on we go. After you run the above command and hit enter, then enter again to accept, it should finish.

The vold daemon runs around making this all happen. So if this process is corrupt or something, then you might need to reboot. But if it's working, then you can stop and start volmgt. This isn't necessary,.. I am just saying to do it for good measure.
# /etc/init.d/volmgt stop
# /etc/init.d/volmgt start

Now to remount that floppy
# volcheck

Now let's see if our format worked.
# cd /floppy

Is anything there? You should see the "mydisk" item there now. If so, check it's contents. There should be no contents in it. Try creating some files in it.
# cd /floppy/mydisk
# touch file1 file2 file3 file4
# ls -l /floppy/mydisk

And that's about it. These concepts also apply to cdroms and zip drives and other things. Although it's done differently. CD roms are automatically mounted for instance. I'll probably write up a simple practice tutorial on usb drives and cdroms in a few days.