The short version is, Yes, it is possible. But a few points from me:
- When doing the conversion, boot from a rescue media (or just from install media), otherwise you will not be able to see if the changes you are doing have any impact on the live system (if a partition is in use, the kernel is not able to reload the partition table)
- Backup your original partition table. The MBR is exactly 512 bytes, so just doing a
dd if=/dev/sda bs=512 count=1 of=backupfile
should be enough to make a copy of the original MBR. A copy of the GPT is also stored after the MBR and before the first partition (in this case the first partition starts at sector 2048), so backing up this space should be enough to undo any damage you may cause to your disks dd if=/dev/sda bs=512 count=2048
).
- If at any point you think you messed up, simply do
dd if=backupfile of=/dev/sda
and you can start over.
- Now do the conversion. For starters, wipe your MBR with
wipefs /dev/sda
. You should only see something like the below, so go ahead and wipe it with wipefs -f /dev/sda
:
DEVICE OFFSET TYPE UUID LABEL
sda 0x1fe dos
- Now go ahead and create your GPT table with
gdisk
. The key here is when creating the partitions, make sure to match the start
and end
to be the same as before.
- Note that you don't have to create an extended partition in GPT, so just skip that one.
Here is a rundown of the commands you need to run. I did against a file, but you can do against sudo /dev/sda
instead.
$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.5
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries in memory.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-234441614, default = 2048) or {+-}size{KMGTP}: 2048
Last sector (2048-234441614, default = 234441614) or {+-}size{KMGTP}: 201011199
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): n
Partition number (2-128, default 2): 5
First sector (34-234441614, default = 201011200) or {+-}size{KMGTP}: 201013248
Last sector (201013248-234441614, default = 234441614) or {+-}size{KMGTP}: 234440703
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'
Command (? for help): p
Disk /dev/sda: 234441648 sectors, 111.8 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 75C2AE94-C3C0-4927-A4D2-48BBDECE3AD7
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 234441614
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 201011199 95.8 GiB 8300 Linux filesystem
5 201013248 234440703 15.9 GiB 8200 Linux swap
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
If your bootloader is on the same disk, there is a very good chance it will fail to boot. This is a much more involved process, so if that is the case... restore your MBR (remember to save the backupfile
), and you'd need to create an EFI BOOT partition (if I were you, I'd shrink down the swap and recreate it, to make some space - 500MB or so for the EFI boot partition), and make sure you get the installer on it. Make sure you boot from an UEFI boot media, or it would be tough to install grub in UEFI mode.
sudo fdisk -l /dev/sda
to your question. You also need to understand that the conversion will affect all partitions on the disk, not only one since you change from MBR-partition-table to GPT-partition-table.