XXX: XXX: Rationale: `The NetBSD Guide' seems to not contain any paragraphs XXX: about using USB flash drives in `Chapter 13. Using removable media'. XXX: The following notes show an example how to initialize and create an XXX: MS-DOS partition and filesystem on an USB flash drive. XXX: USB flash drives can be used to share data among machines. After attaching it we can see via dmesg(8) that it is recognised as `sd0': # dmesg [...] sd0 at scsibus0 target 0 lun 0: disk removable sd0: fabricating a geometry sd0: 14755 MB, 14755 cyl, 64 head, 32 sec, 512 bytes/sect x 30218842 sectors sd0: fabricating a geometry [...] WARNING: WARNING: Please note that the following commands will erase all the previous WARNING: contents on the USB flash drive! WARNING: To initialize it we can write zeros in the first 1MB of the USB flash drive: # dd if=/dev/zero of=/dev/rsd0d bs=1m count=1 1+0 records in 1+0 records out 1048576 bytes transferred in 0.118 secs (8886237 bytes/sec) Via fdisk(8) we can create a partition table. MS-DOS partition and filesystem is supported by most operating systems and devices that accept an USB disk, so let's update the partition table (`-u'), creating an MS-DOS partition and set the new partition as active (`-a'): # fdisk -au sd0 fdisk: primary partition table invalid, no magic in sector 0 fdisk: Cannot determine the number of heads Disk: /dev/rsd0d NetBSD disklabel disk geometry: cylinders: 14755, heads: 64, sectors/track: 32 (2048 sectors/cylinder) total sectors: 30218842, bytes/sector: 512 BIOS disk geometry: cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder) total sectors: 30218842 Partitions aligned to 16065 sector boundaries, offset 63 Do you want to change our idea of what BIOS thinks? [n] Partition table: 0: 1: 2: 3: Bootselector disabled. No active partition. Drive serial number: 0 (0x00000000) Which partition do you want to change?: [none] 0 The data for partition 0 is: sysid: [0..255 default: 169] 11 start: [0..1881cyl default: 63, 0cyl, 0MB] size: [0..1881cyl default: 30218779, 1881cyl, 14755MB] bootmenu: [] (space to clear) Partition table: 0: Primary DOS with 32 bit FAT (sysid 11) start 63, size 30218779 (14755 MB, Cyls 0-1881/9/10) PBR is not bootable: All bytes are identical (0x00) 1: 2: 3: Bootselector disabled. No active partition. Drive serial number: 0 (0x00000000) Which partition do you want to change?: [none] Do you want to change the active partition? [n] y Choosing 4 will make no partition active. active partition: [0..4 default: 4] 0 Are you happy with this choice? [n] y We haven't written the MBR back to disk yet. This is your last chance. Partition table: 0: Primary DOS with 32 bit FAT (sysid 11) start 63, size 30218779 (14755 MB, Cyls 0-1881/9/10), Active PBR is not bootable: All bytes are identical (0x00) 1: 2: 3: Bootselector disabled. First active partition: 0 Drive serial number: 0 (0x00000000) Should we write new partition table? [n] y Then we can see via disklabel(8): # disklabel sd0 # /dev/rsd0d: type: SCSI disk: DataTraveler 3.0 label: fictitious flags: removable bytes/sector: 512 sectors/track: 32 tracks/cylinder: 64 sectors/cylinder: 2048 cylinders: 14755 total sectors: 30218842 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 5 partitions: # size offset fstype [fsize bsize cpg/sgs] d: 30218842 0 unused 0 0 # (Cyl. 0 - 14755*) e: 30218779 63 MSDOS # (Cyl. 0*- 14755*) disklabel: boot block size 0 disklabel: super block size 0 that an sd0e MSDOS partition is present. We can finally create an MS-DOS filesystem via newfs_msdos(8): # newfs_msdos /dev/rsd0e /dev/rsd0e: 30189264 sectors in 1886829 FAT32 clusters (8192 bytes/cluster) MBR type: 11 bps=512 spc=16 res=32 nft=2 mid=0xf0 spt=32 hds=64 hid=0 bsec=30218779 bspf=14741 rdcl=2 infs=1 bkbs=2 It is ready to be used and mounted via mount_msdos(8).