OpenBSD - USB

Page content

dmesg

show disks

dmesg |grep ^sd. 
sd0 at scsibus1 targ 0 lun 0: <ATA, KingFast, T031> t10.ATA_KingFast_04xxxxxxxxxxxx
sd0: 114473MB, 512 bytes/sector, 234441648 sectors, thin
sd1 at scsibus4 targ 1 lun 0: <JetFlash, Transcend 8GB, 1100> removable serial.85xxxxxxxxxxxxxxxxxx
sd1: 7450MB, 512 bytes/sector, 15257600 sectors

Show DiskLabel

sysctl hw.disknames
hw.disknames=sd0:9axxxxxxxxxxxxxx,sd1:60xxxxxxxxxxxxxx

Show Disklabel sd1

disklabel sd1 
disklabel sd1 
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Transcend 8GB
duid: 60xxxxxxxxxxxxxx
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 949
total sectors: 15257600
boundstart: 64
boundend: 15257600

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:         15257600                0  unused

Fdisk

kill everything

fdisk -e sd1
Enter 'help' for information
sd1: 1> p
Disk: sd2	geometry: 949/255/63 [15257600 Sectors]
Offset: 0	Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: EF      0   1   2 -      0  16  16 [          64:         960 ] EFI Sys
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] Unused
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] Unused
*3: A6      0  16  17 -     45 227  54 [        1024:      736256 ] OpenBSD
sd1: 1> reinit
Disk: sd1	geometry: 949/255/63 [15257600 Sectors]
Offset: 0	Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] Unused
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] Unused
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] Unused
*3: A6      0   1   2 -    949 189   8 [          64:    15257536 ] OpenBSD
Use 'write' to update disk.
sd1*: 1> w
Writing MBR at offset 0.
sd1: 1>

Create Partition by Hand

disklabel -E 60xxxxxxxxxxxxxx
Label editor (enter '?' for help at any prompt)
60xxxxxxxxxxxxxx> p
OpenBSD area: 64-15257600; size: 15257536; free: 15257536
#                size           offset  fstype [fsize bsize   cpg]
  c:         15257600                0  unused


60xxxxxxxxxxxxxx> a
partition to add: [a] 
offset: [64] 
size: [15257536] 
FS type: [4.2BSD] 
60xxxxxxxxxxxxxx*> w
60xxxxxxxxxxxxxx> x

or Create Paritition Automatically

be carefull add partition a, full size, type 4.2BSD, write and quit

echo -n 'a\n\n\n\n\nw\nq\n' | disklabel -E sd1c

Show Disklabel

disklabel sd1
# disklabel sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Transcend 8GB
duid: 60xxxxxxxxxxxxxx
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 949
total sectors: 15257600
boundstart: 64
boundend: 15257600

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:         15257536               64  4.2BSD   2048 16384     1
  c:         15257600                0  unused

Create FS

newfs sd1a

Mount

mount /dev/sd1a /mnt

Check

df -h /mnt/
# df -h /mnt/
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd1a      7.0G    2.0K    6.7G     1%    /mnt

Mount at Startup

Update fstab and mount sd1.a at /mnt after reboot

diskname=$(sysctl hw.disknames |cut -d',' -f 1 |cut -d':' -f 2)
echo "${diskname}.a /mnt ffs rw,nodev,nosuid 1 2" >> /etc/fstab

Reboot

reboot

and confirm …


Any Comments ?

sha256: f9835f0692b3a0a748234ecf09056792efc3299c1f9b2a7f0dc7c6499295c8e5