LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 07:38 PM   #1
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,280

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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, 07:51 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,396

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

Original Poster
Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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, 03: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, 11:08 AM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,280

Original Poster
Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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, 05:38 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,396

Rep: Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048Reputation: 3048
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 08:09 AM
partition table restore mkzet Linux - Newbie 3 01-16-2011 07:24 PM
How to restore partition table without a CDROM? welson_sun Fedora - Installation 2 10-11-2005 04:30 PM
ext3 partition table restore pats Linux - General 1 07-22-2005 11:44 PM
Why can't I restore a partition table backup containing a reiser partition? oldweasel Linux - Software 2 05-23-2004 01:11 AM

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

All times are GMT -5. The time now is 04:33 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration