View
105
Download
2
Category
Preview:
DESCRIPTION
If you don't want to take any chances with your data, it is recommended that you backup hard disk partition table. Last Friday I was discussing some issues with one of our customer and he pointed out me dd command.
Citation preview
AboutForumHowtos & FAQsLow graphicsShell ScriptsRSS/Feed
nixcraft - insight into linux admin work
Linux: How to backup hard diskpartition table (MBR)by nixCraft on July 10, 2006 · 12 comments· Last updated September 3, 2007
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
1 of 9 03/27/2013 09:43 PM
If you don't want to take any chances with your data, it isrecommended that you backup hard disk partition table. LastFriday I was discussing some issues with one of our customerand he pointed out me dd command.
Backup MBR with dd command
dd the old good command which now backup partition tables even writes CDs ;).Backing up partition is nothing but actually backing up MBR (master bootrecord). The command is as follows for backing up MBR stored on /dev/sdX or/dev/hdX :# dd if=/dev/sdX of=/tmp/sda-mbr.bin bs=512 count=1
Replace X with actual device name such as /dev/sda.
Now to restore partition table to disk, all you need to do is use dd command:# dd if= sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446 seek=446
dd command works with Solaris, HP-UX and all other UNIX like operatingsystems. Read man page of dd for more info.
Tweet
Like 10
You should follow me on twitter here or grab rss feed to keep track of new
changes.
Featured Articles:
30 Handy Bash Shell Aliases For Linux / Unix / Mac OS XTop 30 Nmap Command Examples For Sys/Network Admins25 PHP Security Best Practices For Sys Admins20 Linux System Monitoring Tools Every SysAdmin Should Know20 Linux Server Hardening Security TipsLinux: 20 Iptables Examples For New SysAdmins
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
2 of 9 03/27/2013 09:43 PM
Top 20 OpenSSH Server Best Security PracticesTop 20 Nginx WebServer Best Security Practices20 Examples: Make Sure Unix / Linux Configuration Files Are Free FromSyntax Errors15 Greatest Open Source Terminal Applications Of 2012 My 10 UNIX Command Line MistakesTop 10 Open Source Web-Based Project Management SoftwareTop 5 Email Client For Linux, Mac OS X, and Windows UsersThe Novice Guide To Buying A Linux Laptop
{ 12 comments… read them below or add one }
1 Wartin April 15, 2010 at 1:37 pm
dd if= sda-mbr.bin
it has a blank space after =, it should read
dd if=sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446 seek=446
Reply
2 PT August 10, 2010 at 5:14 am
This advice does not work if you have an extended partition table.
Reply
3 VernDog January 26, 2011 at 4:26 pm
Wrong! This method DOES WORK with extended , primary partitions.I’ve used it all the time, to both backup & restore. Just remember tobackup MBR if you add any changes to partitions.
Reply
4 brendan December 1, 2012 at 11:29 pm
No. He’s right. The MBR lists whether a partition is active, itstype, start point and number of sectors within the partition. MBRlists this for a maximum of 4 partitions. This not include logicalpartitions. They are described within the extended partition.They are not described in the MBR.
Reply
5 Jack October 9, 2010 at 9:47 am
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
3 of 9 03/27/2013 09:43 PM
PT,
You can use sfdisk to backup extended partition table.
sfdisk -d /dev/sdX > backup-sdX.sf
Restore:
sfdisk /dev/sdX < backup-sdX.sf
Reply
6 jns August 22, 2011 at 6:07 am
The restore line corrupted my entire partition table…beware, i guess…
Reply
7 victor September 3, 2011 at 12:18 pm
jns, it could be because only one seek is needed.there are 446b of MBR, 64b of Partition Table and 2 as end (0x55aa). {=512b}if skip and seek aren’t synonimous, you seek 446 + 446.thus, command line must bedd if=sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446ordd if=sda-mbr.bin of=/dev/sdX bs=1 count=64 seek=446
Reply
8 victor September 3, 2011 at 12:45 pm
i’m sorry, i’m mistake. error coud be if mbr is all zero. then you must addconv=notrunc for no file optimization.ej:2GB filedd if=/dev/zero of=afile bs=1 seek=2GB count=1 (file size in hd<1kb)ordd if=/dev/zero of=afile bs=1 count=2GB (file size in hd=2gb)
size must be specific in bytes, 2gb is only for easy read.note: a little bs spend more time
Reply
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
4 of 9 03/27/2013 09:43 PM
9 Mr_T September 13, 2011 at 7:31 pm
Victor,In your first post, could you clarify the units you are using for mbr and thepartiton table and what is the “2 as end” means. Its not intuitive to theuninitiated.
Thanks
Reply
10 brendan December 1, 2012 at 11:42 pm
He’s talking about bytes. 446 bytes of Bootstrap code, then 4 partitionentries x 16 bytes = 64 bytes, then 2 bytes of signature (a 16 bitnumber = 0101010110101010). This is 55aa in hex and 21930 indecimal.
Reply
11 brendan December 1, 2012 at 11:44 pm
446 + 64 + 2 = 512 bytes :)
Reply
12 Marek December 7, 2011 at 11:19 am
What about GPT ?
Reply
Leave a Comment
Name *
E-mail *
Website
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
5 of 9 03/27/2013 09:43 PM
You can use these HTML tags and attributes for your code and commands:<strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href=""title="">Security Question:What is 12 + 13 ?
Solve the simple math so we know that you are a human and not a bot.
Submit
Tagged as: backup hard disk, dd command, disk partition, master boot record, mbr, partition table
Previous post: May the best team win
Next post: Linux Iptables block remote X Window server connection
GET FREE TIPS & NEWSMake the most of Linux Sysadmin work!
Enter your email Join
Youtube | Twitter | Google +
Loading
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
6 of 9 03/27/2013 09:43 PM
nixCraft
Like
30,870 people like nixCraft.
Facebook social plugin
Related Posts
Restore Debian Linux Grub boot loader
How do I forcefully unmount a Linux disk partition?
Re-read The Partition Table Without RebootingLinux System
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
7 of 9 03/27/2013 09:43 PM
How Do I Make Linux / UNIX Filesystem BackupWith dd?
HowTo: Linux Check IDE / SATA Hard Disk TransferSpeed
Linux Creating a Partition Size Larger Than 2TB
Quickly Backup / dump MySql / Postgres databaseto another remote server securely
Fix a dual boot Windows Vista and Linux problem
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
8 of 9 03/27/2013 09:43 PM
Perl script to monitor disk space and send an email
Repairing ReiserFS file system with reiserfsck
©2004-2013 nixCraft. All rights reserved. Cannot be reproduced withoutwritten permission.Privacy Policy | Terms of Service | Questions or Comments | Copyright Info |Sitemap
Linux: How to backup hard disk partition table ... http://www.cyberciti.biz/tips/linux-how-to-backup-...
9 of 9 03/27/2013 09:43 PM
Recommended