C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 07-08-2009, 08:14 AM   #1
Registered User
 
Join Date: Dec 2006
Posts: 1,780
Backing up recovery partition

My new laptop came with Vista, and a recovery partition. I'm going to wipe them out and install Linux. But I want to backup the recovery partition first, just in case I need it later to send it in for warranty services or something.

The recovery partition is ~10GB. I usually wouldn't mind having that sitting on my harddrive... but it's a 80GB SSD, and space is scarce.

Just to make sure, can I back it up using dd like this? (assuming the SSD is at /dev/sda, and the recovery partition /dev/sda1)
Code:
dd if=/dev/sda of=partition_table skip=446 count=64
dd if=/dev/sda1 of=recovery_partition bs=4M
According to Wikipedia, the partition table starts at 446 offset, and is 64 bytes long.
Master boot record - Wikipedia, the free encyclopedia

and to restore
Code:
dd if=partition_table seek=446 count=64
#reboot
dd if=recovery_partition of=/dev/sda1 bs=4M
Thanks
cyberfish is offline   Reply With Quote
Old 07-08-2009, 09:14 AM   #2
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,941
If your question is, can I use "dd" to copy an entire file system the answer is yes.

Probably you want to make sure the block size is the same but it looks like you are on top of that. Using an offset works too, I've used this to place a filesystem after a compressed kernel on a floppy, since the kernel can boot itself, then the kernel finds the filesystem using the offset.

You can compress the resulting file, etc too.

OH! And remember you want to keep a copy of the windows boot sector!
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 07-08-2009 at 09:17 AM.
MK27 is online now   Reply With Quote
Old 07-09-2009, 06:41 AM   #3
Registered User
 
Join Date: Dec 2006
Posts: 1,780
Ah yes, I have used dd for partition backup. But I'm unsure about the partition table part.

Is it necessarily to keep the Windows boot sector? I thought they are all the same and can be easily had by doing a repair from a Windows installation disk (I have a Vista disk).

EDIT: but true, I could also back it up while I am at it. It's just 446 bytes.

Last edited by cyberfish; 07-09-2009 at 06:51 AM.
cyberfish is offline   Reply With Quote
Old 07-09-2009, 10:15 AM   #4
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,941
Quote:
Originally Posted by cyberfish View Post
EDIT: but true, I could also back it up while I am at it. It's just 446 bytes.
Hmmm, so it's contiguous with the partition table? I think when I have done this before I have just backed up a single chunk, probably 500 bytes, but I don't remember clearly...I definitely have put it back and had it work tho, but that was probably old copies of XP or Win 95.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is online now   Reply With Quote
Old 07-09-2009, 11:08 AM   #5
Chinese pâté
 
foxman's Avatar
 
Join Date: Jul 2007
Location: Canada
Posts: 406
Here's two way to save your primary partition table :
  • with dd - save the whole MBR (simpler than just saving the partitions descriptors) with a command like "dd if=/dev/sda of=mbr.bin bs=512 count=1"
  • with parted/fdisk - save your partition table information with a command like "parted /dev/sda unit s print > part-info.txt". With this information, you'll be able to recreate any of your original partition.

Also, I think most versions of dd consider a block size of 512 bytes by default; you should always specify it with the "bs=" option to be safe.
__________________
I hate real numbers.
foxman is offline   Reply With Quote
Old 07-09-2009, 11:44 AM   #6
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
Quote:
Originally Posted by MK27 View Post
Using an offset works too, I've used this to place a filesystem after a compressed kernel on a floppy, since the kernel can boot itself, then the kernel finds the filesystem using the offset.
Dude, you are showing your age here. . . This is no longer the case, and has not been the case for many years. I think that ended some time in the 1.34.x era, but I cannot recall.
Kennedy is offline   Reply With Quote
Old 07-10-2009, 07:50 AM   #7
Registered User
 
Join Date: Dec 2006
Posts: 1,780
Yeah, apparently the 512 bytes MBR is 446 bytes boot code + 64 bytes partition table + 2 bytes padding according to wikipedia.
cyberfish is offline   Reply With Quote
Old 07-10-2009, 10:01 AM   #8
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,941
Quote:
Originally Posted by Kennedy View Post
Dude, you are showing your age here. . . This is no longer the case, and has not been the case for many years. I think that ended some time in the 1.34.x era, but I cannot recall.
Well, I sure did it a few times with 2.1+ kernels. I have such a floppy in my closet somewhere, I could check it just to be sure but I believe there is no bootloader or anything, just a compressed kernel written with a pointer to the root device and the offset where the filesystem begins. Maybe there is a bootloader...hmmm. Much the same anyway, and you can certainly still do that (raw image is grub + fs w/ kernel), altho using floppies may be a too tight a squeeze
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 07-10-2009 at 10:04 AM.
MK27 is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk Partition Stuff CodeMonkey Tech Board 15 12-19-2008 11:53 AM
Partition Problem anirban Tech Board 1 09-30-2007 03:32 AM
Reading a (possibly EXT2) partition with Windows nickname_changed Linux Programming 5 08-20-2003 07:43 PM
Linux/Windows partition Fyodorox A Brief History of Cprogramming.com 11 04-24-2002 08:16 AM
hardware interaction in c vineetwadwekar C Programming 6 03-29-2002 09:01 AM


All times are GMT -6. The time now is 04:27 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22