DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 5th January 2009
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Post [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:
=================================
Preparing:

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

Backup data

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
Code:
$ gpt create -f ad0
You don't need to specify full path to device

2) Mount flash to /mnt

3) Create gpt boot partition
Code:
$ 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
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)
Code:
$ gpt add -t ufs -s 268435456 ad0
5) To check what have you done
Code:
$ gpt show ad0
here's example output from one of my [already finished] test setup
Code:
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
in this table might be mistakes [writing by hand sux], later i made better lay-out



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)
Code:
$ 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:
$ gpt add -t swap -s 1048576 ad0
8) Create home partition with remaining free space
Code:
$ gpt add -t ufs ad0
9) Format partitions
Code:
$ 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:
/dev/ufs/root     /      ufs      rw    1 1
you need to edit your swap entry in fstab
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
Code:
options         GEOM_PART_GPT           # GUID Partition Tables.
For some reason, when i had all GEOM_PART_* in my kernel config i couldn't boot



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
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

resources:
man gpt


EDIT:
made few inaccuracy fixes


Original thread
https://forums.freebsd.org/showthread.php?t=1305

Last edited by graudeejs; 19th December 2010 at 07:14 PM.
Reply With Quote
  #2   (View Single Post)  
Old 19th December 2010
ghostcorps ghostcorps is offline
New User
 
Join Date: Nov 2010
Posts: 8
Thanked 0 Times in 0 Posts
Default

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?


Thanks again
Reply With Quote
  #3   (View Single Post)  
Old 19th December 2010
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Default

gpt is deprecated... use gpart
Reply With Quote
  #4   (View Single Post)  
Old 19th December 2010
ghostcorps ghostcorps is offline
New User
 
Join Date: Nov 2010
Posts: 8
Thanked 0 Times in 0 Posts
Default

Thanks

I have been trying gpart also, but when I create a 'freebsd-ufs' type partition as below:

Code:
# 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)
it doesn't mount:

Code:
# mount /dev/da2s1 /media
mount: /dev/da2s1 : Operation not permitted
even with -t ufs... Obviously I am doing something wrong, but I havn't figured it out yet.

Last edited by ghostcorps; 19th December 2010 at 11:58 PM.
Reply With Quote
  #5   (View Single Post)  
Old 20th December 2010
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Default

If you have only 1 partition, you can format entire drive with ufs
Code:
# newfs -U /dev/da2
I suggest using labels (for example adding -L data) and then you can mount disk from /dev/ufs/data

as for mounting... it looks like you're not mounting as root
Reply With Quote
  #6   (View Single Post)  
Old 20th December 2010
ghostcorps ghostcorps is offline
New User
 
Join Date: Nov 2010
Posts: 8
Thanked 0 Times in 0 Posts
Default

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:

Code:
# newfs -L media -U /dev/da2
newfs: /dev/da2: failed to open disk for writing
I have triple checked that it is not already mounted somehow. Am I being daft by not being in single user mode perhaps?


Thanks for sticking with me
Reply With Quote
  #7   (View Single Post)  
Old 20th December 2010
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Default

ahhh, maybe you have partitions on it
if so delete partitions and destroy gpt
then format it

show output of gpart show and ls /dev/da2*
Reply With Quote
  #8   (View Single Post)  
Old 20th December 2010
ghostcorps ghostcorps is offline
New User
 
Join Date: Nov 2010
Posts: 8
Thanked 0 Times in 0 Posts
Default

Still no love


Is there any chance it is a hardware issue perhaps?

Code:
# whoami
root
Code:
# ls /dev/da2*
/dev/da2
Code:
# 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
Code:
# 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)
Code:
# dd if=/dev/zero of=/dev/da2 count=2
dd: /dev/da2: Operation not permitted
Code:
# newfs -L media -U /dev/da2
newfs: /dev/da2: failed to open disk for writing

Code:
# 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>
Code:
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.
Reply With Quote
  #9   (View Single Post)  
Old 20th December 2010
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Default

I've no idea what the hell.
Try disconnect and reconnect the drive and see if anything changes.
Reply With Quote
Old 21st December 2010
ghostcorps ghostcorps is offline
New User
 
Join Date: Nov 2010
Posts: 8
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
Old 21st December 2010
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
formerly killasmurf86
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 588
Thanked 29 Times in 26 Posts
Default

OK, but let's stick to one forum (forums.freebsd.org preffered)
http://forums.freebsd.org/showthread.php?t=20038
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT. The time now is 02:14 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick