Solved Setting up a hard drive with gpart

I am trying to verify that I have done this correctly. I am looking to have my hard drive look like:

This is the example I was given:
Code:
# gpart show ada0
=>       63  234441585  ada0  MBR  (112G)
         63          1        - free -  (512B)
         64     262144     1  fat16  (128M)
     262208  234179432     2  freebsd  (112G)
  234441640          8        - free -  (4.0K)

=>        0  234179432  ada0s2  BSD  (112G)
          0   41943040       1  freebsd-ufs  (20G)
   41943040    8388608       2  freebsd-swap  (4.0G)
   50331648  183847784       4  freebsd-zfs  (88G)
What is the best way to do this?

Thanks!
 

SirDice

Administrator
Staff member
Administrator
Moderator
Use GPT instead of MBR for anything new. While MBR would certainly still work it has a few major drawbacks. Join the 21st century and start using GPT instead.
 
I like slices now that I know how to use them. But I do agree. GPT has zero pitfalls.
ada0p2 is so much easier to understand than ada0s2b

MBR does allow single partition installation whereas GPT needs freebsd-boot partition.
 
I think the question "what are you trying to accomplish" needs to be asked. I mean beyond how do I duplicate this.

Are you trying to UEFI boot?
Is the system dedicated to FreeBSD?
Is the system PC based or "other" (ARM, Mac, etc)?
How big is the device you are partitioning? There may be limitations around size.

GPT lets you label partitions which is very useful in your /etc/fstab and other places that reference partitions.
 
I am trying to setup for UBoot.
FreeBSD only.
Other X5000.
I believe it is an 128GB SSD.
I don't believe that I can use GPT, maybe some day.

In the end, I set it up on Mac G3 and now the system boots.
 
GPT lets you label partitions which is very useful in your /etc/fstab and other places that reference partitions.
Other partition types and schemes allow labels too. It's just that GPT is the tool to deal with its own labels. They need other tools for labeling.
 
Hey.

I am trying to setup for UBoot.
...
I don't believe that I can use GPT, maybe some day.
I don't know if the first sentence has any impact here, but normally *you should* be able to run GPT easily. Why do you say you don't believe you can use GPT?

I assume the steps you take for this setup is:
  1. copying the bootcode to the first 512B,
  2. adding the FAT16 slice (is it raw filesystem on the slice? Is this what U-Boot uses?),
  3. finally adding a BSD-scheme slice and putting your system partitions there.

So perhaps you could try creating a tiny PMBR partition with the gptbootcode.

If I'm reading the layout you've given correctly, perhaps try
# gpart create -s gpt ada0
# gpart add -t freebsd-boot -a 4K -s 512K -l pmbr ada0
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
# gpart add -t <type> -a 4K -s 128M -l uboot ada0 # is this the U-Boot partition? Not sure what type it uses? Is this raw FAT16 on slice 1?
# newfs_msdos -F 16 "<GEOM>p2" # may require some more parameters like -b, -c, -S
# gpart add -t freebsd-ufs -a 4K -l system ada0
# gpart create -s bsd ada0p3
# gpart add -t freebsd-ufs ... ada0p3
# gpart add -t freebsd-swap ... ada0p3
# gpart add -t freebsd-ufs ... ada0p3

I don't know the U-Boot specifics, as for example if it supports GPT and if its partition needs to be at the beginning of the GEOM provider (if yes, then you could still move the freebsd-ufs/pmbr partition behind it, changing the -i to '2' in the bootcode command), but this could work.

Overall, if U-Boot is not a problem, then it should totally be possible to use GPT. I am however not sure if it's worth it. For instance, I am quite certain you can't create a GPT scheme within another GPT scheme, so your BSD system slice under GPT would simply become a BSD partition.

In general, you may want to have a look at this article. I find it exceptionally informative and instructional - it has been incredibly helpful in my own tinkering with FreeBSD lately.
 
Top