# Question about gpart



## circus78 (Nov 2, 2013)

Hi,
I'd like to add a partition; my 80GB hard disk is:


```
# gpart show
=>       63  156367953  ada0  MBR  (74G)
         63   31457223     1  freebsd  [active]  (15G)
   31457286  124910730        - free -  (59G)

=>       0  31457223  ada0s1  BSD  (15G)
         0  29360128       1  freebsd-ufs  (14G)
  29360128   2097094       2  freebsd-swap  (1G)
  31457222         1          - free -  (512B)
```

Basically I would like to add a second slice in free hard disk area (59GB).
This partition has to be formatted with EXT3 fs.

Is the correct command:
`gpart add -s 31457286  -t mbr`

?

After, I'll do other work with sysutils/e2fsprogs port.
Thank you!


----------



## mav@ (Nov 2, 2013)

MBR is not a partition type, but a partition schema. I am not sure which partition type should be for EXT3, but I would try something like "linux-data".


----------



## wblock@ (Nov 2, 2013)

Partition types.  gpart(8) knows some of these by name, but the others must be entered with an exclamation point and a number.  Because the exclamation point can be interpreted by the shell, it should be escaped:

`gpart add -t \!131 -a4k ada0`

Untested.  I think that will add a partition in the first free space.


----------



## circus78 (Nov 3, 2013)

Hi, thank you for your replies.
Do you think it's safer to do this with GParted or another Linux live distribution?
For example, if I boot with live CD and then I add partition with `fdisk`, can I screw FreeBSD's MBR?


----------



## wblock@ (Nov 3, 2013)

There are at least three different programs called fdisk.  It's not clear why you'd trust FreeBSD to create the other partitions but then not to create this one.  Back everything up, then use the program you prefer.


----------



## circus78 (Nov 3, 2013)

mav@ said:
			
		

> MBR is not a partition type, but a partition schema. I am not sure which partition type should be for EXT3, but I would try something like "linux-data".



Please take a look on the manpage, it says "mbr" even in PARTITION TYPE section.
I don't see any reference to "linux-data", instead.


----------



## kpa (Nov 3, 2013)

I think that is just what is known as "extended partition" outside FreeBSD. Another term is used is EBR.

Edit: With GPT partitioning the partition type "mbr" really means a GPT partition that is subdivided by an MBR to four individual partitions, strange but true.


----------



## circus78 (Nov 3, 2013)

wblock@ said:
			
		

> It's not clear why you'd trust FreeBSD to create the other partitions but then not to create this one.



Sorry, I was scared of your "untested" (like "dangerous") 
Anyway, I created partition with your command:

`gpart add -t \!131 -a4k ada0`

and now I have:


```
# gpart show
=>       63  156367953  ada0  MBR  (74G)
         63   31457223     1  freebsd  [active]  (15G)
   31457286         63        - free -  (31k)
   31457349  124910604     2  linux-data  (59G)
  156367953         63        - free -  (31k)

=>       0  31457223  ada0s1  BSD  (15G)
         0  29360128       1  freebsd-ufs  (14G)
  29360128   2097094       2  freebsd-swap  (1G)
  31457222         1          - free -  (512B)
```

What's the advantage of alignment?
Thank you so much.


----------



## circus78 (Nov 3, 2013)

mav@ said:
			
		

> MBR is not a partition type, but a partition schema. I am not sure which partition type should be for EXT3, but I would try something like "linux-data".



Sorry, now I realize that you mean type "131" (0x83).
Thank you


----------



## wblock@ (Nov 3, 2013)

Alignment makes for faster writes on 4K-block drives, with zero disadvantage on drives with 512-byte blocks.  However, I forgot about the MBR standards on FreeBSD, which negate the alignment for MBR anyway.

It doesn't matter on that drive, it's not big enough to have 4K blocks.

The `gpart` output shows that it does know linux-data as a keyword, and that could have been used as the type when adding rather than just the partition ID number.

PS: please put program output in [code] tags, which preserve whitespace formatting.


----------

