Format a USB flash drive using gpart

Bruce Cran bruce at cran.org.uk
Mon Jul 9 11:50:18 UTC 2012


On 09/07/2012 11:16, Polytropon wrote:
> If you're talking about an MS-DOS disk, then yes, it contains
> a DOS partition which is formatted. In FreeBSD, we would call
> it a slice (slice == "DOS primary partition"). In this case,
> there is no (sub)partitioning, the _slice_ carries the MS-DOS
> file system here. You know that MS-DOS does not have support
> for partitioning.

Floppy disks aren't partitioned/sliced - they use 'dangerously 
dedicated' mode, containing nothing except the filesystem. The way you'd 
mount it would be:

mount /dev/fd0 /mnt/point

You can do the same with a normal USB or other disk using:

newfs /dev/da0
mount /dev/da0 /mnt/point

The reason it's called 'dangerously dedicated' I think is that other 
systems - or even the same system months/years later if you forget and 
run the wrong tools - won't know there's a filesystem there and it's 
easy to think the disk's empty.  If you're on an old system and run 
'gpart show da0' and don't see a partition table it's quite easy to 
forget to check if da0 itself contains a filesystem.

When using GPT what were called slices are now partitions, and instead 
of 'ada0s1a' (disk 0, slice 1, partition a) you just have 'ada0p1'. A 
partition table supports up to 4096 entries (gpart creates one 
supporting 128 by default) so there's no need for the freebsd container 
any more - you just create freebsd-boot, freebsd-ufs, freebsd-zfs, 
freebsd-swap entries e.g. 'gpart add -t freebsd-ufs -s 64g da0'.

-- 
Bruce Cran


More information about the freebsd-questions mailing list