Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 May 2010 19:05:04 +0100
From:      Christopher Key <cjk32@cam.ac.uk>
To:        Jon Theil Nielsen <jontheil@gmail.com>
Cc:        User Questions <freebsd-questions@freebsd.org>
Subject:   Re: More than 8 partitions
Message-ID:  <4BDDBED0.7040504@cam.ac.uk>
In-Reply-To: <q2s8f82c35c1005011910w1ad4792ehd90f38d3a8883519@mail.gmail.com>
References:  <y2z8f82c35c1004301044pd7168618qa23eb66438350a5d@mail.gmail.com> <4BDC794B.2060009@cam.ac.uk> <q2s8f82c35c1005011910w1ad4792ehd90f38d3a8883519@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Jon Theil Nielsen wrote:
> 2010/5/1 Christopher Key <cjk32@cam.ac.uk>
>
>   
>> Jon Theil Nielsen wrote:
>>     
>>> Hi
>>>
>>> I'm running 8.0-Release on an external usb hard drive. and have dual-boot
>>> with FreeBSD on da0s2 and Windows XP on da0s1. I made a setup via
>>>       
>> Sysinstall
>>     
>>> with 7 partitions:
>>>
>>> /dev/da0s2a on / (ufs, local)
>>> /dev/da0s2b (swap)
>>> /dev/da0s2d on /var (ufs, local, soft-updates)
>>> /dev/da0s2e on /tmp (ufs, local, soft-updates)
>>> /dev/da0s2f on /usr (ufs, local, soft-updates)
>>> /dev/da0s2h on /var/log (ufs, local, soft-updates)
>>> /dev/da0s2g on /home (ufs, local, soft-updates)
>>>
>>> I have about 660 GB left unused on da0s2 that I would like to use for
>>> backups. But I can't figure out how to create one more partition.
>>> If i create a file for bsdlabel like
>>>
>>> #       size    offset  fstype
>>> i:      *       0       4.2BSD
>>>
>>> I get the following error message: "line 2: partition name out of range
>>>       
>> a-h:
>>     
>>> i"
>>> I have also tried with gpart:
>>>
>>> gpart add -s 500G -t freebsd -f x da0s2
>>>
>>> I get something like "gpart: index '9': No space left on device"
>>>
>>> I thought that 8.0 should support more than 8 partitions. Maybe it does,
>>>       
>> but
>>     
>>> then I don't know how to do.
>>> Any ideas?
>>>
>>>
>>>       
>> I believe that FreeBSD does support more than 8 partitions on a disk
>> (apparently up to 20 using gpart), but that you need sufficient entries
>> for these partitions to be created in the disklabel, viz.
>>
>> gpart create -n 20 ...
>>
>> Some testing seems to indicate that you can manually override this by
>> changing by byte 0x28a of the disk from 0x08 to 0x14, and that bsdlabel
>> / gpart will then allow you to create further partitions on the disk.
>>
>>
>>
>> Kind regards,
>>
>> Christopher Key
>>     
>
>
> Thanks Christopher
>
> I am not sure if I understand all of if. And I wouldn't like to wipe the
> drive to test if is possible to "mass produce" partitions like that. Could
> be useful in another situation, though.
>
> My knowlodge of GEOM and its utilities is very limited. Since I have
> succeded in creating the two slices with fdisk and subsequently populate
> them with bsdlabel, my only problem is how to create the last partition from
> the unpartioned space on da0s2. As mentioned in the beginning of this post,
> I have tried with both bsdlabel (from a file) and by issuing the gpart add
> command. With no luck. Would it be any help to give more specific about the
> drive/slice? The output of df -h | grep dev/da0 is:
>
> /dev/da0s2a   3.9G   630M    2.9G    17%    /
> /dev/da0s2g    97G   160K     89G     0%    /home
> /dev/da0s2e   3.9G   129M    3.4G     4%    /tmp
> /dev/da0s2f    48G   6.6G     38G    15%    /usr
> /dev/da0s2d   9.7G   151M    8.8G     2%    /var
> /dev/da0s2h   3.9G   1.5M    3.6G     0%    /var/log
>
> and of gpart show da0:
>
> =>         0  1759551255  da0s2  BSD  (839G)
>            0     1048576         - free -  (512M)
>      1048576     8318064      2  freebsd-swap  (4.0G)
>      9366640     7303168         - free -  (3.5G)
>     16669808     8388608      1  freebsd-ufs  (4.0G)
>     25058416    20971520      4  freebsd-ufs  (10G)
>     46029936     8388608      5  freebsd-ufs  (4.0G)
>     54418544   104857600      6  freebsd-ufs  (50G)
>    159276144   209715200      7  freebsd-ufs  (100G)
>    936891344     8388608      8  freebsd-ufs  (4.0G)
>    377379952  1382171303         - free -  (659G)
>
> and, finaly, of bsdlabel da0s2:
>
> # /dev/da0s2:
> 8 partitions:
> #        size     offset    fstype   [fsize bsize bps/cpg]
> a:    8388608   16669808    4.2BSD        0     0     0
> b:    8318064    1048576      swap
> c: 1759551255          0    unused        0     0         # "raw" part,
> don't edit
> d:   20971520   25058416    4.2BSD        0     0     0
> e:    8388608   46029936    4.2BSD        0     0     0
> f:  104857600   54418544    4.2BSD        0     0     0
> g:  209715200  159276144    4.2BSD        0     0     0
> h:    8388608  368991344    4.2BSD        0     0     0
>
> In my desparate effort to understand these informations/data, i have put
> them into a spreadsheet and rearranged them - including some of my own
> calculations and assumptions.
>
> bsdlabel output - sorted by sector offset:
>
> #            size       offset  (GB*)
> c   1.759.551.255            0    839
> b       8.318.064    1.048.576      4
> a       8.388.608   16.669.808      4
> d      20.971.520   25.058.416     10
> e       8.388.608   46.029.936      4
> f     104.857.600   54.418.544     50
> g     209.715.200  159.276.144    100
> h       8.388.608  368.991.344      4
>
> gpart show output - sorted by sector offset:
>
> (#)         (size)    (offset)   (GB)      (offset*)   (GiB*)    (i)
>         1.048.576            0    0,5              0        1   free
>  b      8.318.064    1.048.576      4      1.048.576        4      2
>         7.303.168    9.366.640    3,5      9.366.640        3   free
>  a      8.388.608   16.669.808      4     16.669.808        4      1
>  d     20.971.520   25.058.416     10     25.058.416       10      4
>  e      8.388.608   46.029.936      4     46.029.936        4      5
>  f    104.857.600   54.418.544     50     46.029.936       50      6
>  g    209.715.200  159.276.144    100    159.276.144      100      7
>     1.382.171.303  377.379.952    659    368.991.344      659   free
>  h      8.388.608  936.891.344      4  1.759.551.255        4      8
>
> In the first place, I wondered why gpart would not let me add anoter
> partiotion. There *should *be lots of free space left. But on closer
> inspection, it seems that the 659 somehow is '"squezzed'" in. Don't really
> know what all this is about. Allthough this might be a vaste of time, since
> I kan copy, reslice/repartition and copy back, any more comments are
> welcome.
>
> Regards,
>   
I'm not very familiar with geom either, so my apologies if the
terminology / detail is incorrect.

I think that there are two issues at work here:

Firstly, the size of the partition table.  At the start of the da0s2
there is a header, with a entries for partition information, i.e.
offset, size, type etc.  There are a fixed number of entries (8 are
created by default), and as you create partitions, each of these entries
gets used up.  The error message "gpart: index '9': No space left on
device", is a little bit misleading.  It is reporting that all 8 entries
have been used, and that there is nowhere to store the metadata for a
9th partition.  Incidentally, the error message indicating that the
desired partition wouldn't fit anywhere on the disk would have been
"gpart: autofill: No space left on device"

There are two ways round this.  The first, only available when you are
starting from scratch, is to pass "-n 20" to "gpart create", which
instructs it to create 20 entries for partitions.  The second, somewhat
dubious method, is to manually edit this header, creating extra
entries.  By changing byte 0x28a of the disk from 0x08 to 0x14, you are
effectively creating an extra 12 entries, which can then be used for
partitions.  This is a bit dangerous, as the extra 12 entries created
haven't been initialised with any data.  On a new, blank disk, freebsd
appears to interpret the blank entry as meaning 'no partition defined',
but I wouldn't want to guarantee this behaviour.

It's possible that there are also other complications that I'm unaware
of.  Nevertheless, if you're prepared to rebuild the system anyway, I'd
recommend giving it a try.  Firstly, get a copy of the first 1024 bytes
of the slice:

dd if=/dev/da0s2 of=/tmp/hdr count=2

Next, edit byte 0x28a (650) of this file, changing it from 0x08 to 0x14
(or if you know that you only want to add one extra partition then 0x09
might be safer).  editors/hexedit will probably do what you need, or
alternatively transfer the file to a Windows box and use something like
frhed.  Next write the data back to the disk:

dd if=/tmp/hdr of=/dev/da0s2

You should now find that gpart add will work.

The second issue at hand is the fact that the free space is in the
middle of the disk, with partition h following it.  I don't know why the
disk has ended up like this, but some testing suggests that gpart knows
how to deal with this correctly.


I hope this helps to explain whats going on.

Kind regards,

Christopher Key.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BDDBED0.7040504>