LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   clone a harddrive (https://www.linuxquestions.org/questions/linux-hardware-18/clone-a-harddrive-4175663186/)

Pedroski 10-25-2019 07:37 PM

clone a harddrive
 
I just bought a new Samsung laptop, it is the same as this older one, just better processors, i5 third generation, I'm told.

I use Ubuntu, the latest LTS version. I have my old laptop set up nicely, all the things installed just as I need them. Things I can't even remember installing!

Can I simply clone this hd onto the new computer's hd?

Or is that not a good idea?

If this is advisable, I'm thinking of removing the hd from the new laptop, putting it in my external drive and copying everything.

Maybe with rsync? I use that to fetch files from my webpage.

teckk 10-25-2019 08:46 PM

Quote:

Can I simply clone this hd onto the new computer's hd?
Yes.
If the new one is larger, you'll need to move the last partition out to the end of the drive, and then extend the file system to the end.
Quote:

Or is that not a good idea?
I have done it, won't hurt anything. Better to do a fresh install, but clone will work ok.

Example:
Clone it, make sure which is which.
Code:

dd if=/dev/sda of=/dev/sdb bs=1M
Move the last partition to the end of drive
Code:

(parted) resizepart 2 100%
Extend the file system
Code:

resize2fs /dev/sdb2 100%

syg00 10-25-2019 08:56 PM

May I demur - dd is absolutely the wrong tool. Allocate some partitions and use rsync as proposed. Best option is to allocate a separate /home partition, then if a fresh install is required, settings aren't lost.
dd has no knowledge of filesystem structure, and if there are any errors will simply clone the errors as well. It has its uses (forensics say), but not a backup tool.

jefro 10-25-2019 09:22 PM

Clones tend to work best on exact hardware. A general rule is to fix specific naming before you clone or you may have to adjust it later.

Will it work? Never know till you try. dd is not tech proof. I've been... I mean people have been known to bork that command.


Some folks use clonezilla booted live on each to move the information over network. I'd think that to be easier than remove but ...

Guess you could even use dd over netcat but that is not as safe as rsync over netcat maybe. Plenty of ways to do this. Any could fail..


Clean boot used to be the only pure way according to some distro's.

frankbell 10-25-2019 09:24 PM

There's also Clonezilla.

I'm inclined to think that a fresh install on the new computer, with a separate /home, then fetching the files for /home with rsync, is likely the best option (I have used a separate /home partition for many years, and have several times been very glad I do).

If it were me, I'd be concerned about potential hardware conflicts in trying to restore a clone from an older machine to the newer one.

Of course, you could try cloning and, if it fails, you would have a fallback plan.

teckk 10-26-2019 07:19 AM

Fresh install the best option. Yes definitely. I said so in post 2.

A file system will have bad blocks, bad sectors, errors, corrupt files, sometimes even immovable data. If you clone it, you clone all of that. dd clones.

Quote:

Can I simply clone this hd onto the new computer's hd?
Sure you can. Will it run ok, sure it will, it will be just like that old drive.

Quote:

Or is that not a good idea?
You see what everyone has said.

Is there an advantage to doing it? Sure, no reconfiguring, no installing, no nothing.

I did a 160GB almost full to a 500GB. Whole thing from start to rebooting the new drive was about 35 min. If you are going to do it with a 1TB drive...that's going to take a while.

Also when you run some like:
Code:

tune2fs -l /dev/sda2
It will look the same as the old drive. Because that is what it is.


All times are GMT -5. The time now is 02:40 AM.