Local References (* works-in-progress)
Workstation Security Server Other
Setting up custom terminal windows * Explanation of inetd and rc.conf usage with links to hardening the box Quick Perl setup within Apache Chroot of OpenBSD Various loopback wiring diagrams
Making gtk-gnutella 0.93.3 on OpenBSD 3.3 * IPF and the examples from /usr/share/ipf/ Additional Setup for MySQL/Perl within Apache Chroot of OpenBSD * ICMP types and codes
      External USB Storage under OpenBSD
       

Example: Mount External USB Storage under OpenBSD

Intro

A friend had an extra My Book and sold it to me cheap. A 320GB external USB drive, and I hadn't put a USB device near the OpenBSD server before. It took a little poking and since I didn't see a straightforward list on a quick google search, wrote my steps down for next time.

Steps

Find the scsi id of the usb device, it may be that the first plugged in is always sd0, but to be sure use dmesg. Then, to find which partition is setup how (which fstype) use disklabel disk. That should provide all the info needed to plug into mount -t fstype disk dir. If that reminder doesn't work, continue on for examples below.

Find scsi special

My Western Digital My Book shows up as sd0, it is evident in syslog messages and dmesg:

 
lmno$ tail /var/log/messages
Jan 24 21:33:50 lmno /bsd: umass0: using SCSI over Bulk-Only
Jan 24 21:33:50 lmno /bsd: scsibus1 at umass0: 2 targets
Jan 24 21:33:50 lmno /bsd: sd0 at scsibus1 targ 1 lun 0:  SCSI4 0/direct fixed
Jan 24 21:33:50 lmno /bsd: sd0: 305245MB, 305245 cyl, 64 head, 32 sec, 512 bytes/sec, 625142448 sec total
Jan 24 21:33:50 lmno /bsd: uhidev0 at uhub3 port 6 configuration 1 interface 1
Jan 24 21:33:50 lmno /bsd:
Jan 24 21:33:50 lmno /bsd: uhidev0: Western Digital My Book, rev 2.00/10.16, addr 2, iclass 3/0
Jan 24 21:33:50 lmno /bsd: uhid0 at uhidev0: input=1, output=2, feature=0
Jan 24 21:58:14 lmno /bsd: udf_mount: enforcing read-only mode
Jan 24 22:00:01 lmno syslogd: restart
lmno$ dmesg
...
umass0 at uhub3 port 6 configuration 1 interface 0
umass0: Western Digital My Book, rev 2.00/10.16, addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets
sd0 at scsibus1 targ 1 lun 0:  SCSI4 0/direct fixed
sd0: 305245MB, 305245 cyl, 64 head, 32 sec, 512 bytes/sec, 625142448 sec total
uhidev0 at uhub3 port 6 configuration 1 interface 1
uhidev0: Western Digital My Book, rev 2.00/10.16, addr 2, iclass 3/0
...

Verify fstype

Verify the filesystem in use is msdos under openbsd, using partition i:

lmno$ sudo disklabel sd0
Password:
disklabel: warning, DOS partition table with no valid OpenBSD partition
# /dev/rsd0c:
type: SCSI
disk: SCSI disk
label: My Book
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 305245
total sectors: 625142448
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

16 partitions:
#             size        offset  fstype [fsize bsize  cpg]
  c:     625142448             0  unused      0     0      # Cyl     0 -305245*
  i:     625137282            63   MSDOS                   # Cyl     0*-305242*

Mount the drive

Create a destination node and mount the device on it

lmno$ sudo mkdir -p /mnt/mybook/
lmno$ sudo mount_msdos /dev/sd0i /mnt/mybook/
lmno$ df -h /mnt/mybook
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd0i      298G   83.3G    215G    28%    /mnt/mybook

Unmount Drive

Rather than force things to umount when done with /mnt/mybook for awhile, I had to check into why it wouldn't umount and it turned out I had restarted mysql while pwd was on the mouned drive.

lmno$ sudo umount /mnt/mybook/
Password:
umount: /mnt/mybook: Device busy

lmno$ fstat | grep mnt                                                   
root     sh         26544   wd /mnt/mybook   371098 ?rwSr-S--T   r 255593762450 

lmno$ ps auwx | grep 26544                                               
root     26544  0.0  0.0   548     4 p0  I      1:42AM    0:00.02 /bin/sh /usr/local/bin/mysqld_safe    

lmno$ sudo kill_mysqld                                                   
STOPPING server from pid file /var/mysql/lmno.pid
090125 12:41:32  mysqld ended

lmno$ sudo umount /mnt/mybook/

lmno$ sudo start_mysqld                                                 
Starting mysqld daemon with databases from /var/mysql                          
.ln: /var/run/mysql/mysql.sock: File exists                                    
done