# creating new partition



## hirohitosan (Apr 10, 2009)

Hi there.
I want to create a new partition on my second HDD.
I did: sysinstall > FDISK > Create > I chose UFS > Write Changes

and:

```
ERROR: Unable to write data to disk ad8!

To edit the labels on a running system set
sysctl kern.geom.debugflags=16 and try again.
```
I quit here for I don't know how and where to


> set sysctl kern.geom.debugflags=16


if I do that I will destroy the partition table on the second HDD? On my second HDD I have Linux.


----------



## Carpetsmoker (Apr 10, 2009)

You need to use the sysctl(8) command, i.e.:
`# sysctl kern.geom.debugflags=16`



> if I do that I will destroy the partition table on the second HDD? On my second HDD I have Linux.



No, this just allows direct editing of disks that are currently in use.
If you want to install a new bootloader (Which is done with boot0cfg(8)) then only the specified disk is modified.
The same applies to sysinstall, it only touches the disk currently selected.


----------



## hirohitosan (Apr 10, 2009)

this is how it looks sysinstall > FDISK before
	
	



```
Offset       Size(ST)        End     Name  PType       Desc  Subtype    Flags

         0         63         62        -     12     unused        0
        63   16370172   16370234    ad8s1      4 linux_swap      130
  16370235  651001995  667372229    ad8s2      4 extended DOS        5
 667372230  309400938  976773167        -     12     unused        0
```
I chose unused slice (the last one). I chose Create > UFS > Write > No boot loader and here how it looks after:

```
0         63         62        -     12     unused        0
        63   16370172   16370234    ad8s1      4 linux_swap      130
  16370235  651001995  667372229    ad8s2      4 extended DOS        5
 667372230  309395835  976768064    ad8s3      8    freebsd      165
 976768065       5103  976773167        -     12     unused        0
```
I quit FDISK and open Label > Create > FS > Mount point /mnt/2_ufs

```
Part      Mount          Size Newfs   Part      Mount          Size Newfs
----      -----          ---- -----   ----      -----          ---- -----
ad8s3d    /mnt/2_uf     147GB UFS2+S Y
```
and Write but :

```
Error mounting /dev/ad8s3d on /mnt/2_ufs : No such file or directory
```
but the /mnt/2_ufs exist since I created before starting FSDISK.
the problem is ...
	
	



```
ls /dev/ad8*
/dev/ad8        /dev/ad8s1      /dev/ad8s2      /dev/ad8s5      /dev/ad8s6
```
I don't have ad8s3. Why FDISK add ad8s3?
or where is the problem?

thx


----------



## Carpetsmoker (Apr 10, 2009)

I suspect it's /dev/ad8s6 or /dev/ad8s2, the reason the numbers are quirky is because you use logical partitions.

I haven't used logical partitions in years, so I'm not 100% sure how FreeBSD deals with them, but you have 4 partitions (2 primary, 1 extended which counts are primary, and one logical), and there are also 4 ad8s* device names.
Since FreeBSD is the last partition, I would guess ad8s6.

OR

FreeBSD reserves numbers above ad*s4 for extended/logical partitions, ad8s5 is the extended partition, ad8s6 the logical, and ad8s2 the FreeBSD.

Hint:
You can use `# less -f /dev/ad8s*` to quickly examine a disks content, this is not perfect, but many filesystems have a easily recognizable header which can be used to identify the FS.

You can of course also try mounting them and see what happens.
Or maybe there is a tool for sniffing filesystems ...


----------



## Djn (Apr 10, 2009)

It's the latter: s1->4 are the primary, and s5+ are logical.
(Or at least that's what the evidence points at: Given a disk with one extended partition containing five logical partitions, I have s1, and s5->s9.)


----------



## hirohitosan (Apr 10, 2009)

Carpetsmoker said:
			
		

> I suspect it's /dev/ad8s6 or /dev/ad8s2, the reason the numbers are quirky is because you use logical partitions


the ad8s6 I'm sure it's fat since I mounted in fstab
`# less -f /dev/ad8s*` 
well I did it but I cannot post the output ...



			
				Carpetsmoker said:
			
		

> You can of course also try mounting them and see what happens.


here's the output:

```
# mount /dev/ad8s2 /mnt/2_ufs/
mount: /dev/ad8s2 : Operation not permitted
# mount /dev/ad8s5 /mnt/2_ufs/
mount: /dev/ad8s5 : Invalid argument
# mount /dev/ad8s1 /mnt/2_ufs/
mount: /dev/ad8s1 : Invalid argument
# mount /dev/ad8s6 /mnt/2_ufs/
mount: /dev/ad8s6 : Operation not permitted
```
the problem is that after using sysinstall none of partition was formated.
maybe I should remove the logical partition ... I didn't realize that when I installed Linux, the second HDD was formated as logical


----------



## Beastie (Apr 11, 2009)

I usually only use primary BIOS partitions.

And I only use sysinstall to calculate the physical location and size of slices.

I then leave sysinstall and do everything manually using the information collected in sysinstall:
1. create slice: fdisk -u ad8
2. create labels: bsdlabel -w /dev/ad8s3
3. edit labels if you want: bsdlabel -e /dev/ad8s3
4. format new partition: newfs -U /dev/ad8s3d
5. modify /etc/fstab


----------

