-
Fun with GPT partitioning
Executive summary : A Linux user can easily partition a Pata or Sata disk with the gpt partitioning scheme. Most modern Linux will run on gpt disks with little bother but MS Windows will find it an uphill struggle. It is something useful to have when the hard disk exceeds 2TB. The gpt disks can happily co-exist with the non-gpt disks.
I have stayed away from this GUID partition table (GPT) until I bought a 2TB hard disk. The legacy partition table, also called MBR partition table adopted since Dos, has a limitation beyond the 2TB so I was just looking ahead and had a go with the gpt partioning system. A disk partitioned with the legacy type is called Msdos disk whereas a hard disk with a gpt scheme is now called gpt disk.
In theory the gpt partitioning scheme is ready-make for breaking the 2TB barrier in the hard disks. It will cope well with the future 4k physical sector change as well as the resulting alignment problems created. There is a lot of promises so here I am to find it out.
Apparently the GPT partition table is part of the Extensible Firmware Interface (EFI). The former can be implemented in Linux using certain partitioning tools but the latter requires a efi-aware motherboard which is not easy to find. None of my PC has it.
The upshot of it is that the 64-bit MS Windows can be installed and booted if the PC has both efi hardware and gpt hard disk. The 32-bit Windows can never be booted with gpt hard disk. That means the gpt partition table is pretty useless for the majority of the MS systems.
When it comes to Linux the matter is a lot happier and brighter.
To make a gpt disk all we need is to run the "parted" command in a root terminal. To create a gpt hard disk, say for device /dev/sdb, the command is
Code:
parted /dev/sdb
mklabel gpt
The command nukes all existing partitions. To create a partition say from 0Gb to 100Gb is simply
Code:
mkpart Ubuntu 0 100G
quit
The gpt partition table automatically reserves the front end, about 34 sectors or 34x512= 17408 bytes, for the system use. This is a far cry from the Msdos disk that uses 4x16=64 bytes to describe the 4 primary partitions. The MS systems recognise a gpt disk can have 128 partitions. That apparently also applies in Linux as Post #2 shows how I make a 128 partition under 20 seconds!
The gpt partition table is recognised as one partition type ee in all Linux's partitioning tool that do not support gpt because the first 512 bytes sector is common in both gpt and MBR disks. This GPT partition uses up the whole disk. If the disk is larger than 2TB then only the first 2TB will be reported in the protective MBR entry but the GPT partition can be a lot larger. This is how my 500Gb disk looks like after partitioned with "parted" and interrogated by "fdisk".
Code:
bash-3.1# fdisk -l /dev/sdb
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2aa773c4
Device Boot Start End Blocks Id System
/dev/sdb1 1 60802 488386583+ ee GPT
bash-3.1#
I have actually created 5 partitions inside using parted but only a few partitioning tools that support gpt can report it. The list from parted looks like this
Code:
bash-3.1# parted -l /dev/sdb
(note: the tabulations of 60 partitions of sda were removed as they are irrelevant)
Model: ATA SAMSUNG HD501LJ (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 100GB 100GB ext3 Ubuntu
2 100GB 110GB 9999MB ext3 Mepis
3 110GB 120GB 10.0GB ext3 PClinuxOS
4 120GB 130GB 10.0GB ext3 LinuxMint
5 130GB 140GB 9999MB ext3 Slackware
bash-3.1#
Thus the Linux kernel sees the content inside the gpt and the /dev/sdbx partitions can be used as in a normal MBR partition table.
I have installed Ubuntu 10.4 in sdb1 but sdb2 to sdb5 were filled with Mepis, PClinuxOS, Linux Mint and Slackware from other hard disk. They all boot normally with Grub1 but my Linux Mint has Grub2 and I have to manually boot it up first before I could do a Grub-install inside.
I encountered the following interesting points:-
(1) Grub1 if patched can see the partitions inside a gpt disk. The standard 0.97 Grub1 only see gpt disk with one partition type ee and cannot boot the internal partitions. As an example my Mepis has a standard v0.97 Grub1. Although I can chainload Mepis using a patched Grub1 from Ubuntu when Mepis is loaded its standard Grub failed to boot up Mepis, claiming the partition did not exist.
(2) Grub2 has native support for gpt disks so it can be used to boot their internal partitions.
(3) Some older kernel fail to detect the internal partitions of a gpt disk. As an example I am now using Slackware with a 2.6.29 kernel. I managed to boot it up from sdb5 and was using it, yet when I attempted to mount /dev/sdb2 I got an error message of
mount: special device /dev/sdb2 does not exist
. Its /dev directory only has sdb1 device name. Thus the gpt support is still not mature in Linux.
(4) The UUID numbering system appears to originate from gpt partitioning system.
(5) Without efi hardware support from the motherboard I could not install any of the 64 bit MS Windows on the gpt disk. For the 32 bit MS system the gpt is a no-go area because the internal partitions won't get mounted at all. This means a ntfs partition created by a 64-bit Win7 cannot be seen in a Xp home. And I originally thought gpt partition table was invented for the MS systems.
(6) Any hard disk can be created in gpt format. I have tried it on both 500Gb and 2Tb hard disks.
(7) The partition type numbers appear to have been dropped in gpt system.
(8) A gpt partition table to a non gpt-aware partitioning tool like fdisk, cfdisk or sfdisk is similar to a LVM partition or an extended partition. It show up as one entry but there can be several partitions inside it.
(9) When a hard disk is partitioned in gpt the entire space is used up. A maximum of 128 partitions can be created (as showed in Post #2).
I shall add references to this thread about gpt in the space below from time to time
--------------------------------------GPT references--------------------------------------------------------------------
efi as explained in Wikipedia. Best explanation of gpt A comprehensive tutorial (for gdisk) of the current state of gpt from author of gdisk Rod Smith
Windows and GPT FAQ uefi specification
Last edited by saikee; 06-06-2010 at 05:49 PM.
-
Who says Linux isn't fun?
Here is a script that generate 128 partitions in a gpt disk
Code:
saikee-desktop-Mint8 saikee # echo "mklabel gpt" > a2;for ((i=1;i<=180;i++)); do k1=$[(i-1)*10000+1] k2=$[i*10000]; echo "mkpart sde$i $[k1]m $[k2]m"; done >> a2 ;echo "q">>a2
saikee-desktop-Mint8 saikee # parted /dev/sde < a2
Basically I used a BASH terminal to create a file called a2 storing the key strokes I would have to press in Parted. I then submitted to parted.
Here are the 128 partitions (shown in blue at the bottom of the list). It took 29 seconds to generate the 128 partitions.
Code:
saikee-desktop-Mint8 saikee # parted -l
Model: ATA SAMSUNG HD154UI (scsi)
Disk /dev/sda: 1500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 57.6GB 57.6GB primary fat32 boot, lba
2 57.6GB 115GB 57.6GB primary fat32 hidden, lba
3 115GB 173GB 57.6GB primary
4 173GB 1500GB 1328GB extended
5 173GB 174GB 1653MB logical linux-swap(v1)
6 174GB 232GB 57.6GB logical ntfs
7 232GB 290GB 57.6GB logical ntfs
8 290GB 347GB 57.6GB logical ntfs
9 347GB 405GB 57.6GB logical ntfs
10 405GB 462GB 57.6GB logical ntfs
11 462GB 491GB 28.8GB logical ext3
12 491GB 520GB 28.8GB logical ext3
13 520GB 549GB 28.8GB logical ext3
14 549GB 578GB 28.8GB logical ext3
15 578GB 606GB 28.8GB logical ext3
16 606GB 635GB 28.8GB logical ext4
17 635GB 664GB 28.8GB logical ext4
18 664GB 693GB 28.8GB logical ext4
19 693GB 722GB 28.8GB logical ext4
20 722GB 750GB 28.8GB logical ext3
21 750GB 767GB 16.5GB logical ext4
22 767GB 783GB 16.5GB logical
23 783GB 800GB 16.5GB logical
24 800GB 816GB 16.5GB logical
25 816GB 833GB 16.5GB logical ext3
26 833GB 849GB 16.5GB logical ext3
27 849GB 866GB 16.5GB logical ext3
28 866GB 882GB 16.5GB logical ext3
29 882GB 898GB 16.5GB logical ext3
30 898GB 915GB 16.5GB logical ext3
31 915GB 923GB 8233MB logical ext3
32 923GB 931GB 8233MB logical ext3
33 931GB 940GB 8233MB logical ext3
34 940GB 948GB 8233MB logical ext3
35 948GB 956GB 8233MB logical ext3
36 956GB 964GB 8233MB logical ext3
37 964GB 973GB 8233MB logical ext3
38 973GB 981GB 8233MB logical ext3
39 981GB 989GB 8233MB logical ext3
40 989GB 997GB 8233MB logical ext3
41 997GB 1005GB 8233MB logical ext3
42 1005GB 1014GB 8233MB logical ext3
43 1014GB 1022GB 8233MB logical ext3
44 1022GB 1030GB 8233MB logical ext3
45 1030GB 1038GB 8233MB logical ext3
46 1038GB 1047GB 8233MB logical ext3
47 1047GB 1055GB 8233MB logical ext3
48 1055GB 1063GB 8233MB logical ext3
49 1063GB 1071GB 8233MB logical ext4
50 1071GB 1080GB 8233MB logical
51 1080GB 1088GB 8233MB logical ext3
52 1088GB 1096GB 8233MB logical ext3
53 1096GB 1104GB 8233MB logical ext3
54 1104GB 1112GB 8233MB logical ext3
55 1112GB 1121GB 8233MB logical ext3
56 1121GB 1129GB 8233MB logical ext3
57 1129GB 1137GB 8233MB logical ext3
58 1137GB 1145GB 8233MB logical ext3
59 1145GB 1154GB 8233MB logical ext3
60 1154GB 1162GB 8233MB logical
Model: ATA SAMSUNG HD501LJ (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 100GB 100GB ext4 Ubuntu
2 100GB 110GB 9999MB ext3 Mepis
3 110GB 120GB 10.0GB ext3 PClinuxOS
4 120GB 130GB 10.0GB ext3 LinuxMint
5 130GB 140GB 9999MB ext3 Slackware
Model: SAMSUNG HD203WI (scsi)
Disk /dev/sde: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 10.0GB 10000MB sde1
2 10.0GB 20.0GB 10.0GB sde2
3 20.0GB 30.0GB 10.0GB sde3
4 30.0GB 40.0GB 10.0GB sde4
5 40.0GB 50.0GB 10.0GB sde5
6 50.0GB 60.0GB 10.0GB sde6
7 60.0GB 70.0GB 10.0GB sde7
8 70.0GB 80.0GB 10.0GB sde8
9 80.0GB 90.0GB 10.0GB sde9
10 90.0GB 100GB 10.0GB sde10
11 100GB 110GB 10.0GB sde11
12 110GB 120GB 10.0GB sde12
13 120GB 130GB 10.0GB sde13
14 130GB 140GB 10.0GB sde14
15 140GB 150GB 10.0GB sde15
16 150GB 160GB 10.0GB sde16
17 160GB 170GB 10.0GB sde17
18 170GB 180GB 10.0GB sde18
19 180GB 190GB 10.0GB sde19
20 190GB 200GB 10.0GB sde20
21 200GB 210GB 10.0GB sde21
22 210GB 220GB 10.0GB sde22
23 220GB 230GB 10.0GB sde23
24 230GB 240GB 10.0GB sde24
25 240GB 250GB 10.0GB sde25
26 250GB 260GB 10.0GB sde26
27 260GB 270GB 10.0GB sde27
28 270GB 280GB 10.0GB sde28
29 280GB 290GB 10.0GB sde29
30 290GB 300GB 10.0GB sde30
31 300GB 310GB 10.0GB sde31
32 310GB 320GB 10.0GB sde32
33 320GB 330GB 10.0GB sde33
34 330GB 340GB 10.0GB sde34
35 340GB 350GB 10.0GB sde35
36 350GB 360GB 10.0GB sde36
37 360GB 370GB 10.0GB sde37
38 370GB 380GB 10.0GB sde38
39 380GB 390GB 10.0GB sde39
40 390GB 400GB 10.0GB sde40
41 400GB 410GB 10.0GB sde41
42 410GB 420GB 10.0GB sde42
43 420GB 430GB 10.0GB sde43
44 430GB 440GB 10.0GB sde44
45 440GB 450GB 10.0GB sde45
46 450GB 460GB 10.0GB sde46
47 460GB 470GB 10.0GB sde47
48 470GB 480GB 10.0GB sde48
49 480GB 490GB 10.0GB sde49
50 490GB 500GB 10.0GB sde50
51 500GB 510GB 10.0GB sde51
52 510GB 520GB 10.0GB sde52
53 520GB 530GB 10.0GB sde53
54 530GB 540GB 10.0GB sde54
55 540GB 550GB 10.0GB sde55
56 550GB 560GB 10.0GB sde56
57 560GB 570GB 10.0GB sde57
58 570GB 580GB 10.0GB sde58
59 580GB 590GB 10.0GB sde59
60 590GB 600GB 10.0GB sde60
61 600GB 610GB 10.0GB sde61
62 610GB 620GB 10.0GB sde62
63 620GB 630GB 10.0GB sde63
64 630GB 640GB 10.0GB sde64
65 640GB 650GB 10.0GB sde65
66 650GB 660GB 10.0GB sde66
67 660GB 670GB 10.0GB sde67
68 670GB 680GB 10.0GB sde68
69 680GB 690GB 10.0GB sde69
70 690GB 700GB 10.0GB sde70
71 700GB 710GB 10.0GB sde71
72 710GB 720GB 10.0GB sde72
73 720GB 730GB 10.0GB sde73
74 730GB 740GB 10.0GB sde74
75 740GB 750GB 10.0GB sde75
76 750GB 760GB 10.0GB sde76
77 760GB 770GB 10.0GB sde77
78 770GB 780GB 10.0GB sde78
79 780GB 790GB 10.0GB sde79
80 790GB 800GB 10.0GB sde80
81 800GB 810GB 10.0GB sde81
82 810GB 820GB 10.0GB sde82
83 820GB 830GB 10.0GB sde83
84 830GB 840GB 10.0GB sde84
85 840GB 850GB 10.0GB sde85
86 850GB 860GB 10.0GB sde86
87 860GB 870GB 10.0GB sde87
88 870GB 880GB 10.0GB sde88
89 880GB 890GB 10.0GB sde89
90 890GB 900GB 10.0GB sde90
91 900GB 910GB 10.0GB sde91
92 910GB 920GB 10.0GB sde92
93 920GB 930GB 10.0GB sde93
94 930GB 940GB 10.0GB sde94
95 940GB 950GB 10.0GB sde95
96 950GB 960GB 10.0GB sde96
97 960GB 970GB 10.0GB sde97
98 970GB 980GB 10.0GB sde98
99 980GB 990GB 10.0GB sde99
100 990GB 1000GB 10.0GB sde100
101 1000GB 1010GB 10.0GB sde101
102 1010GB 1020GB 10.0GB sde102
103 1020GB 1030GB 10.0GB sde103
104 1030GB 1040GB 10.0GB sde104
105 1040GB 1050GB 10.0GB sde105
106 1050GB 1060GB 10.0GB sde106
107 1060GB 1070GB 10.0GB sde107
108 1070GB 1080GB 10.0GB sde108
109 1080GB 1090GB 10.0GB sde109
110 1090GB 1100GB 10.0GB sde110
111 1100GB 1110GB 10.0GB sde111
112 1110GB 1120GB 10.0GB sde112
113 1120GB 1130GB 10.0GB sde113
114 1130GB 1140GB 10.0GB sde114
115 1140GB 1150GB 10.0GB sde115
116 1150GB 1160GB 10.0GB sde116
117 1160GB 1170GB 10.0GB sde117
118 1170GB 1180GB 10.0GB sde118
119 1180GB 1190GB 10.0GB sde119
120 1190GB 1200GB 10.0GB sde120
121 1200GB 1210GB 10.0GB sde121
122 1210GB 1220GB 10.0GB sde122
123 1220GB 1230GB 10.0GB sde123
124 1230GB 1240GB 10.0GB sde124
125 1240GB 1250GB 10.0GB sde125
126 1250GB 1260GB 10.0GB sde126
127 1260GB 1270GB 10.0GB sde127
128 1270GB 1280GB 10.0GB sde128
saikee-desktop-Mint8 saikee #
My script is supposed to generate 180 partitions each 10Gb large but the following error was reported. Here is part of the print out where parted objected to.
Code:
(parted) mkpart sde120 1190001m 1200000m
(parted) mkpart sde121 1200001m 1210000m
(parted) mkpart sde122 1210001m 1220000m
(parted) mkpart sde123 1220001m 1230000m
(parted) mkpart sde124 1230001m 1240000m
(parted) mkpart sde125 1240001m 1250000m
(parted) mkpart sde126 1250001m 1260000m
(parted) mkpart sde127 1260001m 1270000m
(parted) mkpart sde128 1270001m 1280000m
(parted) mkpart sde129 1280001m 1290000m
Error: Too many primary partitions.
(parted) mkpart sde130 1290001m 1300000m
Error: Too many primary partitions.
(parted) mkpart sde131 1300001m 1310000m
Error: Too many primary partitions.
(parted) mkpart sde132 1310001m 1320000m
Error: Too many primary partitions.
(parted) mkpart sde133 1320001m 1330000m
Error: Too many primary partitions.
(parted) mkpart sde134 1330001m 1340000m
Error: Too many primary partitions.
(parted) mkpart sde135 1340001m 1350000m
The 128 partition limit is to match what MS systems have been designed to support.
It is also interesting to see that even I specified the first partition to start from 1st Mb of the hard disk Parted overruled me to start at 17.4k which is exactly at the 34th sector. As my 2TB Samsung disk has 512 bytes per sector (both physical and logical) 34*512 = 17408 bytes or 17.4k.
A gpt partition table has
Sector 1 for the protective MBR
Sector 2 for the primary header
Sector 3 to 34 for storing the 128 partition entries. Each partition entry has 128 bytes. Details as per Wikipedia on GUID Partition Table
Proof of the pudding in the eating
To prove these partitions work I tried to install a Linux at the 128th partition while using the 1st partition as a swap. Ubuntu seems to take too long and I lost patience. I tried Open Suse 11.3. It apparently has a Grub1 that failed to get installed and the distro became inoperable.
Finally I installed Fedora 13 X86_64 Live-KDE in the 128th partition and its Grub1 failed again, leaving me with an installed Linux without a boot loader. However I slip in a Grub2 floppy and fired it up manually. I am using this Fedora to add information to the current post. The /boot/grub/grub.conf gave it away that Fedora has only Grub1. The content of /boot/grub directory is nearly empty and the grub.conf has nothing inside.
Code:
[root@localhost saikee]# ls /boot/grub
grub.conf splash.xpm.gz
[root@localhost saikee]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
[root@localhost saikee]#
Fedora's /boot has these files
Code:
[root@localhost saikee]# ls /boot
config-2.6.33.3-85.fc13.x86_64 initramfs-2.6.33.3-85.fc13.x86_64.img
efi memtest86+-4.00
elf-memtest86+-4.00 System.map-2.6.33.3-85.fc13.x86_64
grub vmlinuz-2.6.33.3-85.fc13.x86_64
[root@localhost saikee]#
So it can be booted manually with Grub2 commands
Code:
set root=(hd1,128)
linux /boot/vmlinuz-2.6.33.3-85.fc13.x86_64 ro root=/dev/sdb128
initrd /boot/initramfs-2.6.33.3-85.fc13.x86_64.img
boot
The green bits were not typed but using the tab key to complete.
When installing Fedora I removed one of the hard disks making the gpt disk changed from sde to sdb.
Some bad news
(1) If the distro has unpatched Grub1 of V0.97 then the installation can fail with the bootloader unable to read the gpt partition table. The only way out is to boot up the system manually with Grub2 and then install Grub2 inside.
(2) Grub1, even if patched and able to read a gpt can have an issue of "Selected cylinder exceeds the maximum supported by the BIOS". This happened to me when I tried to use a patched Grub1 from Ubuntu to boot the Fedora in sdb128 which is at the 1280Gb position of the hard disk.
(3) A distro may have components able to read a gpt yet another component not arranged to service it. An example is Slax and Slackware which have "parted" to show up the 128 partitions yet in the /dev directory only the first partition has been detected and has just the device name /dev/sdb1 available. Some distros may list only the first 15 partitions too if the other are detected.
(4) Even if the Linux is fully able to work with 128 partitions its installer may not have been written to cope with such a high number of partitions. Typically the installer may freeze in such an encounter.
(5) I found out two issues with Grub1. (1) The standard Version 0.97 cannot read a gpt disk. This can be overcome by the patched Grub1 available from Ubuntu, Mandriva and Slackware family distros. Just replace the two files stage1 and stage2 in the /boot/grub directory is all one needs. (2) Grub1 even patched will not be able to boot systems located beyond at about 1340Gb in the hard disk. The error is "The cylinder exceeds the maximum supported by the BIOS". So far the only cure is to switch to Grub2. This error applies to both Msdos and gpt disks.
Last edited by saikee; 06-06-2010 at 07:11 AM.
-
Some GPT partitioning scheme FAQs
(1) What is gpt partitioning scheme?
It is one of the several partitioning schemes for a hard disk. Most of us use Msdos partition table in Linux.
(2) Why can't I stick with the existing Msdos partition table?
Yes you can. It is just in the Msdos partition table each partition is defined by 16 bytes. The last 2 sets of 4-bytes describe the hard disk position and the number of sectors of the partition. There are 42 bits in 4 bytes and 2^32*512 bytes per sector=2TB. Thus hard disks or RAID exceeding 2TB cannot use Msdos partition table.
Can I partition any hard disk with gpt scheme?
I haven't tried Pata disk but there does not seem to be any problem with Sata disk.
What tool in Linux can we use to do gpt partitions?
Parted is the main tool. But Gparted and gdisk (also sgdisk) also do gpt partitions.
Does Linux kernel support gpt?
There were information indicating gpt supports started in 2000 in Linux. Most distros have no problem with it. Some installers may not have been written to install in a gpt disk. From my experience I haven't found an installer from Slackware family able to read a gpt disk. Its kernel doesn't boot from it but has the program "parted" and so able to see it.
Linux in general has little problem in using a gpt partitions in exactly the same way as any partition.
Do other operating systems support gpt?
MS Windows seem to go in a big way to promote gpt but with 200% effort of Linux to get 25% out of it. All 32-bit MS Windows, possibly the majority of the desktops, are totally blind to gpt because they can't mount it. A 64-bits MS Windows can only boot from gpt if the motherboard is equipped with efi hardware.
Apple has gone in a big way to support gpt and able to make a good use of it.
BSD systems are like Linux -- no problem!
Can Linux boot loaders cope with gpt?
Since I can't get a Slackware family distro to recognise a gpt disk so I haven't been able to test Lilo fully. I did manage to install Mandriva into the gpt sda7 partition and opted for Lilo as its boot loader. That boot up successfully first in MBR and then withing sda7 when chainloaded by another bootloader. Lilo has a limit not able to recognise a partition number higher than 15 so it is not a big player in booting Linux. There seem to a fair bit of criticism Lilo failing gpt and I did find it behaving differently between a Msdos and gpt disks.
Standard Grub1 cannot read a gpt disk. This is not a big deal because a standard Grub1 also can't read the Ext4 filing system too but can be "doctored" to do so. Many distros now have Grub1, patched to recognise gpt as well as Ext4, able to read gpt disks. If Grub1 can read gpt it can boot from it.
Grub2 has been engineered to read gpt from day 1.
How does a gpt disk respond in the normal partitioning scheme?
A gpt partitioning scheme retains the MBR layer and has been given Type number "ee". It works just live a LVM (Type 8e). You only see one partition displayed but there can be several components inside. The partition types supported by Linux are :-
Code:
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux RAID auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
The command
yields
Code:
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2aa773c4
Device Boot Start End Blocks Id System
/dev/sda1 1 60802 488386583+ ee GPT
whereas the command
Code:
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util sfdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 0+ 60801- 60802- 488386583+ ee GPT
start: (c,h,s) expected (0,0,2) found (0,0,1)
/dev/sda2 0 - 0 0 0 Empty
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
The fully contents of a gpt disk is only visible currently with parted command but GUI commands like Gparted also privides a full list.
Code:
Model: ATA SAMSUNG HD501LJ (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 100GB 100GB ext4 Ubuntu
2 100GB 110GB 9999MB ext3 Mepis
3 110GB 120GB 10.0GB ext3 PClinuxOS
4 120GB 130GB 10.0GB ext3 LinuxMint
5 130GB 140GB 9999MB ext3 Slackware
6 200GB 201GB 1000MB linux-swap(v1) swap
7 201GB 210GB 9000MB ext3 new_Linux
Can a Linux be moved from a Msdos disk to a gpt disk?
Yes subject to the normal rules of migrating to a different partition.
In the above sda disk I only installed Ubuntu but moved Mepis, PCLinuxOS, LinuxMint and Slackware from a Msdos disk. They were in different partition numbers too. All of them boot except the Slackware.
A brief rundown of Linux migration of Mepis, PCLinuxOS, Linux Mint and Slackware:
(1) I had to mount the distro at its new location, edit /etc/fstab and /boot/grub/menu.lst (for Grub1) or /boot/grub/grub.cfg(for Grub2) to reflect the new location.
(2) For Grub1 I simply use a Grub shell or Grub prompt to restore Grub it the distro's root partition. Say this is /dev/sda2 the Grub commands are just
Code:
root (hd0,1)
setup (hd0,1)
(3) For Grub2 I had to boot manually into the Linux and do a grub-install. For within its root partition, say sda1, will be
Code:
grub-install --force /dev/sda1
for choosing that distro to take control of MBR then the command will be
Code:
grub-install /dev/sda
(4) I then edited the Grub menu of distro controlling the MBR to chainload all the others.
Mepis has a standard Grub1. When it booted Grub1 cannot mount any partition so I ended up with a Grub prompt. PCLinuxOS and Slackware have patched Grub1 so I simply copied their stage1 and stage2 files from /boot/grub directory into Mepis. I did the "root" and "setup" commands again and Mepis boots successfully in the gpt disk.
Ubuntu and Linux Mint use Grub2 so they booted immediately after the migration.
PCLInuxOS does not like the migration of being moved from sda39 to sda3. It waits 2 minutes for sda39 to appear. After the 2 minutes it boots up normally. This is a speciality of Mandriva family and I have not found a cure to avoid the 2 minutes waiting yet.
Slackware doesn't boot! It panic complaining could not find sda5. The boot up message shows only sda1 was detected so its kernel can't read a gpt disk. I then tried to install several Slackware family distros and none of them can see the partitions inside.
Last edited by saikee; 07-30-2011 at 04:56 AM.
-
Tips for partitioning a hard disk with "parted"
After trying the gpt on Pata and Sata disks I thought some of the pointers mat be useful to others.
(A) Do the gpt scheme first and the partitions later.
This is because I prefer the partitioning with a script with which I could check first before going ahead. To make a hard disk do gpt one just needs a command but it pays to check the disk before and after as I explain with the following example. The red entries are my input while the rest is from the Linux.
Code:
linux-ijwr:/home/saikee # parted /dev/sdb
GNU Parted 2.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: ATA SAMSUNG HD154UI (scsi)
Disk /dev/sdb: 1500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 24.7MB 60.4GB 60.4GB primary boot, type=bf
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) p
Model: ATA SAMSUNG HD154UI (scsi)
Disk /dev/sdb: 1500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) q
Information: You may need to update /etc/fstab.
The first command "parted /dev/sdb" is to commit myself to partition device sdb. When inside parted I issued the first "p" to print out the existing partition table, which is a Solaris Type "bf" I wished to ditch.
The main command to turn the disk to gpt is "mklabel gpt".
Parted wants a confirmation for safety so I answer with a "yes". I then issued the 2nd "p" to print the latest partition table which now show up empty. I then issued "q" to exit parted.
(B) Partioning by a script
To do partition I find enjoyment of doing it by a script so I used an editor to write a file called "parted_sda_10_partition"
Code:
linux-ijwr:/home/saikee # cat parted_sda_10_partition
for ((i=1;i<=10;i++));
do k1=$[(i-1)*20000+1]
k2=$[i*20000];
echo "mkpart Partition_$i $[k1]m $[k2]m";
done > a2 ;
echo "q">>a2
One can issue it as a bash script to generate a text file called a2.
Code:
linux-ijwr:/home/saikee # cat a2
mkpart Partition_1 1m 20000m
mkpart Partition_2 20001m 40000m
mkpart Partition_3 40001m 60000m
mkpart Partition_4 60001m 80000m
mkpart Partition_5 80001m 100000m
mkpart Partition_6 100001m 120000m
mkpart Partition_7 120001m 140000m
mkpart Partition_8 140001m 160000m
mkpart Partition_9 160001m 180000m
mkpart Partition_10 180001m 200000m
q
I checked the partition layout and after satisfied with it I then committed by directing parted to use it as the input.
Code:
linux-ijwr:/home/saikee # parted /dev/sdb <a2
GNU Parted 2.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart Partition_1 1m 20000m
(parted) mkpart Partition_2 20001m 40000m
(parted) mkpart Partition_3 40001m 60000m
(parted) mkpart Partition_4 60001m 80000m
(parted) mkpart Partition_5 80001m 100000m
(parted) mkpart Partition_6 100001m 120000m
(parted) mkpart Partition_7 120001m 140000m
(parted) mkpart Partition_8 140001m 160000m
(parted) mkpart Partition_9 160001m 180000m
(parted) mkpart Partition_10 180001m 200000m
(parted) q
Information: You may need to update /etc/fstab.
linux-ijwr:/home/saikee # parted -l
Model: ATA Maxtor 6Y200P0 (scsi)
Disk /dev/sda: 204GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 10.0GB 9999MB linux-swap(v1) partition1
2 10.0GB 20.0GB 9999MB partition2
3 20.0GB 30.0GB 9999MB partition3
4 30.0GB 40.0GB 9999MB partition4
5 40.0GB 50.0GB 10.0GB partition5
6 50.0GB 60.0GB 9999MB partition6
7 60.0GB 70.0GB 9999MB partition7
8 70.0GB 80.0GB 9999MB partition8
9 80.0GB 90.0GB 10.0GB partition9
10 90.0GB 100GB 9999MB partition10
11 100GB 110GB 9999MB partition11
12 110GB 120GB 9999MB partition12
13 120GB 130GB 10.0GB partition13
14 130GB 140GB 9999MB partition14
15 140GB 150GB 9999MB partition15
16 150GB 160GB 9999MB partition16
17 160GB 170GB 10.0GB partition17
18 170GB 180GB 9999MB partition18
19 180GB 190GB 9999MB ext4 partition19
20 190GB 200GB 9999MB partition20
Model: ATA SAMSUNG HD154UI (scsi)
Disk /dev/sdb: 1500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB Partition_1
2 20.0GB 40.0GB 20.0GB Partition_2
3 40.0GB 60.0GB 20.0GB Partition_3
4 60.0GB 80.0GB 20.0GB Partition_4
5 80.0GB 100GB 20.0GB Partition_5
6 100GB 120GB 20.0GB Partition_6
7 120GB 140GB 20.0GB Partition_7
8 140GB 160GB 20.0GB Partition_8
9 160GB 180GB 20.0GB Partition_9
10 180GB 200GB 20.0GB Partition_10
The blue section of the above is the gpt partition table I created.
For a few partitions there is no need to use a script. I tend to stretch the gpt to the limit so having a script is a lot easier for testing.
Last edited by saikee; 06-06-2010 at 05:47 PM.
-
gpt and MS Windows
(A) Different Windows see a gpt disk differently.
32-bit Windows cannot see gpt disk interior. This is how a gpt disk showing up in Xp's disk management
[img]http://groups.google.com/group/hkexf...0one.gif?hl=en[/img]
It clear show the 2TB gpt as one partition. The other 1.5TB disk has a normal Msdos partition table.
The 64-bit Windows systems are a bit cleverer and a 64-bit Win7 sees the maximum 128 internal partitions as shown below.
[img]http://groups.google.com/group/hkexf...disk.PNG?hl=en[/img]
It is interesting to see the 64-bit sees the gpt disk as its own and attempts to mount all the partitions by assigning a letter to each until the drive letter runs out at z:. Then it stops.
This is a very unusual behaviour because a standard MS Windows does not mount a partition, gives it a drive letter if the filing system is not recognised. Yet it goes all its way to do it for the gpt disk.
I have also long been puzzled by MS Windows calling every partition it doesn't recognised or with a vaild filing system as a "primary" partition.
(B) gpt is a no go area for MS boot loaders
MS boot loaders from Dos, Win2k, Xp, Vista and Win7 all work on the principle that any one of the 4 primary partitions with the booting flag set "on" shall be booted. There is no distinction between primary and logical partition in a gpt disk and there can be potentially 128 partitions in each. Thus the MS boot loaders break down completly with a gpt disk. No wonder none of the 32 bit MS Windows can boot from a gpt disk.
The 64-bit MS Windows can boot from a gpt disk only if the motherboard is equipped with the efi hardware which provides its own boot loader. This will be very hard to catch on. In the mean time many MS Windows systems are reaching the end of the road with a hard disk limited at 2TB. May be the 4k physical block addressing will buy them some extra time.
The superiority of the Linux boot loaders is evident when comparing with the MS systems.
It comes no surprise that I found Lilo and Grub can work normally with a gpt disk.
Linux kernel is a lot saner when coming to partitions. Unless one specifies them in /etc/fstab none of the partitions will be mounted. If a user wants he/she can always mounts a partition manually or automatically with fstab.
A MS Windows system tends to be obssessed with other systems using their resources so on every boot-up it will go through every partition in each hard disk. This takes a long time and doing the disk no good at all.
-
Saikee, I need your help!
I have been using a 500GB SATA drive (same model as your example - Samsung 501LJ) which is (somehow) a GPT format (I probably had OSX on there at some point).
I used to boot off a third (unused) NTFS MBR formatted drive, so the bootloader is still intact on that HDD I believe. My problem is THIS, I have transferred the drive to a new machine, and it now will not boot Linux (Mint 10 Julia). There is probably a very simple fix to this, probably replacing the MBR (GPT?) with a simple dd line.
For an OS that supports GPT, I am having a nightmare getting grub reinstalled off the boot CD.
I now have the linux boot drive connected via a PCI Sata card, which identifies the disk as SCSI I believe, although it mounts fine with a default mount command. All the files on the disk look intact...
Any help would be very useful to me... You should be able to email me via this forum.
Many thanks...
themacmeister
-
themacmeister,
Welcome to Justlinux!
I think your boot loader might have been broken by the disk order as you seem to several hard disk so there would have been a disk order 0, 1, 2 etc.
The MBR for a MSdos and gpt partition disk is the same. The only difference is a gpt has a large boot sector storing all the necessary information for the 128 partitions. It also has a dulpication of its partition table at the rear end of the disk making salvage work possible.
As far as I am aware Grub2 works with gpt disks the same way as MSdos disks so your rescue lies with identify the correct disk and partition if the Grub2 has been installed into the gpt disk.
For assistance you will have to describe the situation before the change and after the change. Location of the boot loader, which should be in one of the Linux, /boot/grub/grub.cfg, /boot/grub/device.map and /etc/fstab will helps us to understand your configuration.
As a rule you should be able to restore Grub2 with any Linux Live CD that has Grub2 inside.
-
Never mind, I reformatted the drive, and will eventually reinstall Mint Linux. Thanks for your reply - it will be helpful in the future.
-
How Seagate manage a 3TB to suit operating systems
Bought a 3TB external hard disk today. It is one of those Seagate Geoflex series. It does not have a gpt partition table but a special or interesting Msdos partition table
The saying is a 32-bit operating system has a limit of addressing up to a maximum just below 2.2TB and so this becomes the limit of the MSDOS partition table based on each record the hard disk read or write is 512 bytes.
The trend is go for the gpt partition table but that is still too immature or too new for many PC users.
Seagate in order to sell their 3TB hard disks has increased the sector size from 512 bytes to 4096 bytes. Thus the number of records to search is artificially reduced so that the hard disk hooked up as an external drive (not required for booting) can be used by the common operating systems.
Here is the disk geometry of Seagate 3TB hard disk, factory-preformatted to one NTFS partition.
Code:
Note: sector size is 4096 (not 512)
Disk /dev/sdb: 3000.6 GB, 3000592977920 bytes
1 heads, 7 sectors/track, 104652377 cylinders
Units = cylinders of 7 * 4096 = 28672 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xa4b57300
Device Boot Start End Blocks Id System
/dev/sdb1 2 104652001 2930256000 7 HPFS/NTFS
Partition 1 does not start on physical sector boundary.
Thus the hard disk is still reading 512 bytes per sector physically but the controller of the external hdd enclosure changes it to 4096 bytes.
This 3TB USB disk is automatically mounted by Xp (32-bit), Win7 (64-bit) and Ubuntu (32-bit) and operates normally.
Last edited by saikee; 06-23-2011 at 04:27 PM.
-
Great Stuff
Writing, content, understandability, reading great stuff http://www.justlinux.com/forum/image...es/biggrin.gif
-
PaulTabo,
Welcome to Justlinux!
-
hi saikee
i have a T420s with a 160GB SSD and i have discovered (i am a newbie:-) ) that
the disk label is msdos and i want as little as possible from MS so i booted from a live-USB and changed the disk label to GPT and reinstalled linux mint 12. but now when i switch on the computer, it doesnt even load the grub.. the only error message is: exiting intel boot agent.. any suggestions?
-
It sounds to me that you might have not installed Grub properly so that the computer trying to obtain a boot code from the Intel booting agent which I assume is the one residing in the PC hardware.
What you can do is to boot up the Mint CD and post here the output of
Code:
sudo su
fdisk -l
parted -l /dev/sda
to confirm the disk partitions. The "l" in the above is the lower case of "L". The Mint CD should enable you to use the Internet.
Last edited by saikee; 05-06-2012 at 06:23 PM.
-
ok, but in all distros i ve tried (except arch) one can just partition the disk manually and click: install bootloader on /dev/sd*.. can one install a live cd with command line tools to have more control?
here are my outputs: (i'm not sure if i've changed something since installation, i've maybe messed around with..)
PHP Code:
mint mint # fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 312581807 156290903+ ee GPT
PHP Code:
mint mint # parted -l /dev/sda
Model: ATA INTEL SSDSA2BW16 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 10.0GB 10.0GB ext4
2 10.0GB 50.0GB 40.0GB ext4
3 50.0GB 62.0GB 12.0GB linux-swap(v1)
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0
has been opened read-only.
Error: Invalid partition table - recursive partition on /dev/sr0.
Ignore/Cancel?
-
i ran "boot info script" too, should i'll post the output? its pretty long:-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|