Results 1 to 8 of 8

Thread: Using dd to copy a SINGLE partition

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Location
    TX
    Beans
    316
    Distro
    Hardy Heron (Ubuntu Development)

    Using dd to copy a SINGLE partition

    I have a full 320gb hdd with two partitions, as small root, and a big home.

    I have a 1TB new hdd that I created two partitions as well, both bigger than the old ones. I formatted it ext 3.

    From a liveCD I copied my whole /home from my old hdd to the new hdd.

    Now, I wanted to copy the whole root over. But, it doesn't work becaues of weird files like /proc. So, I tried using dd

    Code:
    sudo dd if=/dev/sda1 of=/dev/sdb1
    This should have copied the small partition of the 320gb drive (with my install on it) to the small partition of the new drive (with nothing on it). Right? I wasn't quite sure what happens if you dd a partition to a larger partition. But, in any case, I mount /dev/sdb1 and it's empty, when it should have all my install on it. Any other ideas on how to transfer my install over to this new hdd would be appreciated.

  2. #2
    Join Date
    Apr 2006
    Beans
    313

    Re: Using dd to copy a SINGLE partition

    1) Boot to a LiveCD and make sure the drive you want to copy is unmounted.
    2) Use the following command to save it as a drive image:
    Code:
    dd if=/dev/sda1 of=/dev/sdb1/imagename.img
    If the advice you're given in this forum solves your issue, please mark the post as [SOLVED] in consideration to others.
    Registered Linux User: 448689 | How To: Secure the GRUB Boot Loader
    [ Acer Aspire 5535 | Arch Linux x86_64 | Compiz WM ]

  3. #3
    Join Date
    Jun 2008
    Beans
    1

    Re: Using dd to copy a SINGLE partition

    May I humbly suggest dd-rescue - comes stock on the gparted live CD which has been a lifesaver.

    http://www.gnu.org/software/ddrescue/ddrescue.html

    -w

  4. #4
    Join Date
    Feb 2008
    Location
    TX
    Beans
    316
    Distro
    Hardy Heron (Ubuntu Development)

    Re: Using dd to copy a SINGLE partition

    Quote Originally Posted by munkyeetr View Post
    1) Boot to a LiveCD and make sure the drive you want to copy is unmounted.
    2) Use the following command to save it as a drive image:
    Code:
    dd if=/dev/sda1 of=/dev/sdb1/imagename.img
    ok, so then you are creating a file, on the sdb1 partition? Is that just going to work? Is it what I needed to do in the first place?

    If I did that it seems like that creates an image file, sitting on /dev/sdb1. I'm confused as to what that is going to do. Work, possibly, but I would like to understand what is happening.

    I just want to effectivly move my installation to the new hdd. You are suggesting that I make an image file of my whole root partition and put it on my new root partition. How is that going to work when I run the system, and it needs to save more stuff, and stuff? What exactly is an image file, is it just a folder with a whole file tree in it? Sorry maybe I should have posted in the noob forum.

    May I humbly suggest dd-rescue
    cool, but what would I do with it? Does it have a 'copy your partition to another bigger partition on your new hard drive' option or something?
    Last edited by BetterSense; August 11th, 2008 at 06:11 PM.

  5. #5
    Join Date
    Apr 2006
    Beans
    313

    Re: Using dd to copy a SINGLE partition

    sorry, i misread and was under the impression that you wanted to create a backup of the drive, which creating the image would do.
    If the advice you're given in this forum solves your issue, please mark the post as [SOLVED] in consideration to others.
    Registered Linux User: 448689 | How To: Secure the GRUB Boot Loader
    [ Acer Aspire 5535 | Arch Linux x86_64 | Compiz WM ]

  6. #6
    Join Date
    Feb 2008
    Location
    TX
    Beans
    316
    Distro
    Hardy Heron (Ubuntu Development)

    Re: Using dd to copy a SINGLE partition

    That's what I thought, thanks. I found a partimage tutorial on the internets that I will try. If that fails, is it possible to reinstall, then copy, like, /bin, /usr, and /share from your old install over and have it effectively be the same? The only things keeping me from just renistalling is I had a hard time getting my scanner, my dual monitors, sound, japanese fonts all configured.

  7. #7
    Join Date
    Jul 2006
    Location
    vancouver, bc
    Beans
    44
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Using dd to copy a SINGLE partition

    Hi, just stumbled upon this. I'm trying to use dd to restore a partition from a backed up image. Anyone know how to mount an image to RAID? (not sure if possible)

    Anyway, I found this on a gentoo forum:

    Code:
    telinit 1; cp /dev/sda /dev/sdb
    http://www.unix.com/gentoo/30298-how...partition.html

    for copying a whole drive. Not sure if that works with GUI running. There are more ideas on that link.

    For the record you don't need to use dd to copy a root partition and have it be functional. Various "weird" directories like /proc as you mention only contain date that is used when the system is running. I'm pretty sure it's of no importance to save for the next reboot. I've usually just used rsync instead of cp because I like all the info it gives me to make sure I'm not making a mistake. I usually use:

    Code:
    rsync -avnu --stats --progress / /mnt/newlocation
    And I've never had problems. I even copy the boot partition this way.

    As for the GRUB, Use the super GRUB disk. I am in love with this simple liveCD ever since I discovered it and I can't recommend it enough. Basically the cp command copies all the important data - all you need is the GRUB on the MBR. This is normally a kind of tricky thing to do because MBR is annoying. But with the Super GRUB CD all you do is boot the cd, select the partition where your /boot is and it writes the MBR automagically and next time you boot fine without the CD. Sometimes it is harder if you have many bootable partitions to remember the drive numbers but that is exactly when you need SUPERGRUB to help you. The GUI of supergrub is a very primative and confusing at first but once you get it it is perfect. It won't harm anything unless you have a Windoze partition to worry about. Yay SuperGRUB!

    PS if you prefer to use cp over rsync use this:
    Code:
    cp -dpRx / /mnt/newlocation
    which I got from:
    http://www.howtoforge.com/software-r...debian-etch-p2
    Last edited by hotdoog; February 9th, 2009 at 07:12 AM. Reason: more complete
    I am what I am because of who We all are.
    {I am a Bittorrent addict}

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •