Re: gpart: can not add MBR partitions with "gpart add -t, mbr"

From: Warren Block <wblock_at_wonkity.com>
Date: Sat, 22 Jun 2013 07:04:29 -0600 (MDT)
On Fri, 21 Jun 2013, Genre Roger wrote:

> When I refer to gpart(8) manpage (9.1 release, updated jan 25,2013), I find 
> the description of partition types a bit confusing.
>
> Considering the case of a MoBo with "old way" Bios (non UEFI), the only 
> scheme allowed to get a bootable system is MBR. (Note that after booting, 
> your OS is able to manage gpt-scheme on different providers.)

Sorry, I don't understand.  GPT boots fine on a BIOS system.  I'm using 
it on several systems.

> Then, if you speak "bsd-ish", you are able to add on the "MBR"-scheme 
> provider up to 4 "freebsd-type" slices, each of them containing up to 8 
> partitions with a BSD filesystem (or swap space).

Yes.  This is a partitions-inside-a-slice configuration, used for quite 
a while because it provides more partitions than MBR's four, and also 
because it allows a standard PC to multi-boot from any of the four MBR 
slices.  Technically, it's a hack.  It's complex and shows that both 
partitioning schemes (MBR and bsdlabel) have weaknesses.

> Or, if you speak "msdos-ish", you would be able to add on the "MBR" provider 
> up to 4 "msdos-type" partitions (or 3 + 1 extended ), each of them containing 
> one filesystem.
>
> The manpage does'nt list explicitly the type for this second case; Oliver try 
> to use "mbr", decribed as "A partition that is sub-partitioned by a Master 
> Boot Record (MBR). This type is known as 
> "!024dee41-33e7-11d3-9d69-0008c781f39f " by GPT.". Such definition is'nt very 
> explicit.

In general, it's rare to find a FreeBSD system that uses MBR slices 
directly because there are only four.  But it can be done by combining 
one or more of the standard filesystems and not subdividing the slices:

ada0s1: freebsd (/, /var, /tmp, and /usr combined into a single
                  / filesystem)
ada0s2: swap

That would leave s3 and s4 available for other uses.

> Let me show the example below on my provider ada0 :
>
>> $ gpart show
>> =>       63  976773105  ada0  MBR  (465G)
>>          63  136314864     1  freebsd  [active]  (65G)
>>   136314927  840458241        - free -  (400G)
>> 
>> =>        0  136314864  ada0s1  BSD  (65G)
>>           0    8388608       1  freebsd-ufs  (4.0G)
>>     8388608   16777216       2  freebsd-swap  (8.0G)
>>    25165824   16777216       4  freebsd-ufs  (8.0G)
>>    41943040    8388608       5  freebsd-ufs  (4.0G)
>>    50331648   85983215       6  freebsd-ufs  (41G)
>>   136314863          1          - free -  (512B)
>> 
>> $ sudo gpart add -t mbr -i 2 -s 8G ada0
>> Password:
>> gpart: Invalid argument

MBR is not a type of partition, it is a partitioning method or "scheme" 
as the gpart man page calls them.  The partitioning scheme is dictated 
by the type of system.  Standard x86 computers are only going to be able 
to use MBR or GPT.

>> $ sudo gpart add -t \!12 -i 2 -s 8G ada0
>> ada0s2 added

\!12 is just an MS-DOS partition (FAT32 with LBA).

>> $ sudo newfs_msdos ada0s2
>> /dev/ada0s2: 16773056 sectors in 262079 FAT32 clusters (32768 
>> bytes/cluster)
>> BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 
>> SecPerTrack=63 Heads=16 HiddenSecs=0 HugeSectors=16777215 FATsecs=2048 
>> RootCluster=2 FSInfo=1 Backup=2
>> $ sudo gpart add -t freebsd -i 3 -s 8G ada0
>> ada0s3 added
>> $ gpart show ada0
>> =>       63  976773105  ada0  MBR  (465G)
>>          63  136314864     1  freebsd  [active]  (65G)
>>   136314927   16777215     2  !12  (8G)
>>   153092142   16777215     3  freebsd  (8G)
>>   169869357  806903811        - free -  (384G)
>> $ sudo newfs_msdos ada0s3
>> /dev/ada0s3: 16773056 sectors in 262079 FAT32 clusters (32768 
>> bytes/cluster)
>> BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 
>> SecPerTrack=63 Heads=16 HiddenSecs=0 HugeSectors=16777215 FATsecs=2048 
>> RootCluster=2 FSInfo=1 Backup=2
>> $ 
> this example show that, if you want a "msdos" or "fat32" partition, both the 
> type "\!12" or "freebsd" allows you  to create a partition where you could 
> install a msdos filesystem (but the "mbr" does not).

It shows that MBR is a partitioning scheme, not a partition type.  It 
also demonstrates that newfs_msdos does not check the partition type of 
the partition on which it is creating a filesystem.  Neither does newfs. 
That is appropriate behavior.  The partition type is so that bootcode 
and other software that deals with partitions does not have to guess 
what is on a particular partition, but has it identified explicitly.

> Such behaviour is not surprising, (using freebsd-type to format as msdos 
> means you don't use the space allowed for labeling);

I don't understand what you are saying there.  Offhand, I can't think of 
any reason to misidentify a partition intentionally.

> but what is really the purpose of the listed "mbr"-type in the gpart(8) manpage?

MBR is a partitioning scheme, comparable to GPT but more limited.  APM 
is a partitioning scheme for PPC Macs, VTOC8 is a partitioning scheme 
for Sparc.

The partitioning scheme determines which types of partitions are 
allowed.  For MBR, there are lots of partition types for variations for 
MS-DOS (including type 12), one (really) for NTFS, one for FreeBSD:
http://en.wikipedia.org/wiki/Partition_type
Received on Sat Jun 22 2013 - 11:04:31 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:38 UTC