LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-23-2012, 05:00 PM   #1
snmcdonald
Member
 
Registered: Jul 2011
Location: Canada
Distribution: Debian, Arch
Posts: 55

Rep: Reputation: 0
Back up Partition Table and MBR Manually


How do you back up your partition table for a GPT system?

For a regular MBR and MBR partition it would be:

Quote:
dd if=/dev/sda of=/etc/mbr.bak conv=notrunc bs=512 count=1
How many bytes must I copy for a GPT table?
 
Old 12-23-2012, 05:29 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by snmcdonald View Post
How do you back up your partition table for a GPT system?

For a regular MBR and MBR partition it would be:
Code:
dd if=/dev/sda of=/etc/mbr.bak conv=notrunc bs=512 count=1
Watch out! That saves only the layout of the primary partitions. If one of those is an extended partition, none of the info for the logical partitions within it will be saved.
Quote:
Originally Posted by snmcdonald View Post
How many bytes must I copy for a GPT table?
You have to calculate that from the fields in the GPT header.
 
1 members found this post helpful.
Old 12-23-2012, 07:32 PM   #3
snmcdonald
Member
 
Registered: Jul 2011
Location: Canada
Distribution: Debian, Arch
Posts: 55

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rknichols View Post
Watch out! That saves only the layout of the primary partitions. If one of those is an extended partition, none of the info for the logical partitions within it will be saved.
Extended would be tricky as it appears to have varied offsets: wiki:EBR:examples

This has a nice solution: http://www.cyberciti.biz/faq/howto-copy-mbr/

Backup
Code:
# dd if=/dev/sda of=/tmp/backup-sda.mbr bs=512 count=1
# sfdisk -d /dev/sda > /tmp/backup-sda.sfdisk
Restore
Code:
# dd if=backup-sda.mbr of=/dev/sda
# sfdisk /dev/sda < backup-sda.sfdisk
Quote:
Originally Posted by rknichols View Post
You have to calculate that from the fields in the GPT header.
This blog gives the solution as:

Code:
# dd if=/dev/sda of=/etc/gpt.bak bs=512 count=34 conv=notrunc
GPT is 34 LBA... This assumes LBA is 512bytes... parted /dev/sda print or fdisk -l /dev/sda should list the sector/physical size.

Last edited by snmcdonald; 12-23-2012 at 07:59 PM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for ways to manually rebuild a partition table katto Linux - General 6 12-17-2010 10:31 AM
Need to manually edit partition table charrah Linux - General 3 08-25-2009 11:09 PM
manually write partition table for deleted partition tihcra Linux - Software 1 07-30-2009 12:26 PM
Manually create partition table? FogSwimmer Linux - Software 7 12-29-2005 06:28 PM
Uh-Oh... Manually Edit a Partition Table? davidbalt Linux - Software 11 03-02-2004 01:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:32 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
Open Source Consulting | Domain Registration