HOWTO: Creating & Mounting a Solaris partition on a USB disk drive

For a change, this entry will not be about web services or identity management. It's all about using Solaris commands to create a Solaris partition on a USB removable disk drive. Since I didn't find anything that looked like a short HOWTO for this I thought I'd create a post on that so here we go:

  1. /etc/init.d/volmgt stop
    This turns off vold - not always friendly with usb mass storage devices)
  2. svcs volfs
    It should show volfs as disabled (after step 1).
  3. rmformat -l
    To list the removable devices; this allows to figure out where is my usb disk! (/dev/rdsk/c4t0d0p0 in this example).
  4. fdisk /dev/rdsk/c4t0d0p0
    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.
  5. /rmformat -s /tmp/my_slices /dev/rdsk/c4t0d0p0
    Where my_slices is a text file that describes my slices in the partition. Note Solaris has one "main" partition that you divide in slices (8 max). The slice #2 represents the entire filesystem while others are your own partition). An example of such file would be:
    slices:    2 = 0, 350GB, "wm" "backup" :
                   8 = 0, 350GB, "wm", "name"
  6. prtvtoc /dev/rdsk/c4t0d0p0
    To display the toc on the usb disk and make sure the change took effect.
  7. newfs -v /dev/rdsk/c4t0d0s8
    Assuming you've labeled your partition as #8 (like in the example above).
  8. mount /dev/dsk/c4t0d0s8 /mnt
    Note that it is 'dsk' and not 'rdsk' since we're now addressing the disk in block mode and not the raw disk when we wanted to format it.

 

That's it, you now can stuff this partition with plenty big files or use it as a backup media (my case).

 

 

 

Comments:

Thanks for the consolidated guide, as there are not many on this topic.

However, the ZFS file system greatly simplifies management of removable media as well as fixed. Once you do the typical easy ZFS setup, "zpool create lexar c4t0d0", to create a ZFS pool on your USB removable disk drive, simply issue a "zfs create lexar/usbdrive" and "zfs set mountpoint=/usbdrive lexar/usbdrive" command [as root] to create a ZFS file system mounted at /usbdrive named 'usbdrive'.

Now attach/detach the USB drive all you have to do is "zpool import lexar" to attach and mount or "zpool export lexar" to disconnect and dismount.

Of course, I used the name "lexar" as my ZFS pool name and "usbdrive" at the ZFS file system and mount point for this example, both of which anyone may choose an alternate name of their liking.

Posted by Wes W on December 19, 2006 at 02:33 AM PST #

Hello Wes,

Thanks for your comment.
I was actually planning to do a subsequent entry on using ZFS to do that; I guess you beat me to the punch :-)

Cheers,
Hubert


 

Posted by Hubert on December 19, 2006 at 02:46 AM PST #

No problem Hubert. Perhaps you can make one nice and colorful like your previous posting above as my comments are not as easily to read due to the HTML formating of my comments.

On that topic, do you have to insert loads of HTML code in roller to make such a nice presentation or is that fairly simple to do?

...not to mention I don't spell check. ;)

Posted by Wes W on December 19, 2006 at 03:47 AM PST #

Very useful post & comments. Had been goofing around long enough trying to setup a ufs filesystem on my usb key. rmformat -l wasn't detecting the usb presence until I got the fdisk partitions right. Also, newfs wouldn't run until I specified the size in sectors (newfs -s 8192 /dev/rdsk/c2t0d0p0) in my case. I was able to know the size in sectors by guessing first and then cheking how many sectors were left. Turned out there was a minimun number of sectors for newfs to work (6144). Thanks.

Posted by Memo Salas on March 13, 2007 at 03:14 PM PDT #

Thanks Memo - Glad you found it useful.
I didn't know about the minimum number of sectors for newfs though.
Cheers.

Hubert

Posted by Hubert on March 13, 2007 at 05:12 PM PDT #

Is there any solution ffor USB disk access in Solaris 9?

I want to use a USB disk as a dump device instead of using tapes.

In solaris ther ther is a directory /dev/usb/hub0 can this device be used as dump device?

Thanks in Advances
Jörgen

Posted by Jörgen Sjögren on November 06, 2008 at 05:58 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

hubertsblog

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today