Choose style:

Author Topic: Cloning Hard drives refresher course  (Read 1205 times)

0 Members and 1 Guest are viewing this topic.

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 985
  • Karma: 54
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9R (64bit), P 10
Cloning Hard drives refresher course
« on: March 19, 2019, 09:52:43 pm »
Hello Peppermint people. I just want to be sure I'm going to do this right. I currently have a 250gb UEFI hard drive installed in my desktop.  I am going to replace it with a 500gb Hard drive. I'm planning on installing the new hard drive where the optical drive is, or at least use it's sata and power cables for this operation. So first of all, while in Peppermint, I'll run gparted and create  a GPT partition table in the new hard drive, or is that even necessary? I should then get a  disc ID such as sdb.  According to what I've found, I can then reboot into a live session and run in the terminal either
 
Code: [Select]
dd if=/dev/sda of=/dev/sdb bs=64k
  or
 
Code: [Select]
sudo ddrescue -v /dev/sda /dev/sdb
   of course I'll have to ensure ddrescue is installed for this method.
How am I doing, is this correct? Am I missing anything? This is my first time doing something like this so I just want a little assurance. Once I'm done, I'll take the 250gb hard drive and put it into my laptop and I'll have SSD's in both my computers. Thanks guys.   :)
What was I thinking?

Offline pin

  • Trusted User
  • Veteran
  • *****
  • Posts: 1823
  • Karma: 250
    • View Profile
Re: Cloning Hard drives refresher course
« Reply #1 on: March 20, 2019, 01:06:53 am »
Hi alynur!
There might be other tools to do this, but yes, dd should work.
There're a few things, though...

-Back-up your data!
-The target  drive should be larger than the origin drive. This seems to be your case.
-Extra space on the target will be unused space. You can use gparted from a live-usb to fix that afterwards.
-Why bother with partions? dd will overwrite everything!
-Why using a block size of 64k? Any reason for this? 1M will do it!
-Be aware that it will take some time. I nearly always, use dd to create my bootable usbs, in these cases 1GB takes about 3 to 5min. Copying 250GB will take a loooong time.
-You might want to add conv=fsync  to the command to flush data to disk after the write.

NOTE: I've never used dd to write such a large amount of data, so I have no clue how this will work and, above all, how long it will take!

Wouldn't it be easier/faster to, back-up your data and config files and, do a fresh install?

Offline murraymint

  • Trusted User
  • Veteran
  • *****
  • Posts: 1938
  • Karma: 335
  • soft boiled with a yolk of gold
    • View Profile
  • Peppermint version(s): 7, 8, 9
Re: Cloning Hard drives refresher course
« Reply #2 on: March 20, 2019, 05:20:10 am »
I'm planning on installing the new hard drive where the optical drive is, or at least use it's sata and power cables for this operation.

