Backing up recovery partition

This is a discussion on Backing up recovery partition within the Tech Board forums, part of the Community Boards category; My new laptop came with Vista, and a recovery partition. I'm going to wipe them out and install Linux. But ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183

    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

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    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!
    Last edited by MK27; 07-08-2009 at 09:17 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    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.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    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.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    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.

  6. #6
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    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.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Yeah, apparently the 512 bytes MBR is 446 bytes boot code + 64 bytes partition table + 2 bytes padding according to wikipedia.

  8. #8
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    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
    Last edited by MK27; 07-10-2009 at 10:04 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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