[DEPRECATED] [GUID] GPT howto

Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated.

[DEPRECATED] [GUID] GPT howto

Postby graudeejs » 05 Jan 2009, 22:04

[color="Red"][SIZE="5"]DEPRECATED: use [man=8]gpart[/man] instead[/SIZE][/color]


The next hot thing after 7.1R is GPT
old limit of 4 partitions is finally history
with GUID Partition table you can have up to 128 partitions.
Should i also say, that GPT will easily handle partitions over 2TB :D
MBR had problems with that ;)

As soon as i heard [thanks to nsayers post]that it's possible to boot FreeBSD from GPT i had to test it

I have encountered some problems that i resolved on my own.
That's why i'm making this howto, so you don't have to spend few hours, just because something went wrong.

OK, here we go:
=================================
[color="Red"][SIZE="5"]Preparing:[/SIZE][/color]

You'll need (or other media):
usb-flash
FreeBSD 7.1R DVD or FreeBSD-7.1R fixit cd

[color="Red"][SIZE="5"]Backup data[/SIZE][/color]

During process we will delete all data on HDD, so
backup your valuable data and system, if you already have 7.1R on your PC

If you don't you need to upgrade your system to 7.1 [dunno if GPT works with 6.4]
before and after upgrading backup all data

I suggest you use GENERIC kernel, if you won't have right option, you can create system on GPT, but you can't boot it [another my fallback]


[color="Red"][SIZE="5"]Copy necessary data[/SIZE][/color]
You need to make copy of /boot/pmbr and /boot/gptboot
because they are not on disks and this was my fallback nr1

You will need these files later.
I will copy them to my usb-flash :D

Once you have copied these files to some where, where you can get them, reboot in fixit mode [use cd]


[color="Red"][SIZE="5"]Creating GUID partition tables[/SIZE][/color]

1) Erase MBR and write GPT table
Code: Select all
$ gpt create -f ad0

You don't need to specify full path to device :D

2) Mount flash to /mnt

3) Create gpt boot partition
Code: Select all
$ gpt boot -b /mnt/pmbr -g /mnt/gptboot ad0

by default this will create 64K partition, you can change this with -s and reduce to minimum (8K)
value behind argument -s must be size in sectors
[color="SeaGreen"]1 sector is 512B[/color]
[SIZE="1"]I suggest no changing it, who know if in 7.2 size might change
Also don't improvise to much, make sure boot partition is Nr 1 and root partition is Nr 2, otherwise you can't boot at all [another my fallback][/SIZE]

Note that when i say boot partition it doesn't mean /boot, it's different. /boot is in same partition as root

4) Create root partition (i'll make 256MB)
Code: Select all
$ gpt add -t ufs -s 524288 ad0


5) To check what have you done
Code: Select all
$ gpt show ad0


here's example output from one of my [already finished] test setup
Code: Select all
fixit# gpt show ad0
      start        size  index     content
          0           1            PMBR
          1           1            Pri GPT header
          2          32            Pri GPT table
         34         128      1     GPT part - FreeBSD boot
        162     1048576      2     GPT part - FreeBSD UFS/UFS2
    1048738     2097152      3     GPT part - FreeBSD UFS/UFS2
    3145890     2097152      5     GPT part - FreeBSD UFS/UFS2
    5243042     1048576      6     GPT part - FreeBSD UFS/UFS2
   16777378     6291456      7     GPT part - FreeBSD UFS/UFS2
   23068834   168926701     11     GPT part - FreeBSD UFS/UFS2
  191995535    10485760     10     GPT part - FreeBSD UFS/UFS2
  202401295   109051904      9     GPT part - FreeBSD UFS/UFS2
  311533199     1048576      8     GPT part - FreeBSD swap
  312581775          32            Sec GPT table
  312581807           1            Sec GPT header

[SIZE="1"]in this table might be mistakes [writing by hand sux], later i made better lay-out[/SIZE]



Partitions that you already have created are accessible as
/dev/ad0[color="Red"]p1[/color] and /dev/ad0[color="Red"]p2[/color]

6) Create more partitions /usr (5GB) and /var (512MB) and /tmp (512MB)
Code: Select all
$ gpt add -t ufs -s 10485760 ad0
$ gpt add -t ufs -s 1048576 ad0
$ gpt add -t ufs -s 1048576 ad0


7) Create 512MB swap
Code: Select all
$ gpt add -t swap -s 1048576 ad0


8) Create home partition with remaining free space
Code: Select all
$ gpt add -t ufs ad0


9) Format partitions
Code: Select all
$ newfs -nL root /dev/ad0p2
$ newfs -nUL usr /dev/ad0p3
$ newfs -nUL var /dev/ad0p4
$ newfs -nUL tmp /dev/ad0p5

I like labeling partitions, because i don't need to edit /etc/fstab each time something changes
It's also easier to track partitions if you got many of them

10) Mount root and run restore, then mount and restore usr, var and home.

After you're done, if you didn't use labels edit /etc/fstab
remember labels are placed in /dev/ufs/ directory

so for root it would look something like
Code: Select all
/dev/ufs/root     /      ufs      rw    1 1

you need to edit your swap entry in fstab
[SIZE="1"]when you create partition without using -i key, which is used to change partition NR, GPT will start with 1 and increment automatically.
[/SIZE]
so in this example swap will be /dev/ad0p5
and /home will be /dev/ad0p6

After you're done you can unmount partitions and reboot system.
It should boot with GENERIC.
If not, post here, I can resolve problems... like i did when i had to on my PC

[SIZE="1"]Note also that you don't need to create bsdlabels anymore[/SIZE]

TIP: it's also very easy to set up swap on most outer tracks of HDD ;) if you're interested in this look at -b parameter in manual

kernel options [make sure you have this in kernel config
Code: Select all
options         GEOM_PART_GPT           # GUID Partition Tables.

For some reason, when i had all GEOM_PART_* in my kernel config i couldn't boot



[SIZE="1"]common partition size cheat sheet
for megabytes:
sector count = 1024^2/512*MB_count
for gigabytes:
sector count = 1024^3/512*GB_count
==========
8KB = 16 sectors
[color="Sienna"]32KB = 64 sect[/color]
64KB = 128 sect
[color="Sienna"]256MB = 524288 sect[/color]
512MB = 1048576 sect

1GB = 2097152 sect
[color="Sienna"]2GB = 4194304 sect[/color]
3GB = 6291456 sect
[color="Sienna"]4GB = 8388608 sect[/color]
5GB = 10485760 sect
[color="Sienna"]6GB = 12582912 sect[/color]
7GB = 14680064 sect
[color="Sienna"]8GB = 16777216 sect[/color]
9GB = 18874368 sect

12GB = 25165824 sect
[color="Sienna"]14GB = 29360128 sect[/color]
15GB = 31457280 sect
[color="Sienna"]25GB = 52428800 sect[/color]
[/SIZE]

tip: 10GB can easily be calculated by adding 0 to 1GB sector count (this works for others as well ;) )


If there's anything unclear please ask, i will answer and explain

[SIZE="5"][color="Red"]resources:[/color][/SIZE]
[man=8]gpt[/man]


EDIT:
made few inaccuracy fixes

[color="Red"]
EDIT:
Important note[/color]
you you're adding gpt on top of geli and and used -s 4096 key, when you created geli, then
you will have to use these formulas:
for megabytes:
sector count = 1024^2/4096*MB_count
for gigabytes:
sector count = 1024^3/4096*GB_count

replace 4096 to value you have used

if you won't do that, you will get 32GB instead of 6GB partition



EDIT
if you want to do new install on gpt, create gpt partitions and fallow this guide:
http://daemonforums.org/showthread.php?t=1538
User avatar
graudeejs
Style(9) Addict
 