Have you checked that the power cable fits? I remember the optical drives having a different connector. You might have to use a splitter cable for the SATA power to both HDs.


Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25300
  • Karma: 2793
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Cloning Hard drives refresher course
« Reply #3 on: March 20, 2019, 07:08:59 am »
With the caveats pin mentions, the 'dd' command looks okay to me (though it'll likely take ages) .. you just have to be 100% SURE you get the input file (if=), and output file (of=) correct .. mix em up and you're headed for disaster.

bite size (bs=) is less important, it's just a measure of how much is read from the input file before being written to the output file .. though larger numbers here can save considerable time, personally I usually use bs=1M (for a 1MB bite size)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline rayzer

  • Jr. Member
  • **
  • Posts: 43
  • Karma: 7
  • New Forum User
    • View Profile
  • Peppermint version(s): 10
Re: Cloning Hard drives refresher course
« Reply #4 on: March 20, 2019, 01:25:35 pm »
you might be able to use gnome disk utility to create a restore image which you can then restore to the new drive

Offline murraymint

  • Trusted User
  • Veteran
  • *****
  • Posts: 1938
  • Karma: 335
  • soft boiled with a yolk of gold
    • View Profile
  • Peppermint version(s): 7, 8, 9
Re: Cloning Hard drives refresher course
« Reply #5 on: March 20, 2019, 01:30:03 pm »
I should then get a  disc ID such as sdb.  According to what I've found, I can then reboot into a live session

Be very careful with this. If you reboot into a live session the "disc IDs" can change so you really need to check them from within that live session.

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 985
  • Karma: 54
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9R (64bit), P 10
Re: Cloning Hard drives refresher course
« Reply #6 on: March 20, 2019, 04:02:56 pm »
Hi alynur!
There might be other tools to do this, but yes, dd should work.
There're a few things, though...

-Why using a block size of 64k? Any reason for this? 1M will do it!

Wouldn't it be easier/faster to, back-up your data and config files and, do a fresh install?

Hi pin, the 64k came from the site I was reading, they had mentioned that without any reference it would be even slower. So bs=1M it is. I try to avoid reinstalls because I never end up with what I had and I don't remember everything I've added to my system. I'm not too worried about the time it takes, I can set it up in the evening and let it copy away all night long(now I've got Lionel Richie on my mind).
So are you saying I don't even need to create the GPT partition table because the cloning will make the hard drive as such? I guess it would, huh?

I'm planning on installing the new hard drive where the optical drive is, or at least use it's sata and power cables for this operation.

Have you checked that the power cable fits? I remember the optical drives having a different connector. You might have to use a splitter cable for the SATA power to both HDs.



Hi murraymint, I have hooked up a second hard drive in the past trying to remember what was on the hard drive, so yes I'm certain this will work.

I should then get a  disc ID such as sdb.  According to what I've found, I can then reboot into a live session

Be very careful with this. If you reboot into a live session the "disc IDs" can change so you really need to check them from within that live session.


I get it, this is probably the most important thing I have to be aware of. Thanks for the additional precautions. Oh, and while I got you, is it necessary to boot into a live session to do this?

I should get the new SSD tomorrow so Saturday it should be all done.
What was I thinking?

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 985
  • Karma: 54
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9R (64bit), P 10
Re: Cloning Hard drives refresher course
« Reply #7 on: March 20, 2019, 04:10:55 pm »
Forgot to ask
Hi alynur!
There might be other tools to do this, but yes, dd should work.
There're a few things, though...

-You might want to add conv=fsync  to the command to flush data to disk after the write.


Should the new command read
Code: [Select]
dd if=/dev/sda of=/dev/sdx bs=1M conv=fsync
  ?
What was I thinking?

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 985
  • Karma: 54
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9R (64bit), P 10
Re: Cloning Hard drives refresher course
« Reply #8 on: March 20, 2019, 04:26:39 pm »
With the caveats pin mentions, the 'dd' command looks okay to me (though it'll likely take ages) .. you just have to be 100% SURE you get the input file (if=), and output file (of=) correct .. mix em up and you're headed for disaster.

bite size (bs=) is less important, it's just a measure of how much is read from the input file before being written to the output file .. though larger numbers here can save considerable time, personally I usually use bs=1M (for a 1MB bite size)

Hi PCNetSpec, how big of a bite size can I use? Of the 250 gb hard drive, about 120gb is used and 25gb is unallocated.
What was I thinking?

Offline murraymint

  • Trusted User
  • Veteran
  • *****
  • Posts: 1938
  • Karma: 335
  • soft boiled with a yolk of gold
    • View Profile
  • Peppermint version(s): 7, 8, 9
Re: Cloning Hard drives refresher course
« Reply #9 on: March 20, 2019, 04:57:08 pm »
is it necessary to boot into a live session to do this?

dd will still work if you're booted to your usual drive but things may change during the copy so it's not advisable.

You could alternatively do the whole thing graphically instead by using GParted, in which case you would have to create the GPT partition table and then copy the partition, then resize it if you like.
« Last Edit: March 20, 2019, 04:59:09 pm by murraymint »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25300
  • Karma: 2793
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Cloning Hard drives refresher course
« Reply #10 on: March 20, 2019, 05:22:47 pm »
Forgot to ask
Hi alynur!
There might be other tools to do this, but yes, dd should work.
There're a few things, though...

-You might want to add conv=fsync  to the command to flush data to disk after the write.


Should the new command read
Code: [Select]
dd if=/dev/sda of=/dev/sdx bs=1M conv=fsync
  ?

That looks good to me as long as sda is the source and sdx is the target .. but as murraymint suggests, check these in the live session, don't assume they'll be the same as they were when booted to the installed OS.

Quote
Hi PCNetSpec, how big of a bite size can I use? Of the 250 gb hard drive, about 120gb is used and 25gb is unallocated.

Theoretically as big as the amount of free RAM you have, but probably best to stick to 1M .. you'll likely see diminishing speed returns above this.
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline pin

  • Trusted User
  • Veteran
  • *****
  • Posts: 1823
  • Karma: 250
    • View Profile
Re: Cloning Hard drives refresher course
« Reply #11 on: March 20, 2019, 05:49:59 pm »
Back-up!!
Then give it a go  :)
Expert 20+h, dd will copy 'empty space' as well  :D
Your command looks good. Be sure you don't have a power loss in the middle of it  ;)

