LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-07-2015, 06:38 PM   #1
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,327

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
How to? Partition table backup and restore


First, the way I've done it up until now, and then a question.

---

The old way (still works if you only have primary partitions and don't use GPT):

save: dd if=/dev/sda of=./mbr.bin bs=512 count=1
restore: dd if=./mbr.bin of=/dev/sda bs=512 count=1

(the above copies all of the MBR, not just the partition table, but that is normally OK)

But the above will not recreate extended partitions, since extended partitions are just a chain of more partition tables spread across the disk. So we could use this instead:

save: sfdisk -d /dev/sda > ./sda_partition_table.sfdisk
restore: sfdisk --force /dev/sda <./sda_partition_table.sfdisk

However, the above will not work with GPT partition tables, nor will it work with partitions larger than 2TB.

Question: So what is the best CURRENT strategy for backing up both partition table types (GPT and MBR), and extended partition data, and large partitions? I don't currently use GPT or have large partitions, but I'm sure I will in the future, so I'd like to know how to properly backup and restore this partition info going forward.

Thanks!
 
Old 01-07-2015, 06:51 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,831

Rep: Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006
Rod has a full suite of utilities - including sgdisk; see his web page.
 
Old 01-07-2015, 11:01 PM   #3
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,327

Original Poster
Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Thanks. That looks like exactly what I need. I found the commands in the "gdisk" package for LinuxMint (my desktop distro), but the package was named "gptfdisk" on SystemRescueCD (my recovery distro).
 
Old 01-08-2015, 02:06 AM   #4
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Debian stable (and OpenBSD-current)
Posts: 1,187

Rep: Reputation: 285Reputation: 285Reputation: 285
With GPT disks there is already a backup of the table at the "end" of the disk; if the primary partition table is damaged a program like gdisk will offer to recover the table from this backup. This is one of the advantages of GPT vs. MBR.
 
Old 01-08-2015, 10:08 AM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,327

Original Poster
Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
I am more concerned about making sure I am set up, backup-wise, for a bare metal restore on a new disk, not so much for repairing an existing disk using GPT's backup partition table at the end. Backing up the actual data on the partitions, that is easy. I guess backing up the partition table is easy too, I just didn't know how to do it for GPT. I was mentally still stuck back in the MBR, dd, and sfdisk days. My plan, up until I just learned about these gdisk tools, would have been to manually recreate the partitions. I have not read through the man pages on gdisk yet, but I am assuming it can dump the partition info to a file and also recreate partitions based on input from a previous dump file, like sfdisk can.
 
Old 01-08-2015, 04:38 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,831

Rep: Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006
Similar but different - you get a binary file as output, not text. But you can feed it back in via the "-l" parameter.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restore old partition table psyphy Linux - General 12 06-01-2012 07:09 AM
partition table restore mkzet Linux - Newbie 3 01-16-2011 06:24 PM
How to restore partition table without a CDROM? welson_sun Fedora - Installation 2 10-11-2005 03:30 PM
ext3 partition table restore pats Linux - General 1 07-22-2005 10:44 PM
Why can't I restore a partition table backup containing a reiser partition? oldweasel Linux - Software 2 05-23-2004 12:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:09 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