Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-14-2014, 11:28 PM
|
#1
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Rep: 
|
MBR to GPT without Data Loss?
Is it possible to convert MBR to GPT without data loss / corruption using gdisk?
|
|
|
03-14-2014, 11:42 PM
|
#2
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,349
Rep: 
|
The answer is "yes", with some provisions.
Editing the partition table doesn't actually affect data on the drive at all. You can delete a partition with fdisk or gdisk or any other tool, but unless you create a new partition and overwrite that part of the drive, the data will still be there. Recreating the partition with the exact same parameters will cause the file system to reappear completely intact.
Having said that, there may be issues with converting certain MBR-based systems to GPT, simply because the GPT takes up more space than the MBR. It is possible for a partition on an MBR-partitioned drive to occupy parts of the disk that would be needed by the GUID Partition Table itself.
Your existing MBR was probably created by fdisk or cfdisk or the distribution installer. Older versions of fdisk followed the same convention as the Microsoft partitioning tool in Windows XP/2003 and earlier versions, which is to let the first partition start at sector 63. That would not be a problem, as the GPT uses sectors 1 - 33. Later versions of fdisk will use sector 2048 as the default starting sector for the first partition. However, in both cases the start sector can be overridden by the user.
A second copy of the GPT is stored in reverse order at the end of the disk. Again, it only takes up 34 sectors, but if a partition continues right up to the very last sector on the drive, creating a GPT will overwrite the last 34 sectors of that partition.
See what fdisk -l has to say about your current partition table, and back up the partition table (or rather, the first 2048 sectors of your drive) before you attempt to convert the partition scheme to GPT.
Last edited by Ser Olmy; 03-14-2014 at 11:48 PM.
|
|
1 members found this post helpful.
|
03-14-2014, 11:46 PM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,383
|
Do *not* attempt to use fdisk. Read this and use gdisk.
I personally have only ever used it when converting a new disk - i.e. with data I don't care about. Has worked without discernable loss for me though.
|
|
1 members found this post helpful.
|
03-14-2014, 11:52 PM
|
#4
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
@ Olmy:
Here is what fdisk spat out about my partition table:
<CODE>
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4294862847 2147430400 83 Linux
/dev/sdb2 4294864896 5860532223 782833664 7 HPFS/NTFS/exFAT</CODE>
As seen I do have 2048 in front of sdb1 (I remember leaving 1MB space preceding the MBR when creating my partitions). so sdb1 looks safe. sdb2 let me calculate... to see how much I got left.
Last edited by Mercury305; 03-14-2014 at 11:58 PM.
|
|
|
03-14-2014, 11:54 PM
|
#5
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
Quote:
Originally Posted by syg00
Do *not* attempt to use fdisk. Read this and use gdisk.
I personally have only ever used it when converting a new disk - i.e. with data I don't care about. Has worked without discernable loss for me though.
|
Thanks, and yes I know the gdisk is pretty much the latest and best supported version for GPT.
|
|
|
03-14-2014, 11:58 PM
|
#6
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,349
Rep: 
|
Quote:
Originally Posted by Mercury305
As seen I do have 2048 in front of sdb1 (I remember leaving 1MB space preceding the MBR when creating my partitions). so sdb1 looks safe. The other I don't know how many sectors are left.
|
Yes, there's plenty of room for the GPT at the start of the drive.
fdisk will have reported the number of sectors on the drive as well, a few lines above the actual partition table. That should tell you if the other partition covers the entire disk. If it does, it will have to be shrunk ever so slightly to accommodate the backup GPT.
|
|
1 members found this post helpful.
|
03-15-2014, 12:01 AM
|
#7
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
Quote:
Originally Posted by Ser Olmy
Yes, there's plenty of room for the GPT at the start of the drive.
fdisk will have reported the number of sectors on the drive as well, a few lines above the actual partition table. That should tell you if the other partition covers the entire disk. If it does, it will have to be shrunk ever so slightly to accommodate the backup GPT.
|
Thanks I noticed later the top of the fdisk spat out total sectors:
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00024a97
So I just subtract from that number and answer = 945 sectors left. So I should be fine!  Thanks again Ser Olmy!
|
|
|
03-15-2014, 12:12 AM
|
#8
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,349
Rep: 
|
Oh, it's even better than that.
According to fdisk you have a 3000 Gb drive, but since fdisk is bound by the limitations of the MBR format, it cannot "see" the parts of the drive that lie beyond 2 Tb (or "TiB" as it's called these days). So you've got those 945 sectors plus an entire terabyte available.
|
|
1 members found this post helpful.
|
03-15-2014, 12:16 AM
|
#9
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
AFAIK, MBR sees upto 2TB per partition (not drive). I remember, when I created the 2 partitions fdisk gave a warning saying it can do only upto 2TB. Hopefully you are right. Let me GPT my disk and see what happens.
|
|
|
03-15-2014, 12:25 AM
|
#10
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,349
Rep: 
|
Quote:
Originally Posted by Mercury305
AFAIK, MBR sees upto 2TB per partition (not drive). I remember, when I created the 2 partitions fdisk gave a warning saying it can do only upto 2TB. Hopefully you are right. Let me GPT my disk and see what happens.
|
You're right of course. You have two partitions, so you've been able to use the entire drive.
What can I say, it's very late here. 
|
|
|
03-15-2014, 12:27 AM
|
#11
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
Here is the Results
All worked fine,
Disk /dev/sdb: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): XXX
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4973 sectors (2.4 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4294862847 2.0 TiB 8300 ext4
2 4294864896 5860532223 746.6 GiB 0700 ntfs
|
|
|
03-15-2014, 12:30 AM
|
#12
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
Now, I am thinking would it be smarter to do LVM since there is so much space?
|
|
|
03-15-2014, 12:32 AM
|
#13
|
Member
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540
Original Poster
Rep: 
|
Quote:
Originally Posted by Ser Olmy
You're right of course. You have two partitions, so you've been able to use the entire drive.
What can I say, it's very late here. 
|
Thanks for staying up so late and all the help
Its almost 2AM over here as well. Gettin my geek on tonight! 
|
|
|
All times are GMT -5. The time now is 03:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|