LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 03-14-2014, 11:28 PM   #1
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Rep: Reputation: Disabled
Question MBR to GPT without Data Loss?


Is it possible to convert MBR to GPT without data loss / corruption using gdisk?
 
Old 03-14-2014, 11:42 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,777

Rep: Reputation: Disabled
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.
Old 03-14-2014, 11:46 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,102

Rep: Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327Reputation: 3327
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.
Old 03-14-2014, 11:52 PM   #4
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
@ 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.
 
Old 03-14-2014, 11:54 PM   #5
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
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.
 
Old 03-14-2014, 11:58 PM   #6
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,777

Rep: Reputation: Disabled
Quote:
Originally Posted by Mercury305 View Post
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.
Old 03-15-2014, 12:01 AM   #7
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
Talking

Quote:
Originally Posted by Ser Olmy View Post
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!
 
Old 03-15-2014, 12:12 AM   #8
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,777

Rep: Reputation: Disabled
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.
Old 03-15-2014, 12:16 AM   #9
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-15-2014, 12:25 AM   #10
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,777

Rep: Reputation: Disabled
Quote:
Originally Posted by Mercury305 View Post
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.
 
Old 03-15-2014, 12:27 AM   #11
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-15-2014, 12:30 AM   #12
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
Now, I am thinking would it be smarter to do LVM since there is so much space?
 
Old 03-15-2014, 12:32 AM   #13
Mercury305
Member
 
Registered: Jul 2012
Location: Rockville, MD
Distribution: CrunchBang / Ubuntu
Posts: 540

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Ser Olmy View Post
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot copy GPT partition data on Linux Mint 12 KDE to Kubuntu formatted MBR larryalk Linux - Newbie 2 06-19-2012 09:41 PM
Change from GPT to MBR partiotion schema (without losing data) juanjillo Linux - Server 1 04-04-2012 08:37 AM
GPT vs MBR asipper Linux - General 9 12-23-2011 08:29 PM
[SOLVED] Slackware 13.37 - gdisk choices, MBR, GPT or Blank GPT CFet Slackware - Installation 3 04-01-2011 04:46 PM
GPT to MBR mrwall-e Linux - Software 3 08-26-2010 09:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration