After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680524 - support backup/restore of the harddisk partition table (MBR)
support backup/restore of the harddisk partition table (MBR)
Status: RESOLVED OBSOLETE
Product: gparted
Classification: Other
Component: application
0.13.0
Other Linux
: Normal enhancement
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2012-07-24 13:02 UTC by Liv
Modified: 2020-11-13 10:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Liv 2012-07-24 13:02:50 UTC
Currently GParted allows to create partition tables, but not to backup or restore (from backup) existing partition tables. 

I'm no expert, but from reading several sources on partition table backups [1][2] it seems to me that making a backup of a disk's partition table is of paramount importance. With a broken partition table (for whatever reason) and no backup, it can be quite difficult to recover the underlying data even if the data itself is uncorrupted. 

From [2], backing up the MBR should be as simple as: 
dd if=/dev/hda of=backup-hda.mbr count=1 bs=512

Backing up the partition entries of the extended partitions: 
sfdisk -d /dev/hda > backup-hda.sf

Restoring the Master Boot Record:
dd if=backup-hda.mbr of=/dev/hda

Restoring extended partitions entries:
sfdisk /dev/hda < backup-hda.sf

Unless there are good arguments against adding such a feature---although just about anything that GParted does is dangerous to the user's data---, it seems to me that it should be relatively straightforward to add this to GParted > Device menu entry. And this would allow for a very easy way for non-technical users to backup a crucial piece of information about their hard drives. 

[1] http://www.partimage.org/Partimage-manual_Backup-partition-table
[2] http://www.cyberciti.biz/tips/linux-how-to-backup-hard-disk-partition-table-mbr.html
Comment 1 Curtis Gedak 2012-07-24 16:12:15 UTC
There could be some value to adding such a feature.  Of course, the process of restoring an incorrect partition table can cause data loss too.  Hence we most often solve lost or incorrect partition tables in the forum after much analysis.

The MSDOS partition table (MBR) is one of many partition tables supported by GParted.  Do you have similar backup and restore commands for other partition tables, such as GPT?
Comment 2 Liv 2012-07-25 09:35:30 UTC
(In reply to comment #1)
> Of course, the process of
> restoring an incorrect partition table can cause data loss too.  
> 
This is why there should be additional loud warnings in the pop-up window. 

> The MSDOS partition table (MBR) is one of many partition tables supported by
>
There seems to be another way [1] to backup MSDOS partition tables using sfdisk: 
sfdisk -d /dev/hda > hda.out

And to restore: 
sfdisk /dev/hda < hda.out


> GParted.  Do you have similar backup and restore commands for other partition
> tables, such as GPT?
>
As for GPT, here's what the man page of sfdisk has to say: 
sfdisk  doesn't  understand  GUID  Partition  Table (GPT) and it is not
       designed for large partitions. In particular case use more advanced GNU
       parted(8).

Chances are that 'libparted' supports backing-up/restoring partition tables for all the types already supported by GParted (MSDOS, GPT, etc.), and that this functionality can be implemented without adding a new dep, sfdisk. 

[1] http://linuxpoison.blogspot.fr/2008/02/howto-take-backup-of-partition-table.html
Comment 3 Curtis Gedak 2012-07-28 17:36:33 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > GParted.  Do you have similar backup and restore commands for other partition
> > tables, such as GPT?
> >
> As for GPT, here's what the man page of sfdisk has to say: 
> sfdisk  doesn't  understand  GUID  Partition  Table (GPT) and it is not
>        designed for large partitions. In particular case use more advanced GNU
>        parted(8).
> 
> Chances are that 'libparted' supports backing-up/restoring partition tables for
> all the types already supported by GParted (MSDOS, GPT, etc.), and that this
> functionality can be implemented without adding a new dep, sfdisk. 

Hi Liviu,

The msdos partition table has been around for decades, and as such there are more tools available for working with msdos partition tables, (e.g., fdisk, sfdisk, cfdisk, parted).

GPT is designed for larger capacity disk devices, and has not been around as long.  In the Linux world, the two tools I can think of to edit GUID partition tables are gdisk, and parted.

I was hoping that since you were interested in this functionality that you would further research how one might backup other partition tables.

The libparted API documentation can be viewed at:
http://fossies.org/dox/parted-3.1/index.html

I do not recall seeing any API calls to backup partition tables.  But then again I may have missed or overlooked something.
Comment 4 Liv 2012-07-30 10:17:43 UTC
(In reply to comment #3)
> GPT is designed for larger capacity disk devices, and has not been around as
> long.  In the Linux world, the two tools I can think of to edit GUID partition
> tables are gdisk, and parted.
> 
I wasn't sure what GPT was and how it worked. Anyways, here's what I found. 

I couldn't see anything in parted or libparted related to backing up partition tables. 

But I did find out how to use gdisk [0] to backup GPT partition tables [1][2][3]. 
To backup GUID partition table:
sgdisk -b sda_gpt_backup /dev/sda

To restore GUID partition table:
sgdisk -l sda_gpt_backup /dev/sda

(All resources that I've linked to are worth a read as understanding how GPT partition tables work is paramount before providing a GUI interface to it.) Here's another link discussing the differences between MSDOS and GPT tables [4][6]. And a blog post of someone describing how he couldn't use (g)parted to restore GPT partition tables on a Mac and used gdisk instead [5]. 

The [1] link also discusses how to backup/restore LVM metadata. There is a more in-depth explanation in the Red Hat manuals [7]. Not sure whether this is relevant. 


[0] http://www.rodsbooks.com/gdisk/index.html
[1] http://blog.sleeplessbeastie.eu/2012/05/14/how-to-backup-dos-type-partition-table-gpt-and-lvm-metadata/
[2] http://www.rodsbooks.com/gdisk/sgdisk.html
[3] http://www.rodsbooks.com/gdisk/repairing.html
[4] https://wiki.archlinux.org/index.php/GUID_Partition_Table
[5] http://www.7bits.nl/blog/2012/01/02/mac-gpt-partition-table-recovery
[6] http://www.sysresccd.org/Sysresccd-Partitioning-EN-The-new-GPT-disk-layout#GPT_and_protective_MBR
[7] http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/index.html
Comment 5 Curtis Gedak 2012-08-01 16:54:03 UTC
Thanks Liviu for the extra links and detective work to learn how to backup and restore GPT partition tables.

There are other partition tables supported by parted/gparted if you would like to investigate how these might be backed up and restored.
Comment 6 Liv 2012-08-01 21:11:38 UTC
I checked and GParted seems to support quite a large number of partition table types, many of them "exotic", I understand. Unfortunately I'm unlikely to dig up backup/restore methods for each of those. 

I would suggest, though, that implementing a GUI interface to backup/restore MSDOS and GPT tables would already be immensely useful. It seems to me that MSDOS/GPT already covers a vast majority of users. Moreover, the list of supported tables could be expanded in the future, as methods to deal with them are discovered.
Comment 7 André Klapper 2020-11-13 10:41:26 UTC
bugzilla.gnome.org is being replaced by gitlab.gnome.org. We are closing all old bug reports and feature requests in GNOME Bugzilla which have not seen updates for a long time.

If you still use gparted and if you still see this bug / want this feature in a recent and currently supported version, then please feel free to report it at
https://gitlab.gnome.org/GNOME/gparted/-/issues/
by following the guidelines at
https://wiki.gnome.org/Community/GettingInTouch/BugReportingGuidelines

Thank you for creating this report and we are sorry it could not be implemented so far (volunteer workforce and time is limited).