Monday, May 19, 2008


FAT32 file system in Solaris 10

Despite many Unix-type file system in existence, it is still problematic to have a single file system which is well compatible with both traditional BSD-based Unix systems, like OpenSolaris (which use older ufs or newer ZFS), and modern Linux distributions (using ext2 or ext3). Though it is technically possible to both mount ufs under Linux and ext3 under Solaris, in neither case support is enabled by default and it may not be very reliable.

That leaves the only file system type which is shared by all Unix/Linux computers without need of any hacking or kernel recompilation as FAT32 from Microsoft. All of its inherit limitations non-withstanding, FAT32-formatted USB flash cards are usually immediately understood and mounted with full read/write access by all modern Unix and Linux distributions.

The only things is, creating such file systems  is not exactly simple. For starters, since Windows 2000 operating system, Microsoft does not provide an option to (re-) format driver as FAT32 if its size exceeds 32 GB, despite the fact and the file system itself has no such limit, so, funny as it is, to create new FAT32 drives one needs either older Windows OS, like Windows 98, or, a Unix/Linux computer.

Debian (and I guess all other modern Linux systems) allows you to create FAT32 file system with one simple command like that (you need to have dosfstools installed first):

mkdosfs -F 32 /dev/sdb1

(you can also use 'fdisk' prior to that to create DOS partition table, but I am not sure it is necessary). Drives so formatted can be then accessed from Windows computer with not trouble as any other FAT32 drive.

With Solaris though, things aren't exactly that simple. I assume that it is being somewhat too picky about existence of "valid" DOS-style "primary" partition table (remember this old DOS logic of four "primary" partitions C,D,E,F and then the rest, if any, being "extended" partitions?). While I am sure it must be somehow possible to convince fdisk and mkdosfs under Linux to create something Solaris will understand, here I present an opposite approach of creating FAT32 system under Solaris.

All operations are executed under "root".

First off, Solaris has so-called "volume management" which (I guess) is charged with auto-mounting user disks. All instructions related to any manipulation with disk devices and mounts outside of services provided by "volume management" insist that you shut down volume management server upfront with this command:

/etc/init.d/volmgt stop

and then restart it with "/etc/init.d/volmgt start" when you're done.

Next, after you plugged it/installed your drive to be formatted, this command:

iostat -En

will help you to identify correct device name for your disk. My external USB hard drive "Free Agent" from Seagate, for example, is reported like that:

c2t0d0           Soft Errors: 86 Hard Errors: 0 Transport Errors: 0 
Vendor: Seagate  Product: FreeAgent Pro Revision: 400D Serial No:  Size: 750.16GB <750156374016 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 86 Predictive Failure Analysis: 0 

Next, you run Sun's fdisk to (interactively) create DOS partition table, like that:

fdisk /dev/rdsk/c2t0d0p0

(note that this has to be "character special" file from /dev/rdsk, and p0 (meaning "first primary partition") appended to the name)

Finally, this command generates file system:

mkfs -F pcfs -o 'fat=32' /dev/rdsk/c2t0d0p0:c

(Note ":c" appended to the name, corresponding to the traditions DOS assignment of drive letter "C" to the 1-st partition)

You can now mount your system with this command:

mount -F pcfs /dev/dsk/c2t0d0p0:c /myusbdrive

(Note that this time we use "block special" file from /dev/dsk)


Thanks for great instruction. After trying 100 other web sites instructions, yours worked first time.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?