Linux gpt to dos

Adventures with Hybrid EFI

My gaming PC has been long overdue due for a reformat. I naively allocated only 30GB to the Windows partition (and the other 120GB to 3 flavours of Linux) thinking I wouldn’t use Windows for much other than Starcraft 2, but a few months back I had the urge to play Battlefield 2 again. Ever since installing and fully patching it disk space has been running pretty tight. I had to disable sleep, hibernation as well as system restore and still only had 4GB of free space, so my filesystem became fragmented easily. With the release of Windows 8 Customer Preview (download it free here), I figured it was a good time to reformat my disk and reinstall all my OSs from scratch.

I figured while I’m at it, I would make all of the big changes at once and enabled EFI booting on my Gigabyte GA-Z68A-D3H board. Little did I know that when the BIOS says «EFI,» it really means Gigabyte’s «Hybrid EFI» implementation and not UEFI (although in retrospect, the fact that I made the change in the BIOS should have been enough of a hint, right?). With Hybrid EFI enabled, Windows 7 and Windows 8CP installed perfectly and even created a nice GPT disk layout so reinstalled my games and activated Windows 7. Then I rebooted to play around in Windows 8CP for a bit (I do not like it, btw).

I then tried installing Fedora 16. To my surprise EFI booting failed every time, despite the all of the Fedora 16 installation media being EFI-capable. When attempting to boot from my Fedora 16 Live (x86_64) USB key I just would get a black screen with «. » printed one dot a time and then it would proceed to fall back to the next boot device (Windows boot manager on the hard disk). Upon re-examining my BIOS settings, I was disappointed to find that the setting was actually called «CD/DVD EFI Boot Option» indicating that perhaps USB EFI booting was not supported. Fair enough, I burnt the same F16 image I was using on the USB key to a CD and tried again. The same «. » text appeared.

It was then as I went back to boot Windows 7 that I discovered my attempts to set it as the default OS from Windows 8CP removed my capability of booting Windows 7 somehow. At this point it was 2AM and I was fed up with this stupid Hybrid EFI. I looked for a way to revert to a good old MS-DOS/MBR partition layout. After some Googling I stumbled across Rod Smith’s website. He has extensive documentation on EFI booting, including with Gigabyte’s implementation of Hybrid EFI. He says that it shares a large amount of code with EFI DUET (tianocore) and although it does work natively with Windows 7, it is not a full UEFI implementation. That would explain the problems I was having with Fedora, then.

Читайте также:  Starting ssh server linux

The actual GPT to MBR conversion

Through the Rod Smith’s guidance and a few dirty tricks, I was successfully able to convert my GPT partition — without data loss or deleting any partitions — and then boot Windows 7 in legacy/MBR mode. In order to do this you’ll need your Windows installation media at hand as well as a copy of the Fedora 16 Live media. If you don’t have a copy of Fedora 16 Live handy, you can download the Live media ISO (64-bit) from a local mirror here. See the Fedora 16 Installation Guide for details on burning this image to a CD or on creating a bootable USB key.

Keep in mind that at this point I only had 3 partitions and a bunch of unpartitioned space on the disk, so conversion was a rather straightforward process (all GPT partitions mapped directly to primary partitions). Although it is theoretically possible to convert GPT partitions with >4 partitions by defining which ones are to be logical partitions after conversion, I have not tested this.

  1. Boot your Fedora 16 Live media and wait for your session to start. If you’re having troubles booting, press Tab at the boot loader screen and try booting with the nomodeset parameter added.
  2. Depending on your graphics card, you’ll either be presented with the new Gnome 3 Shell or with the traditional interface. Start a terminal session by putting your mouse in the top right corner of the screen and typing «terminal» in the search (Gnome Shell) or by selecting Applications > System Tools > Terminal (traditional interface)
  3. Install gdisk:

That’s it! You should now have a bootable installation of Windows 7 on a MBR partition layout.

Источник

Как конвертировать MBR в GPT в Linux

Master Boot Record (MBR) использует стандартную таблицу разделов BIOS, тогда как GPT использует унифицированный расширяемый интерфейс встроенного ПО (UEFI). Диск GPT имеет ряд преимуществ перед диском MBR, поскольку на нем можно создать более четырех основных разделов. Если размер диска превышает 2 ТБ, требуется GPT. Итак, давайте рассмотрим, как конвертировать MBR в GPT в LinuxВ этой статье также рассказывается об отличном программном обеспечении, которое может восстановить данные, если вы потеряете важные файлы после конвертации.

конвертировать mbr в gpt в linux

В этой статье

Часть 1. Можно ли конвертировать MBR в GPT в Linux без потери данных?

Да, вы можете конвертировать MBR в GPT в Linux без потери данных. К счастью, решение оказалось однострочной командой, выполняемой с загрузочного CD (или загрузочного USB) под управлением Linux, которая может избавить от всех процессов удаления и восстановления данных.

Часть 2. Почему вы должны конвертировать MBR в GPT в Linux?

Таблица разделов GPT (GUID Partition Table) является более надежной, чем MBR (Master Boot Record), что позволяет увеличить объем и обеспечить более надежную защиту данных. Схема MBR с 32-разрядными записями позволяет использовать максимальный размер диска всего 2 ТБ. Кроме того, допускается только четыре основных раздела. С другой стороны, структура GPT поддерживает разделы размером более 2,2 ТБ. Вот почему конвертирование MBR в GPT имеет большое значение, поскольку MBR больше не поддерживает диски большего размера. С разделами GPT последние 64-разрядные дистрибутивы поддерживают системы UEFI.

Часть 3. Как конвертировать диск из MBR в GPT в Linux?