Posts: 4591
Joined: 16 Nov 2008, 23:23
Location: Riga, Latvia

Postby nsayer » 09 Jan 2009, 00:06

I would put your swap space adjacent to your boot partition. There are some very good reasons to do this:

1. By putting the swap near the beginning of the disk, it will boost its performance somewhat compared to it being at the end of the disk.

2. If you ever need to replace the boot partition (for example, if you move to an EFI machine, you'll need an EFI system partition instead), you'd simply delete the boot and swap partitions, make the new boot and then from the remaining space, make a swap partition.
User avatar
nsayer
Junior Member
 
Posts: 51
Joined: 29 Dec 2008, 19:17

Postby graudeejs » 09 Jan 2009, 01:09

Beginning of the disk is in center, isn't it (inner track/cylinder)? [i'm not sure]

for data cd/dvd it is, so my guess would be it's also same for HDD
and if I'm right, and i hope I am, my swap is in outer track/cylinder of HDD
User avatar
graudeejs
Style(9) Addict
 
Posts: 4591
Joined: 16 Nov 2008, 23:23
Location: Riga, Latvia

Postby nsayer » 12 Jan 2009, 04:47

Seeks are the costly thing, regardless of whether block 0 is on the inside or outside of the disk. If you put the swap at the end of the disk, then you're setting up a situation where the machine is going to need to fiddle with lots of files from filesystems on the early blocks on the disk, and swap blocks in and out of swap space at the end of the disk. Lots of long seeks. Bad mojo.
User avatar
nsayer
Junior Member
 
Posts: 51
Joined: 29 Dec 2008, 19:17

Postby trev » 16 Jan 2009, 10:46

Copy necessary data
You need to make copy of /boot/pmbr and /boot/pmbr [1] because there [2] are not on disks and this was my fallback nr1


1. The same file?
2. "they" ?
trev
Member
 
Posts: 354
Joined: 31 Dec 2008, 06:41

Postby graudeejs » 16 Jan 2009, 11:06

trev wrote:1. The same file?
2. "they" ?


Thank you for noticing, I fixed my mistake [it was about 2 or 3 am when i wrote this :) ]
Code: Select all
You need to make copy of [B]/boot/pmbr[/B] and [B][color="Red"]/boot/gptboot[/color][/B]
because [color="Red"][B]they[/B][/color] are not on disks and this was my fallback nr1
User avatar
graudeejs
Style(9) Addict
 
Posts: 4591
Joined: 16 Nov 2008, 23:23
Location: Riga, Latvia

Postby trash » 12 Oct 2009, 23:44

anyone know how to fix corrupt gpt tables when migrating from solaris ?
trash
Junior Member
 
Posts: 15
Joined: 12 Oct 2009, 04:07

Postby graudeejs » 13 Oct 2009, 06:24

sorry, i dunno
but search forum, I remember there was 1 or 2 threads about this problem.
User avatar
graudeejs
Style(9) Addict
 
Posts: 4591
Joined: 16 Nov 2008, 23:23
Location: Riga, Latvia

Postby trash » 13 Oct 2009, 14:18

hi, thanks for the reply, yes ive also added my question to those threads, at least i think ive found all of them - almost asked the entire internet the question now :)
trash
Junior Member
 
Posts: 15
Joined: 12 Oct 2009, 04:07

Postby graudeejs » 05 Dec 2009, 22:05

To all looking at this howto.... ;) yup, i saw you bluefish....
This is abit outdates. on FreeBSD 8 you need to use gpart for makeing gpt partitions... gpt is removed :D
User avatar
graudeejs
Style(9) Addict
 
Posts: 4591
Joined: 16 Nov 2008, 23:23
Location: Riga, Latvia


Return to Howtos & FAQs (Moderated)

Who is online

Users browsing this forum: No registered users and 0 guests