Copy a hdd to a new ssd drive

Technical issues/questions of an intermediate or advanced nature.
User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Copy a hdd to a new ssd drive

Post#1 by Ed_P » 26 Dec 2020, 12:55

I received a new ssd drive for Christmas. :Yahoo!: I want to replace the hdd in my notebook with it and move everything on the hdd to the new ssd drive. The hdd has 8 partitions. Can a simple dd command copy everything??

Sudo dd if=/mnt/sda of=/mnt/sdb

Or do I have to do partition by partition? Or use gparted?

:%)
Ed

User avatar
Blaze
DEV Team
DEV Team
Posts: 3883
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus current ☯ all DEs ☯
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Copy a hdd to a new ssd drive

Post#2 by Blaze » 26 Dec 2020, 15:28

Better to make these partition manual and copy all data via SATA-USB adapter
Image
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Copy a hdd to a new ssd drive

Post#3 by Ed_P » 26 Dec 2020, 19:24

I have an Orico 2.5 inch hard drive enclosure and USB cable to use to copy data from the one drive to the other.
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Copy a hdd to a new ssd drive

Post#4 by Ed_P » 30 Dec 2020, 19:55

DD's bs= option. Hard drives use 512 and the common recommendations for DD are 64 MB and 128 MB. For a drive with large files the large blocksize is useful because it reduces the number or reads and/or writes. But for small files it is a waste of bytes on the drive. A 1 KB script in a 128 MB block wastes 127 MB. 2KB, 10 KB, 1 MB even 10 MB files all take 128 MB.

So, what do you guys recommend for a drive's blksize? And do all the partitions on a drive have to have the same blksize? Can the EFI partition have a 1 MB blksize and the the OS partition 64 MB?
Ed

donald
Full of knowledge
Full of knowledge
Posts: 2067
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Copy a hdd to a new ssd drive

Post#5 by donald » 31 Dec 2020, 05:25

Hmm..it seems to me that you are confusing the dds bs= option with disk sectors.

The block size (bs) parameter specifies the amount of memory used to read a block
from one hard disk before attempting to write that block to the other.

dd copies everything, including free space.
The disadvantages become extremely apparent when you have large disks
that aren't completely filled.

You're probably better off using something like Clonezilla. :)

User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Copy a hdd to a new ssd drive

Post#6 by Ed_P » 31 Dec 2020, 15:47

:o Thank you donald. :friends: I was indeed confusing the dd bs= option with disk sectors.

But before I went to bed I ran my dd script and when I got up this morning it was done. :Yahoo!: Sometime later today I will replace the hdd with the sdd and we will see how successful I was.

My dd script for anyone interested.

Code: Select all

#!/bin/bash
#https://forum.porteus.org/viewtopic.php?t=8473

# Color definitions               # ups.sh
txtbld=$(tput bold)               # Bold
txtred=${txtbld}$(tput setaf 1)   # Bold Red
txtgreen=${txtbld}$(tput setaf 2) # Bold Green 
txtcyan=${txtbld}$(tput setaf 6)  # Bold Cyan
rst=$(tput sgr0)                  # Reset
function redpswd() {
  echo -E "$1" $txtred  
}
function cyan() {
  echo -E "$1" $txtcyan
}

if [ `whoami` != "root" ]; then
   cyan "Enter root's password"
   su -c "sh $0 $1"
   exit
fi
echo $rst

echo
fdisk -l /dev/sda
echo
fdisk -l /dev/sdb
echo
#echo Copy sda to sdb?
read -p "Copy sda to sdb? " ans 
if [ "$ans" != "y" ] && [ "$ans" != "Y" ]; then
   exit
fi 

echo
date
echo
dd if=/dev/sda of=/dev/sdb bs=4K conv=noerror,sync status=progress   #conv=noerror status=progress
echo
date
read
Added in 6 hours 10 minutes 16 seconds:
And it works! :celebrate3: I'm using it now. :happy62: Looking forward to it's impact on playing FoE. :)
Ed

Post Reply