Для конвертирования MBR-диска в GPT мы будем использовать программу с поддержкой GPT, например gptfdisk или gdisk. Инструмент gdisk — это программа с текстовым меню для создания таблиц разделов и работы с ними.

Примечание: Перед началом работы сделайте резервную копию системы и подготовьте живую загрузку Linux для ее спасения. Очень легко ошибиться!

Шаг 1. Установите gdisk на компьютер с Linux

Сначала необходимо установить gdisk в системе. Для его установки выполните следующую команду:

После установки gdisk выполните следующие действия:

Шаг 2. Составьте список и идентифицируйте диски

Чтобы составить список дисков в вашей системе Linux, выполните следующую команду.

определить диски

Прокрутите вывод этой команды и найдите диск, необходимый для конвертирования из MBR в GPT.

Шаг 3. Запустите утилиту gdisk

В терминале введите следующую команду:

Появится запрос на ввод имени диска. Введите имя диска и нажмите ReturnТеперь эта команда выполнит сканирование и отобразит таблицу разделов на этом разделе.

запустите утилиту gdisk

(Не забудьте заменить /dev/sda1 на правильный системный диск, который на многих системах может быть /dev/sda)

Шаг 4. Выполните команду для создания таблицы разделов GPT

Введите w и затем нажмите Return Таблица разделов GPT будет записана на указанный диск. Если появится запрос, нажмите y, чтобы подтвердить свой выбор.

создать таблицу разделов gpt

Шаг 5. Подтвердите конвертацию

Диск теперь конвертирван из MBR в GPT. Вы можете проверить это, выполнив следующую команду.

Источник

Converting between GPT and MBR hard drive without losing data

NOTE: I don’t know a lot about hard drives so you’re going to have to work with me here. My question: Can I change my hard drive from GPT to MBR without losing data on it? NOTE: there isn’t an operating system on the laptop which I’m going to do this on. I’m going to boot from a USB and try to convert it.

Converting is not possible. You have to remove the partition and create a new one. GPT is superior to MBR though, so I would keep GPT. One of the limits of MBR is the maximum size a partition can be. I believe 2 TB is its limit.

It’s true that GPT is superior to MBR, therefore many partition layouts cannot be converted to MBR; but some layouts can. Post the result of Linux command gdisk -l /dev/sdX (substitute sdX with your HDD) so we can tell more.

Why do you want to do this conversion? It may not be necessary, and in fact may be quite inadvisable. OTOH, there are some legitimate reasons to want to do this (such as if you want to use the disk with a GPT-unaware OS).

3 Answers 3

You can convert from GPT to MBR and MBR to GPT without data loss (I have tried that) with gdisk in Linux.

Run command gdisk /dev/sdx with sdx as per your HDD partition

GPT fdisk (gdisk) version 1.0.1 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help): 

MBR to GPT

Enter w to write GPT partition on disk.

Press y to confirm your choice.

GPT to MBR

Enter r to enter in recovery and transformation options.

Enter g to convert GPT to MBR partition.

For Information

You can check table by command p.

Warning: You will lose your boot loader (Ex. GRUB)

You can check if your partition is GPT or MBR now gdisk /dev/sdx with sdx as per your HDD partition in Partition table scan(p)

Something’s not right. In gdisk recovery and transformation options the g option will only recreate the protective MBR on top of the GPT but not actually convert the disk to GPT. The right way to convert a GPT disk to MBR is using fdisk o option but it does destroy data on the disk.

I observed this behaviour with gdisk v1.0.3 and fdisk from util-linux 2.33.1 when I was trying to convert an empty GPT disk (no partitions) to MBR

«Converting» MBR to GPT this way (from a terminal in GParted or some other live distro) is good enough to get Windows 10 to install in UEFI mode, so even if it’s not 100% right it’s just what I need. (I care about keeping data because I dumped the disk structure from an old machine using Clonezilla and then am putting the new Win 10 in unallocated space.)

This successfully converted my disk back to MBR but did not mark the Windows partition as Active and the disk was not bootable. I ended up using DISM to clone the Windows partition after doing a fresh install to restore the structure of the disk while preserving data.

Making your drive bootable

This is an enhancement to the information provided by Krunal and clarkttfu with more details on the steps to create a BIOS boot partition and install grub to it.

If you are changing the partition table on a a boot drive you will need to create a new «BIOS boot partition» for grub to store the bootloader in. These examples use the drive /dev/sda which will usually be the boot drive.

First, validate that there is space before the current first partition to support a boot partition, fisk -l should show that the first partition starts at sector 2048:

johnf@ubuntu:~$ sudo fdisk -l /dev/sda [. ] Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 499711 497664 243M 83 Linux /dev/sda2 501758 125829119 125327362 59.8G 5 Extended /dev/sda5 501760 125829119 125327360 59.8G 8e Linux LVM 

If it does then you have the space required to create the partition. If it doesn’t you cannot follow these instructions and have a bootable system.

Use gdisk to convert the partition to gpt, you can now create a new partition for your MBR, run sudo gdisk /dev/sd, enter n to create a new partition, accept the proposed partition number, you should be able to select a first sector of 34, set the partition type of ef02:

Command (? for help): n Partition number (2-128, default 2): First sector (34-4294967262, default = 4294922240) or size: 34 Last sector (34-2047, default = 2047) or size: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): ef02 Changed type of partition to 'BIOS boot partition' 

You can now write your partition table with w . Run partprobe again and then install grub:

johnf@ubuntu:~$ sudo partprobe johnf@ubuntu:~$ sudo grub-install /dev/sda Installing for i386-pc platform. Installation finished. No error reported. 

You should now be able to reboot your machine without issue.

Источник

Оцените статью
Adblock
detector