Results 1 to 5 of 5

Thread: How can i detect whether my disk is gpt or mbr

Hybrid View

  1. #1
    Join Date
    Apr 2009
    Beans
    9

    How can i detect whether my disk is gpt or mbr

    How can i detect if my disk is formatted as gpt or mbr?

    I suppose in principle this could be done by somehow
    reading a few bytes (no more than say 10K) from the
    beginning and possibly the end of the disk?

    But there surely is a program around that does exactly
    this, maybe some variation of or argument to fdisk or grub?

    Thanks in advance for any info!

    dan

  2. #2
    Join Date
    Jul 2006
    Location
    London, UK
    Beans
    818
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How can i detect whether my disk is gpt or mbr

    Look at it with gdisk

  3. #3
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    parted

    or you can look at it with parted or gparted.

  4. #4
    Join Date
    Mar 2010
    Location
    Woonsocket, RI USA
    Beans
    3,195

    Re: parted

    More answer than you probably wanted, but....

    There are several ways. The details vary with the tool...

    GPT fdisk (gdisk) provides the most complete diagnostic of partition table type that I'm aware of. Type "gdisk -l /dev/sda" (or whatever the disk is), and you'll get something like this, among other things:

    Code:
    Partition table scan:
      MBR: MBR only
      BSD: not present
      APM: not present
      GPT: not present
    This tells you what partitioning data the tool has detected. In this case, it's an MBR disk. A GPT disk would look like this:

    Code:
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    There's another common possibility that gdisk can detect: a hybrid MBR, in which a GPT disk has had MBR "copies" of up to three partitions added. This shows up in the gdisk scan as:

    Code:
    Partition table scan:
      MBR: hybrid
      BSD: not present
      APM: not present
      GPT: present
    There are various broken configurations, too, like "MBR: MBR only" with "GPT: present", which generally means that somebody took a GPT disk and repartitioned it with fdisk or some other GPT-unaware utility. This is technically legal (it's no longer a GPT disk, but an MBR disk), but it confuses libparted-based tools such as GParted. The BSD and APM lines change if gdisk detects a BSD disklabel (usable by FreeBSD, NetBSD, etc.) or an Apple Partition Map (APM; used by 680x0- and PowerPC-based Macs).

    The text-based GNU Parted reports MBR/GPT status, but not hybrid MBRs, on a line like this:

    Code:
    Partition Table: gpt
    It uses "msdos" to mean "MBR" on this line. It reports hybrid disks as being GPT, and if you make changes it writes a fresh protective MBR, wiping out the hybrid partitions. It tends to flake out with most damaged or confused disk types, but it at least reports an error message. It can also detect and work on several other partition table types.

    GParted behaves a lot like GNU Parted, but you've got to select View -> Device Information to see the partition table type.

    With fdisk, you can identify GPT disks in a couple of ways. First, fdisk displays the following warning:

    Code:
    WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk
    doesn't support GPT. Use GNU Parted.
    Second, GPT disks have a type-0xEE MBR partition, known as the "protective partition:"

    Code:
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1               1     3981311     1990655+  ee  GPT
    This partition must be present on all GPT disks, but a true GPT disk contains additional data structures; so you could put such a partition on a blank disk using fdisk and it would look superficially like a GPT disk to fdisk, but it wouldn't really be a GPT disk. (The warning displayed earlier seems to check for other GPT signatures, but I've not checked the source code to learn the details.)
    If I've suggested a solution to a problem and you're not the original poster, do not try my solution! Problems can seem similar but be different, and a good solution to one problem can make another worse. Post a new thread with your problem details.

  5. #5
    Join Date
    Apr 2009
    Beans
    9

    Re: How can i detect whether my disk is gpt or mbr

    Thanks tredegar, Lars, and srs5694.

    Thanks especially srs5694, as i could check my results against your sample outputs.

    This is for reference, in case somebody else needs to determine if they have a gpt or mbr disk in a situation similar to mine. (I don't think it should be dangerous to use gdisk if you quit out of it before asking it to write anything. But anybody please correct me if i'm wrong here.)

    I saw tredegar's response first, so i decided i would try gdisk.

    I could not see it as a package in Synaptic Package Manager for ubuntu 9.10, which is what i have on my machine.

    But it is on source forge, and builds easily (not even a configure step), provided you install the prerequisite packages listed in the README: the uuid lib [dev version], the icu lib [dev], and libpopt [dev]. A link to the sources is in
    http://sourceforge.net/projects/gptf...ptfdisk/0.7.1/
    and to a debian package in
    http://sourceforge.net/projects/gptfdisk/files/

    The sources compile easily (type make and they just build).

    Then all you have to do is run it,
    sudo ./gdisk
    It asks you for a disk, and you give it something like /dev/sda, and
    it reports ---------
    you must type q after the report to make sure that it doesn't actually
    do anything.

    (And, in my case, i have an mbr not a gpt, which is what i thought, but wanted to be sure.)

    Thanks again everybody for the replies, and if anything i've said here is wrong, please somebody correct me.

    dan

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •