Search This Blog

Showing posts with label mbr. Show all posts
Showing posts with label mbr. Show all posts

Sunday, May 1, 2011

How to find what type of disk partition schema do I use (msdos, gpt)

There are many disk partition schemes that can be used. Very likely on most x86 base computer the choice is often limited by the operating system we use although.

The list of supported labels (partition schemes) in GNU parted tool can be found here [1]:


label-type must be one of these supported disk labels:

* bsd
* loop (raw disk access)
* gpt
* mac
* msdos
* pc98
* sun


To find out what type of partition schema we currently have on your system please run the bellow command and check the value for the 'Partition Table'.

% parted /dev/sda unit mb print
Model: ATA ST2000DL003-9VT1 (scsi)
Disk /dev/sda: 2000399MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start     End       Size      Type     File system  Flags
 1      0.03MB    104856MB  104856MB  primary  ntfs         boot
 2      104857MB  209714MB  104858MB  primary  ntfs
 3      209714MB  312115MB  102401MB  primary
                                      
root@sysresccd /tmp % parted /dev/sda unit s print
Model: ATA ST2000DL003-9VT1 (scsi)
Disk /dev/sda: 3907029168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start       End         Size        Type     File system  Flags
 1      63s         204796619s  204796557s  primary  ntfs         boot
 2      204797952s  409597951s  204800000s  primary  ntfs
 3      409597952s  609599487s  200001536s  primary


References:

[1]
(parted) mklabel msdos

Others:

Parted User's Manual

GUID Partition Table

Make the most of large drives with GPT and Linux

Fun with GPT partitioning

Linux Creating a Partition Size Larger than 2TB

How to export/backup partition schema for a disk using old style disk partitions format like 'msdos' written into MBR sector

To backup the partition schema of the disk you can execute:

# sfdisk -d /dev/sda > part.txt

# example output can look like
# cat part.txt
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size=204796557, Id= 7, bootable
/dev/sda2 : start=204797952, size=204800000, Id= 7
/dev/sda3 : start=409597952, size=200001536, Id=83
/dev/sda4 : start=        0, size=        0, Id= 0

To restore the part.txt you can use:

# sfdisk /dev/hda < part.txt 
 
References:
man sfdisk 
Wiping Out Old GPT Data