[DEPRECATED] FreeBSD [GUID] GPT howto
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
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:
You'll need (or other media):
FreeBSD 7.1R DVD or FreeBSD-7.1R fixit cd
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]
Copy necessary data
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
Once you have copied these files to some where, where you can get them, reboot in fixit mode [use cd]
Creating GUID partition tables
1) Erase MBR and write GPT table
$ gpt create -f ad0
2) Mount flash to /mnt
3) Create gpt boot partition
$ gpt boot -b /mnt/pmbr -g /mnt/gptboot ad0
value behind argument -s must be size in sectors
1 sector is 512B
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]
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)
$ gpt add -t ufs -s 268435456 ad0
$ gpt show ad0
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
Partitions that you already have created are accessible as
/dev/ad0p1 and /dev/ad0p2
6) Create more partitions /usr (4GB) and /var (512MB) and /tmp (512MB)
$ gpt add -t ufs -s 10485760 ad0 $ gpt add -t ufs -s 1048576 ad0 $ gpt add -t ufs -s 1048576 ad0
$ gpt add -t swap -s 1048576 ad0
$ gpt add -t ufs ad0
$ newfs -nL root /dev/ad0p2 $ newfs -nUL usr /dev/ad0p3 $ newfs -nUL var /dev/ad0p4 $ newfs -nUL tmp /dev/ad0p5
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
/dev/ufs/root / ufs rw 1 1
when you create partition without using -i key, which is used to change partition NR, GPT will start with 1 and increment automatically.
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
Note also that you don't need to create bsdlabels anymore
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
options GEOM_PART_GPT # GUID Partition Tables.
common partition size cheat sheet
sector count = 1024^2/512*MB_count
sector count = 1024^3/512*GB_count
8KB = 16 sectors
32KB = 64 sect
64KB = 128 sect
256MB = 524288 sect
512MB = 1048576 sect
1GB = 2097152 sect
2GB = 4194304 sect
5GB = 10485760 sect
10GB = 20971520 sect
If there's anything unclear please ask, i will answer and explain
made few inaccuracy fixes
Last edited by graudeejs; 19th December 2010 at 07:14 PM.
Thanks for this I used this a long time ago and never said thankyou.
I have recently moved to Freebsd 8.1 and moved my 2.7TB array with it, but after a blackout it became only accessible in mount only. Previously if I had a power failure in 7.1 I could just clean it with fsck_ffs, but not this time, I have had to recreate it from scratch.
This wouldn't be a problem, except that after installing gpt on 8.1 I can't run it, and it isn't found by whereis.
Do you know of any issues with gpt and 8.1?
I have been trying gpart also, but when I create a 'freebsd-ufs' type partition as below:
# gpart create -s gpt da2 # gpart add -t freebsd-ufs da2 # gpart show => 34 5859704765 da2 GPT (2.7T) 34 5859704765 1 freebsd-ufs (2.7T)
# mount /dev/da2s1 /media mount: /dev/da2s1 : Operation not permitted
Last edited by ghostcorps; 19th December 2010 at 11:58 PM.
If you have only 1 partition, you can format entire drive with ufs
# newfs -U /dev/da2
as for mounting... it looks like you're not mounting as root
I definitely have root, I spend far too much time in root if anything
When I run the newfs command you gave me I get this:
# newfs -L media -U /dev/da2 newfs: /dev/da2: failed to open disk for writing
Thanks for sticking with me
Still no love
Is there any chance it is a hardware issue perhaps?
# whoami root
# ls /dev/da2* /dev/da2
# df -h Filesystem Size Used Avail Capacity Mounted on /dev/da1s1a 7.7G 402M 6.7G 6% / devfs 1.0K 1.0K 0B 100% /dev /dev/da1s1e 989M 214K 910M 0% /tmp /dev/da1s1f 42G 8.6G 30G 22% /usr /dev/da1s1d 7.7G 439M 6.7G 6% /var /dev/da0s1a 496M 199M 257M 44% /7.0 /dev/da0s1f 9.5G 2.7G 6.0G 32% /7.0/usr
# gpart show => 63 143374644 da0 MBR (68G) 63 143363997 1 freebsd (68G) 143364060 10647 - free - (5.2M) => 63 143374644 da1 MBR (68G) 63 143363997 1 freebsd [active] (68G) 143364060 10647 - free - (5.2M) => 0 143363997 da0s1 BSD (68G) 0 1048576 1 freebsd-ufs (512M) 1048576 8388608 2 freebsd-swap (4.0G) 9437184 10450944 4 freebsd-ufs (5.0G) 19888128 1048576 5 freebsd-ufs (512M) 20936704 20480000 6 freebsd-ufs (9.8G) 41416704 101947293 - free - (49G) => 0 143363997 da1s1 BSD (68G) 0 16777216 1 freebsd-ufs (8.0G) 16777216 16777216 2 freebsd-swap (8.0G) 33554432 16777216 4 freebsd-ufs (8.0G) 50331648 2097152 5 freebsd-ufs (1.0G) 52428800 90935197 6 freebsd-ufs (43G)
# dd if=/dev/zero of=/dev/da2 count=2 dd: /dev/da2: Operation not permitted
# newfs -L media -U /dev/da2 newfs: /dev/da2: failed to open disk for writing
# fdisk /dev/da2 ******* Working on device /dev/da2 ******* parameters extracted from in-core disklabel are: cylinders=364749 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=364749 heads=255 sectors/track=63 (16065 blks/cyl) fdisk: invalid fdisk partition table found 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 1564730937 (764028 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 119/ 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>
bsd# fsck_ffs /dev/da2 ** /dev/da2 (NO WRITE) Cannot find file system superblock ioctl (GCINFO): Inappropriate ioctl for device fsck_ffs: /dev/da2: can't read disk label
Last edited by ghostcorps; 20th December 2010 at 10:50 PM.
I'm kinda glad it wasn't just me...
Did I mention that I destroyed and recreated the array in the RAID controllers BIOS also?!
So, I just got a reply from Highpoint, turns out their RAID management software doesn't work with 8.1, only upto 8.0 They said to wait a few months! lol
From what I can tell, that means that the array is not able to be initialised, hence not actually built completely.
I have created a JBOD array instead, and will see how that turns out.
Thanks again for your time, I'll let you know how the JBOD turns out.
|Thread||Thread Starter||Forum||Replies||Last Post|
|HOWTO: FreeBSD CPU Scaling with cpufreq.ko||vermaden||Guides||10||27th October 2010 07:58 AM|
|HOWTO: Enemy Territory on FreeBSD||tangram||Guides||0||9th June 2009 03:31 PM|
|HOWTO: QEMU on FreeBSD||vermaden||Guides||10||9th March 2009 07:10 PM|
|FreeBSD howto: burning and ripping cd's||graudeejs||Guides||9||31st December 2008 06:39 AM|
|HOWTO: FreeBSD with CCACHE||vermaden||Guides||10||9th July 2008 06:14 PM|