1

Currently, my whole system is located at the end of my hdd. I'd like to move that data to the beginning and still have booting and other details working.

dd seems to do exactly what I want (to copy my data exactly how it is placed), but I'm not sure about things like booting, grub configs and so on. Will I need to set these things later, or will dd do this job for me?

1

(warning: this is very dangerous if you do not know what you are doing)

Yes, you can, but I do not recommend it (though I did it a few times, mostly to transfer a partition to another HDD).

dd if=/dev/sdaA of=/dev/sdaB

will transfer the data from sdaA to sdaB, but no checking will be done, all the partition will be copied (even the empty space), you must be sure that sdaB is bigger or equal sdaA (otherwise you overwrite the beginning of following partition), and the system most likely won't boot - you'd have to boot from rescue CD/USB, mount /dev/sdaB, modify grub configuration and re-run grub-install. And optionally resize the filesystem to reclaim any remaining space.

It is much better to create the filesystem on /dev/sdaB and copy the filesystem contents. You'd still have to re-run grub-install, but at least this is much safer.

  • What kind of problems may I get? Assuming I dded a partition (which contains my system) to another, empty partition (the new one). edit: and of course assuming that I didn't copy /proc/ or things like that. – Mário Feroldi Mar 3 '16 at 15:59
  • @thst You cannot copy /proc, you are copying the whole block device... The main problem is that you might overwrite something else by mistake and that cannot be undone. Do not forget to unmount the source partition before copying (that means you have to boot from CD), or at least remount it read-only in single user mode. This will also needlessly overwrite the whole space, which does not matter for HDD but it wears down SDD. – Radovan Garabík Mar 3 '16 at 16:07
  • Oh, I got it now. I think I will just install the distro and move /bin and /use/bin then. Is there any problem with that? Or is there a better way to do so? – Mário Feroldi Mar 3 '16 at 16:15
  • If the destination partition is not large enough you will get an out of space error, not overwrite the next partition. – psusi Mar 3 '16 at 23:29
1

"dd" by itself will not create the partitions, nor fix up grub. I recommend the use of a live rescue CD for this -- things like RIPlinux come with gparted, which can graphically define the moves and will most likely work correctly.

I'd also recommend a backup of the entire disk (if at all possible) before doing anything like this.

  • 1- do not dd mounted partition, or / 2- this is a good time to do a backup and try a restore. – Archemar Mar 3 '16 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.