8

All of the tools I've tried until now were only capable to create a dual (GPT & MBR) partition table, where the first 4 of the GPT partitions were mirrored to a compatible MBR partition.

This is not what I want. I want a pure GPT partition table, i.e. where there isn't MBR table on the disk, and thus there isn't also any synchronizing between them.

Is it somehow possible?

14
  • 2
    This is how all partitioning tools work already. If you want a hybrid you have to use gptsync to mirror some of the GPT partitions in the MBR table.
    – psusi
    Commented Jul 11, 2015 at 22:44
  • 1
    No, you completely misunderstood my comment. You don't get a hybrid table unless you go out of your way to construct one.
    – psusi
    Commented Jul 11, 2015 at 23:18
  • 6
    To any comers: this question should not be closed. Whether or not it reflects a general misunderstanding on behalf of the asker is not the point - it is a very good question, and if the asker was confused in asking, then, well, that's probably why it needed asking in the first place. In any case, the question is on a seldom understood topic, and it is, as I now understand it, a very representative example of same.
    – mikeserv
    Commented Jul 11, 2015 at 23:24
  • 1
    @peterh - any GPT-aware application should have no problem whatsoever understanding a GPT-disk whether or not its Protective MBR has been removed or altered. A hybrid-MBR only works at all because that is the case - the Protective MBR is intended to warn away non-GPT-aware applications, and serves no other purpose at all. The problem with both of these, though, is that non-GPT-aware applications might wind up writing over parts of the disk which appear to be unallocated to them.
    – mikeserv
    Commented Jul 11, 2015 at 23:32
  • 2
    There is no such thing as an EFI BIOS. There is such a thing as a CSM (compatibility support module) which can sometimes contain a BIOS-emulating boot module within an EFI, but these are usually no better than hacks as well.
    – mikeserv
    Commented Jul 11, 2015 at 23:37

2 Answers 2

14

TO ADDRESS YOUR EDIT:

I didn't notice the edit to your question until just now. As written now, the question is altogether different than when I first answered it. The mirror you describe is not in the spec, actually, as it is instead a rather dangerous and ugly hack known as a hybrid-MBR partition format. This question makes a lot more sense now - it's not silly at all, in fact.

The primary difference between a GPT disk and a hybrid MBR disk is that a GPT's MBR will describe the entire disk as a single MBR partition, while a hybrid MBR will attempt to hedge for (extremely ugly) compatibility's sake and describe only the area covered by the first four partitions. The problem with that situation is the hybrid-MBR's attempts at compatibility completely defeat the purpose of GPT's Protective MBR in the first place.

As noted below, the Protective MBR is supposed to protect a GPT-disk from stupid applications, but if some of the disk appears to be unallocated to those, all bets are off. Don't use a hybrid-MBR if it can be at all helped - which, if on a Mac, means don't use the default Bootcamp configuration.

In general, if looking for advice on EFI/GPT-related matters go nowhere else (excepting maybe a slight detour here first) but to rodsbooks.com.


ahem...

This (used to be) kind of a silly question - I think you're asking how to partition a GPT disk without a Protective MBR. The answer to that question is you cannot - because the GPT is a disk partition table format standard, and that standard specifies a protective MBR positioned at the head of the disk. See?

enter image description here

What you can do is erase the MBR or overwrite it - it won't prevent most GPT-aware applications from accessing the partition data anyway, but the reason it is included in the specification is to prevent non-GPT-aware applications from screwing with the partition-table. It prevents this by just reporting that the entire disk is a single MBR-type partition already, and nobody should try writing a filesystem to it because it is already allocated space. Removing the MBR removes that protection.

In any case, here's how:

  • This creates a 4G ./img file full of NULs...

    </dev/zero >./img \
    dd ibs=4k obs=4kx1k count=1kx1k
    

    1048576+0 records in
    1024+0 records out
    4294967296 bytes (4.3 GB) copied, 3.38218 s, 1.3 GB/s
    
  • This writes a partition table to it - to include the leading Protective MBR.

    • Each of printf's arguments is followed by a \newline and written to gdisk's stdin.
    • gdisk interprets the commands as though they were typed at it interactively and acts accordingly, to create two GPT partition entries in the GUID Partition Table it writes to the head of our ./img file.
    • All terminal output is dumped to >/dev/null (because it's a lot and we'll be having a look at the results presently anyway).

      printf %s\\n o y n 1 '' +750M ef00 \
                       n 2 '' '' '' ''   \
                   w y | >/dev/null      \
      gdisk ./img      
      
  • This gets pr's four-columned formatted representation of the offset-accompanied strings in the first 2K of ./img.

    <./img dd count=4 |
    strings -1 -td    | 
    pr -w100   -t4
    

    4+0 records in
    4+0 records out
    2048 bytes (2.0 kB) copied, 7.1933e-05 s, 28.5 MB/s
    

        451 *           1033 K           1094 t           1212 n
        510 U           1037 >           1096 e           1214 u
        512 EFI PART    1039 ;@fY        1098 m           1216 x
        524 \           1044 30          1153 =           1218
        529 P           1047 L           1158 rG          1220 f
        531 (           1050 E           1161 y=i         1222 i
        552 "           1065 w           1165 G}          1224 l
        568 V           1080 E           1170 $U.b        1226 e
        573 G           1082 F           1175 N           1228 s
        575 G           1084 I           1178 C           1230 y
        577 y           1086             1180 b           1232 s
        583 G           1088 S           1185 x           1234 t
        602 Ml          1090 y           1208 L           1236 e
       1024 (s*         1092 s           1210 i           1238 m
    

You can see where the MBR ends there, yeah? Byte 512.

  • This writes 512 spaces over the first 512 bytes in ./img.

    <>./img >&0 printf %0512s
    

And now for the fruits of our labor.

  • This is an interactive run of gdisk on ./img.

    gdisk ./img
    

    GPT fdisk (gdisk) version 1.0.0
    
    Partition table scan:
      MBR: not present
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with corrupt MBR; using GPT and will write new
    protective MBR on save.
    

    Command (? for help): p
    

    Disk ./img: 8388608 sectors, 4.0 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): 0528394A-9A2C-423B-9FDE-592CB74B17B3
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 8388574
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2014 sectors (1007.0 KiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048         1538047   750.0 MiB   EF00  EFI System
       2         1538048         8388574   3.3 GiB     8300  Linux filesystem
    
2
  • I'd only amend the rodsbooks link to be rodsbooks.com/gdisk/index.html as it's less specific and more updated to me; the answer is just great otherwise. Commented Jul 12, 2015 at 11:31
  • 1
    @MichaelShigorin - done. And thanks for the recommendation. I guess I jumped to conclusions about the asker's environment when I read the edit about hybrid MBRs - in my experience nobody even thinks about those things unless a Mac is involved.
    – mikeserv
    Commented Jul 12, 2015 at 13:10
-1

In your case and always you need to create a partition >2TB. You should use parted command.

Before creating the partition command, we should set the disk label to GPT. GPT stands for GUID partition table format (GPT). Use parted’s mklabel command to set disk label to GPT as shown below.

# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print
Error: /dev/sdb: unrecognised disk label

(parted) mklabel gpt

(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

Create >2TB Partition using Parted mkpart.

Use parted’s mkpart command as shown below to create partition that is greater than 2TB. In this example, we are creating a partition that is roughly of 6TB in size.

#parted /dev/sdb

(parted) mkpart primary 0GB 5909GB

(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  5909GB  5909GB               primary
4
  • 2
    What are you talking about w/ you need partition >2TB? And parted, by the way, isn't really about partitions - it does some kind of crazy amalgam of partitions/fs writes. I think the whole concept is ridiculous - it attempts to hide the things it does from its user. The biggest problem with the concept is that partition tables and filesystems are nothing like the same thing - and they get written to entirely different sections of the disk. Trying to combine the two things is asking for trouble.
    – mikeserv
    Commented Jul 11, 2015 at 19:09
  • 1
    You have written what again? No, I downvoted this answer because it doesn't make sense, or it makes some unreasonable assumptions about the question, it doesn't bother to address the primary question in the question, and the formatting is terrible.
    – mikeserv
    Commented Jul 11, 2015 at 19:27
  • 2
    Setting the disk label to gpt does not make it a gpt disk, though setting a label wouldn't have any effect with an mbr disk, because mbr disks do not support labels. The formatting is a little better now, though.
    – mikeserv
    Commented Jul 11, 2015 at 19:44
  • Creating the partition table --My steps #parted /dev/sdb #mklabel gpt #unit GB Create the partition mkpart primary <from GB> <to GB> #mkpart primary 0.0GB 4000.8GB The above command will not give you any output. View the partition table #print Number Start End Size File system Name Flags 1 0.00GB 4001GB 4001GB ext4 primary You see the partition and the size you just created. Now type the following and hit enter to save and quit parted: #quit Create the filesystem -- You know it with mkfs -t format. Commented Jul 11, 2015 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .