I just bought a Seagate Backup Plus 2TB external USB hard drive for backing up my OpenBSD files. The factory-installed file system (not listed on the box) is (or was) NTFS -- read-only in OpenBSD. Obviously, I need to reformat this drive if I want to use it.
Disk formatting in OpenBSD is truly intimidating. I just want to plug in a drive and format it as MSDOS for maximum compatibility with other operating systems. Smaller-sized drives are easy. I plug them into my OS9 Mac, format them as DOS, and I'm good to go. That works until the drive gets too big for the Mac to handle. Hence, my current problem.
Long story short, I plugged this 2TB drive into my OS9 Mac and initialized it as "DOS 1,863GB". The end result was a 7GB capacity drive.
I plugged the drive into OpenBSD and ran:
Code:
$ disklabel -h sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: BUP Slim BK
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 243201
total sectors: 3907029167 # total bytes: 1863.0G
boundstart: 0
boundend: 3907029167
drivedata: 0
16 partitions:
# size offset fstype [fsize bsize cpg]
c: 1863.0G 0 unused
i: 7.0G 32 MSDOS
That's mostly what I wanted -- an MSDOS drive with two partitions, c and i -- except that partition i should be 1863.0G.
newfs(8) seemed like the best option for increasing the size of this partition.
Starting with
disklabel(8), I ran
$ disklabel -e sd1
and changed the size of partition i to 3907029135 (3907029167 minus 32, to account for the offset), then checked the partition size and available free space:
Code:
$ df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/sd1i 7.0G 8.0K 7.0G 0% /path/to/mount-point
I still needed to rebuild the file system on the disk.
I printed the file system parameters:
Code:
$ newfs -N -t msdos sd1i
/dev/rsd1i: 3903217360 sectors in 243951085 FAT32 clusters (8192 bytes/cluster)
bps=512 spc=16 res=32 nft=2 mid=0xf8 spt=63 hds=255 hid=32 bsec=3907029135 bspf=1905868 rdcl=2 infs=1 bkbs=2
and reconstructed the file system:
Code:
$ newfs -t msdos sd1i
I think it worked!
Code:
$ disklabel -h sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: BUP Slim BK
duid: afb5ddb4eca1df71
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 243201
total sectors: 3907029167 # total bytes: 1.8T
boundstart: 0
boundend: 3907029167
drivedata: 0
16 partitions:
# size offset fstype [fsize bsize cpg]
c: 1.8T 0 unused
i: 1.8T 32 MSDOS
Code:
$ df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/sd1i 1.8T 8.0K 1.8T 0% /path/to/mount-point
Code:
$ fdisk sd1
Disk: sd1 geometry: 243201/255/63 [3907029167 Sectors]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
*0: 0C 0 0 33 - 915 244 33 [ 32: 14714848 ] FAT32L
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
Did I do this correctly and is there anything I should be aware of before writing a backup to this drive?
Also, does anyone know if there is a good reference on the nuts and bolts of disk formatting?
Thanks.