# How to format a partition under FreeBSD



## magix_ch (Nov 6, 2010)

Dear all,

I want to format a partition under FreeBSD and change it to UFS filesystem. I searched the web for hours, including this forum, but even the "fdisk" man page is not clear at all, I really don't understand how to format a disk ! This looks so easy, it's really frustrating to loose 3 hours without succeeding ! 

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>
```


----------



## rusty (Nov 6, 2010)

`% man newfs`


----------



## wblock@ (Nov 6, 2010)

magix_ch said:
			
		

> Dear all,
> 
> I want to format a partition under FreeBSD and change it to UFS filesystem. I searched the web for hours, including this forum, but even the "fdisk" man page is not clear at all, I really don't understand how to format a disk ! This looks so easy, it's really frustrating to loose 3 hours without succeeding !



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

`# newfs /dev/da0s1`


----------



## Beastie (Nov 6, 2010)

Create 1 slice covering the entire disk: `# fdisk -I /dev/devN`
Create 1 partition covering the entire slice: `# bsdlabel -w devNs1`
Create a filesystem on the "a" partition (soft-updates enabled): `# newfs -U /dev/devNs1a`

N.B. 1: If you want to create more than one slice, use a disk layout file (*fdisk -f ...*).
N.B. 2: If you want to create more than one partition or change the existing label, either edit the label (*bsdlabel -e*) or "restore" it from a label file (*bsdlabel -R ...*).

I am sure all this is well covered in the man pages and the handbook.


----------



## magix_ch (Nov 6, 2010)

Dear all,

Thanks a lot for your answers...

Beastie, I tried [cmd=]fdisk -I /dev/da0[/cmd] but I got an error...
But I did as as wblock suggested, I simply did :


```
# 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
```
Thanks a lot for your help !

I can continue working and start the backups I had to do...

In fact we are only using Linux, normally, but I am using FreeNAS, which is quite good, but FreeBSD knowledge is obviously needed to mount USB drives ;-)))

Best regards, and thanks again


----------



## sympton (Aug 1, 2011)

I have similar problem, but i have several, are they slices then, in same 2tb hdd. How do i get rid of them ?


----------

