3

I want to format a partition under FreeBSD and change it to UFS filesystem. I searched the web but even the "fdisk" man page is not clear at all. Any help would be clearly appreciated !

My current partition is :

fdisk /dev/da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=121601 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=121601 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 1953520002 (953867 Meg), flag 80 (active)
    beg: cyl 0/ head 1/ sector 1;
    end: cyl 768/ head 254/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
db_ch
  • 648
  • 5
  • 14
  • 21

3 Answers3

4

fdisk for partitions
bsdlabel for slices (for the uninitiated, like partitions for partitions)
newfs for UFS (the native file system)

Quick 1 partition, 1 slice disk:

fdisk -BI [drive]
bsdlabel -wB [drive]s1
newfs [drive]s1a

After which you could mount it with something similar to:

mount [drive]s1a /mnt
Chris S
  • 77,945
  • 11
  • 124
  • 216
4

Nowadays you should use gpart to partition the disk (fdisk/disklabel are being overtaken by gpart since it supports GPT), newfs to format UFS[2] partitions and zpool to create ZFS filesystems. For example to initialize a new, unused disk with a UFS filesystem:

GPT:
gpart create -s gpt adaX
gpart add -t freebsd-ufs adaX
newfs /dev/adaXp1

MBR:
gpart create -s mbr adaX
gpart add -t freebsd adaX
gpart create -s bsd adaXs1
gpart add -t freebsd-ufs adaXs1
newfs /dev/adaX1s1a

If the disk is already partitioned and you want to repartition it, see what's already present with:

gpart show adaX

You can then delete partitions using "gpart delete -i y adaX:

gpart delete -i 4 adaX

You can use "gpart destroy" to destroy the scheme if you want to change it from MBR to GPT for example:

gpart destroy adaX
gpart create -s gpt adaX

GPT is generally preferred nowadays unless you have to interoperate with systems which don't understand it since it can break the 2TB limit and have up to 2^32-1 partitions (in theory!).

BCran
  • 151
  • 2
1

My question was answered on : https://forums.freebsd.org/viewtopic.php?f=3&t=19087&p=108748

Hope it will help someone else :-)

And as requested this is the answer from the link above (if it again becomes unavailable) :

da0 is your drive. The first slice (partition) on that is called s1. fdisk says you have that slice created, so /dev/da0s1 should be present. That's what you format with newfs:

# newfs /dev/da0s1
# mount -t ufs /dev/da0s1 /mnt/usbdisk
# ls -ltr /mnt/usbdisk
total 2
drwxrwxr-x  2 root  operator  512 Nov  6 18:11 .snap

Best regards

db_ch
  • 648
  • 5
  • 14
  • 21