USB Disks on Solaris 10 x86

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.

17 thoughts on “USB Disks on Solaris 10 x86”

  1. With solaris 10 you we have hot-pluggable support for USB flash – I tried this on an x86.
    Simply push in the memory stick. run a ‘pkill -HUP vold’ and voila! the drive is mounted as part of /rmdisk/noname.
    Thereafter you can read to it write to it – do whatever you like.

    Hope this helps someone.
    Regards,
    Tania

    (http://livejournal.com/users/)

  2. If it already has a filesystem on it, then yes, that’s all you have to do. Note though that you still have to reset vold, something a normal user can’t do. You will also have to make sure vold is kicked again when removing it, or the usb port will get screwed up. It would be a lot nicer if vold figured all this out for you, like say on EVERY OTHER OS.

    (http://livejournal.com/users/jlick)

  3. Just a very small comment:

    Solaris is a Server OS, and just happen to be a very nice OS for a “normal” PC. Why on earth would you even consider running vold on a server class machine?

    and I would not classify Linux as part of “EVERY OTHER OS” 🙂

    (http://livejournal.com/users/)

  4. vold does one thing really really well: it automatically mounts CDs when you insert them in the drive. For most other things it seems to get in the way more often than it helps in my experience. I’ve been told that there’s been significant changes made to vold coming out in build 19 or 20 of opensolaris, though, so there’s hope that some of the issues will be dealt with. For what it’s worth, for the issue referenced in this post, I’ve taken to commenting out the “use rmdisk” line in vold.conf and mounting the USB disk manually.

    (http://livejournal.com/users/jlick)

  5. have tried this The some commands don’t work (Example: rmformat -l returns with error “no such option” and also such option does not show on my man pages.) and there is no mention of Firewire.

    I suspect that since this blog applies to *USB* on Solaris 10 X86 and I am using Firewire (IEEE 1394) with Solaris 8 on a Sun Blade 1500, that it is not appropriate to my situation. To quote from the blog “Keep in mind that this is for Solaris 10 X86”.

    Please help me use this neat little RAID.

  6. I am using Firewire (IEEE 1394) with Solaris 8 on a Sun Blade 1500.

    I have this Firewire RAID unit and cant get it to work with Solaris 8 on a Sun Blade 1500.

    Any help would be great….

    Thank you…

    Mark

  7. Not only was your information useful toward getting my USB jump drive working again, but it made me realize why my Solaris10x86 OS stopped recognizing it in the first place.

    I should not have used svcadm to disable all those services a couple weeks ago 🙁 I think one of them was volume manager.. oops. I think there is a way I can fix it so that when the machine boots, it will automatically start volume manager each time without having to type in /etc/init.d/volmgt start.

    /usr/sbin/svcadm -v enable svc:/system/filesystem/volfs:default
    seems to have worked. I will see the next time I reboot.
    Thank so much.
    –Bob ( the Solaris10 newbie)

  8. Do you know of a way to add a label to a pcfs-formatted USB drive so that Solaris x86 shows it on my desktop with that label? In other words, something like this:

    rmformat -b usb-sam /dev/rdsk/c2t0d0p0

    for a pcfs-formatted USB drive (something like this–which doesn’t work AFAIK):

    mkfs -F pcfs -o b=BIGUSBDRIVE /dev/rdsk/c2t0d0p0

    Solaris 10 x86 refuses to show this USB drive by “BIGUSBDRIVE” but still by the icky “unnamed_rmdisk”. Any suggestions?

  9. I tried to add a WD1600BEVE 160GB usb external disk to Sun SPARC solaris 10 system by following your above procedure. But when I tried the step “format -e”, but it showed the c2t0d0s2 is a unkown disk type. I selected other and tried to input cylinder, head, sector information by myself, but it failed because of the cylinder number 310101 is out of range. What should I do to let system recognizing this external usb disk and working properly?

    Thank you very much!

    Best Regards,
    Steven Chang

  10. I’m running into the same problem as Steven.

    It would be nice if you can come back here and post how you eventually resolved your issue 😉

    Thanks

  11. I’ve found this very helpful, though in reading the comments from Steven Chang and Justin Vassalio, am a bit worried, as I am about to undertake this on a SPARC machine. Is there any way of getting in touch with either of these guys to find out how they resolved the issue of how to format the drive? Does anyone else know?
    You can email directly to r o d g e r s (“at”) arborvitae
    dot coM …

    Cheers, Rick Rodgers

  12. Rick,

    I have been having similar issues with a Sony Tiny Vault USB stick on a Sparc (v240), and also an external 500gb usb drive.

    I was lucky enough to have my laptop running fedora, and I plugged in the USB drive, and formatted it (fdisk /dev/sda) , and gave it a “Sun Label”.
    I then made a new file system, with the linux box, using mkfs hsfs.
    I did the same with my 500gb drive.

    once I did that, I am now able to mount both, the USB stick and the drive on my sparc, using the s2 partition (it cannot see s0 or s1).

    The information from format -e /dev/rdsk/c3t0d0s2 when selecting partition, looks like a typical “default solaris formatted drive”, yet I cannot run any mkfs on my sparc, as it always comes up with either invalid VTOC, or cannot find disk parameters, or some other nosh like that.

    I would suggest using opensolaris or the latest version of solaris 11, maybe it will work better.

    The reason I need the little usb stick, is to write metadb’s for my disksuite-mirrored drives, so that I always have more then 50% of the metadb’s when one drive dies.

  13. Is there any way to receive/register signal when USB is inserted/removed ?
    I want to monitor USB device from my application on solaris 10u11.

Leave a Reply

Your email address will not be published. Required fields are marked *