Psst,... once I did
Code: [Select]
sudo dd if=/dev/zero of=/dev/sda bs=1M
It took 22h  ;)
sda was 250GB...

WARNING: Don't issue the command above!!!

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 985
  • Karma: 54
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9R (64bit), P 10
Re: Cloning Hard drives refresher course
« Reply #12 on: March 20, 2019, 06:16:40 pm »
Back-up!!
Then give it a go  :)
Expert 20+h, dd will copy 'empty space' as well  :D
Your command looks good. Be sure you don't have a power loss in the middle of it  ;)

Psst,... once I did
Code: [Select]
sudo dd if=/dev/zero of=/dev/sda bs=1M
It took 22h  ;)
sda was 250GB...


WARNING: Don't issue the command above!!!


Uh oh, that's something I forgot about, power outages. This place has plenty of power outages. What would be a quicker method? How much space on a memory would be needed to create an iso image of 25gb, 12gb and 120gb?
« Last Edit: March 20, 2019, 06:19:52 pm by alynur »
What was I thinking?

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25300
  • Karma: 2793
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Cloning Hard drives refresher course
« Reply #13 on: March 20, 2019, 06:34:30 pm »
Quote
What would be a quicker method? How much space on a memory would be needed to create an iso image of 25gb, 12gb and 120gb?

I'm not understanding your question .. are you talking about making backups of partitions with something like Gnome Disks ?

If so that's unanswerable .. it depends on how much of those partitions are full.

AFAIK Gnome Disks creates file by file backups (so will be as big as the used space), as opposed to sector by sector backups (which will be as big as the partitions).

[EDIT]

Theoretically, a power outage during a 'dd' operation should be safe for the data on the source drive, as it's not getting modified (written to) .. nothing is ever 100% safe, a power outage can always do damage, but there should theoretically be no more risk to the data on the source drive than a power outage any other time.

The data on the target would likely be toast corrupt because the cached data wouldn't have time to be written, but then you'd have to start again anyway as it wouldn't have completed so data would be missing
« Last Edit: March 20, 2019, 06:46:46 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline murraymint

  • Trusted User
  • Veteran
  • *****
  • Posts: 1938
  • Karma: 335
  • soft boiled with a yolk of gold
    • View Profile
  • Peppermint version(s): 7, 8, 9
Re: Cloning Hard drives refresher course
« Reply #14 on: March 20, 2019, 06:46:22 pm »
I think GParted would be faster but I don't normally copy such large partitions. If you're talking about trying to compress it onto a smaller drive, that would take even longer, even if you had a big enough USB drive.

If these are both actually SSDs rather than HDs then it will all be much quicker.