Politics and Technology.

Friday, January 30, 2009

USB Drive on Solaris

This guide walks you through mounting a USB drive on a Solaris SPARC system. The idea is to get the Solaris SPARC to use a disk that is partitioned to be usable by Windows. This Windows "curse" is unavoidable, but Sun ships the right tools to deal with it.
The idea is to create a primary partition for Solaris. Solaris is them "fooled" into using this Windows partition as if it was just raw disk.
Fortunately I found a good blog entry that explained how to do this.

Solaris 10

This is written for Solaris 10. This was tested on a T5240.

Plug it in

Find a happy and available USB port. Plug your USB drive in. Run "dmesg" to confirm that it saw you add the drive to the USB bus.

Volume Management
It is a good idea to turn off Volume Management. It will force you to use the "psuedo" device to refer to the USB drive until you do. You can stop Volume Management in the old school way, and then run "svcs" to check to see if you were successful.


# /etc/init.d/volmgt stop
# svcs volfs



Formatting

Regular format doesn't cut the mustard here. It won't even see your USB drive. Fortunately, Solaris now ships with "rmformat" which will show you "removable" type devices. Use the "-l" option to have it list the removable drives and you should be able to pick out the USB drive. Note the cXtXdXsX.


bash-3.00# rmformat -l
Looking for devices...
1. Logical Node: /dev/rdsk/c0t0d0s2
Physical Node: /pci@400/pci@0/pci@1/pci@0/usb@0,2/storage@2/disk@0,0
Connected Device: TSSTcorp CD/DVDW TS-T632A SR03
Device Type: DVD Reader/Writer
2. Logical Node: /dev/rdsk/c2t0d0s2
Physical Node: /pci@400/pci@0/pci@1/pci@0/usb@0,2/storage@1/disk@0,0
Connected Device: Hitachi Easy Device
Device Type: Removable
bash-3.00#


Now that you know the cXtXdXsX of our target, we have to fdisk it


# fdisk /dev/rdsk/c4t0d0p0


I'll let the blog explain what to do here:

To create the main Solaris partition. If no partition were initially present, just answering yes to the subsequent question will assign 100% of the disk to Solaris. side note: some of you may remember that Linux & Solaris did not like to be on the same disk since Solaris uses the same file format type number than Linux...Well the good news is that one can (and should) use the Solaris2 type so as to avoid those conflicts.


After partitioning the disk, put Solaris partitions on it with the rmformat command. It's easiest to create a template file for it to use.
This file would create a single "backup" slice 2 disk.


# cat my_slices
slices: 2 = 0, 45GB, "wm" "backup"
#


Remember that this is a USB drive, not a StorEdge box so your read and write performance with the device will be pitiful. If you are using the drive to temporarily store some data, set your slice size to be about 20% bigger than your data set size. It will save a lot of time when you have to newfs it.
Now just run rmformat with this file and the USB device.


# rmformat -s /tmp/my_slices /dev/rdsk/c2t0d0s2


Now check your work with the familiar prtvtoc.


bash-3.00# prtvtoc /dev/rdsk/c2t0d0s2
* /dev/rdsk/c2t0d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 16065 sectors/cylinder
* 60801 cylinders
* 60801 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* Unallocated space:
* First Sector Last
* Sector Count Sector
* 0 976768065 976768064
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
2 5 00 0 94371840 94371839
bash-3.00#


Filesystems

From this point, just treat it like you would any other disk.


# newfs -m 1 /dev/rdsk/c2t0d0s2
...
# mount /dev/dsk/c2t0d0s2 /mnt

2 comments:

Anders said...

Excellent guide.

I had problems using this with my USB Memory stick because it was not properly reporting it's size, so I added the -s option to newfs command:

newfs -s 94371840 -m 1 /dev/rdsk/c2t0d0s2

where the size is fetched from the number of secors in the prtvtoc command.

The my_slices file is missing a "," between "wm" and "backup". Should read

slices: 2 = 0, 45GB, "wm", "backup"

jowdjbrown said...

A USB is a storage device that has multiple uses and serves many needs. Today there are numerous offices where usage of these USB drives are not encouraged due to various security and other reasons. However, they still remain a strong choice by many for a number of reasons.custom flash drives