USB support in Solaris is greatly improved these days. One thing I’ve had as a goal for a while now is to more fully migrate my server backups to using disk instead of tape. (Disk for backups? Isn’t that backwards? Actually, if you look at media prices, IDE disks are WAY cheaper than tape media, and that doesn’t even cover the exorbitant cost of tape drives. And rsync *rocks* for this type of application.) One thing that’s still keeping me on tape in addition to disk is that I don’t have any way to do easy offsite storage with disk. But USB drives provide a perfect opportunity to do this.
I’ve been playing a lot with Solaris 10 x86, so I decided to see how hard it is to get a USB disk installed. Unfortunately there’s not a whole lot of documentation out there, and what I could find was pretty vague, along the lines of ‘run rmformat’ which tells you approximately 5% of what you need to know. There’s a couple of pitfalls if you just poke around, so here’s the complete procedure I worked out.
Keep in mind that this is for Solaris 10 x86. The sparc version would be different, but would probably just skip the fdisk stuff and the s2 workarounds. This procedure also assumes you want to use ufs as the filesystem instead of something else like FAT (aka pcfs). Also remember that ufs drives cannot be shared between sparc and x86 servers because of the different methods for layout on the disk. This assumes that your USB chipset is supported and that your USB disk doesn’t require some proprietary driver. Most USB chipsets are supported in Solaris 10 x86, and most current USB disks on the market are generic. If the disk is plug-and-play on XP and Mac, it’ll probably work. The setup requires root access.
Disable Volume Management: /etc/init.d/volmgt stop
(If you don’t, vold will get in the way of what you are doing.)
Plug in your USB drive.
Look at end of file /var/adm/messages and run prtconf -v
to verify it is recognized.
/var/adm/messages:
Apr 24 01:16:27 yemaozi.tcp.com usba: [ID 912658 kern.info] USB 2.0 device (usb4b4,6830) operating at hi speed (USB 2.x) on USB 2.0 root hub: storage@6, scsa2usb0 at bus address 2
Apr 24 01:16:27 yemaozi.tcp.com usba: [ID 349649 kern.info] Cypress Semiconductor USB2.0 Storage Device DEF1097DC60E
prtconf -v
:
storage, instance #0
...
Hardware properties:
...
name='usb-product-name' type=string items=1
value='USB2.0 Storage Device'
name='usb-vendor-name' type=string items=1
value='Cypress Semiconductor'
name='usb-serialno' type=string items=1
value='DEF1097DC60E'
...
Run rmformat -l
to list removable drives:
Looking for devices...
1. Logical Node: /dev/rdsk/c1t1d0p0
Physical Node: /pci@0,0/pci-ide@1f,1/ide@1/sd@1,0
Connected Device: ASUS CD-S520/A4 1.21
Device Type: CD Reader
2. Logical Node: /dev/rdsk/c2t0d0p0
Physical Node: /pci@0,0/pci1297,fb62@1d,7/storage@6/disk@0,0
Connected Device: SAMSUNG SP1604N
Device Type: Removable
The first device is the CD-ROM drive. The USB disk is device 2, which is at /dev/rdsk/c2t0d0p0
First create fdisk partitions: run fdisk -B /dev/rdsk/c2t0d0p0
which assigns the
whole disk to solaris. You may need to use fdisk interactively if the disk already had PC style partitioning on it to remove all other partitions before proceeding.
Add a label: rmformat -b usb-sam /dev/rdsk/c2t0d0p0
This label can be up to 8 characters. You don’t have to add one, but if you don’t add a label, it will show up as “unnamed_rmdisk” under volume management which looks icky. Here we used the label ‘usb-sam’.
Now here’s where it gets a little tricky. If you’re used to working with sparc stuff, you know that you can use partition s2 to make one big partition using the whole disk. On Solaris x86, there’s always a one cylinder boot partition (s8) at the beginning of the disk. This applies even if you’ll never boot off of that disk. So if you want to use the whole disk, you will have to start any data partitions at cylinder 1 instead of 0. Another catch is that Volume Management by default looks for s2 on removable disks, so if you use a different partition such as s0, it won’t automatically mount. But format
won’t let you change the size of s2 if you keep the partition id as ‘backup’. So putting all of this together, the easiest way to resolve this is to change the partition id of s2 to ‘root’, set the permissions to ‘wm’ and then resize it to start at cylinder 1 and use the rest of the disk.
Partition disk: run format -e
. Without the -e flag, Solaris won’t show
removable disks. Select your USB disk and then enter the following commands to do as described in the previous paragraph:
partition
2
root
wm
1
press enter for default
label
press enter for default
y
quit
quit
Run prtvtoc /dev/rdsk/c2t0d0p0
to verify partitioning, e.g.:
* /dev/rdsk/c2t0d0p0 (volume "usb-sam") partition map
*
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 16065 sectors/cylinder
* 19456 cylinders
* 19454 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
2 2 00 16065 312512445 312528509
8 1 01 0 16065 16064
Verify that partition s2 does NOT start at sector 0.
Now create a filesystem: newfs /dev/rdsk/c2t0d0s2
Re-enable Volume Management: /etc/init.d/volmgt start
It should show up after a second or two:
df -k
:
Filesystem 1K-blocks Used Available Use% Mounted on
...
/vol/dev/dsk/c2t0d0/usb-sam/s2
153893759 65553 152289269 1% /rmdisk/usb-sam/s2
When you want to remove the disk, don’t just unplug it from the system. You need to use eject to have Volume Management unmount it first: eject usb-sam
Here we use the disk’s label to identify the device to eject. If you didn’t use a label you can do this instead, though it will be ambiguous if you have multiple removable disks in use: eject rmdisk
Then before you actually unplug the drive, you will need to stop Volume Management because it cannot deal with devices being unplugged. This has to be the stupidest thing ever. Here’s what the manual says:
A disk storage device can not be removed or inserted while
vold is active. To remove or insert a removeable mass
storage device such as a USB memory stick, first stop the
daemon by issuing the command /etc/init.d/volmgt stop. After
the device has been removed or inserted, restart the daemon
by issuing the command /etc/init.d/volmgt start.
So much for Volume Management being automatic. Optionally you can either remove rmdisk support in vold.conf or disable vold completely and mount/unmount the drive manually. Would probably be easier.