Clone an SSD drive.

New to Debian (Or Linux in general)? Ask your questions here!

Clone an SSD drive.

Postby hack3rcon » 2020-11-22 11:27

Hello,
I have an SSD drive that a special Operating System installed on it and has some partitions with different sizes. I want to clone it on another SSD. Is below command enough?
Code: Select all
# dd if=/dev/XXX of=/home/jason/SSD.dd

This command will clone all parts of SSD like Boot partition and...?

Thank you.
hack3rcon
 
Posts: 472
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby RU55EL » 2020-11-22 12:31

User avatar
RU55EL
 
Posts: 498
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Clone an SSD drive.

Postby mm3100 » 2020-11-22 13:03

Yes I think that command of yours will do what you want, just be careful of UUID, since dd will copy those as well.
mm3100
 
Posts: 16
Joined: 2020-10-21 21:39

Re: Clone an SSD drive.

Postby p.H » 2020-11-22 14:46

hack3rcon wrote:I have an SSD drive that a special Operating System installed on it and has some partitions with different sizes. I want to clone it on another SSD. Is below command enough?

No. The command does not clone a drive on another, it only creates an image file from the source drive. You must also write the image to the destination drive.

Also note that :
- If the destination drive is smaller than the source drive, it won't work.
- If the destination drive is bigger than the source drive and the partition scheme is GPT, the available size recorded in the GPT header on the destination drive will be wrong and the backup partition table which is expected to be located at the end of the drive will be at the wrong location unless you run some partitioning tool to fix the partition table.
- dd copies all blocks, used and unused. It is a waste of time and wears the destination. Also, unused copied blocks will be uselessly marked "in use" by the destination SSD unless you run fstrim on each filesystem afterwards. Depending on the partition scheme and filesystem type, clonezilla may be able to copy only used blocks.
- The operating system may not be happy to be moved to another drive without notice. For instance, the Debian package grub-pc (for BIOS boot) records the physical identifier /dev/disk/by-id/xxx of the drive the boot loader was installed to, so that it can reinstall it in the same location after an update.
p.H
 
Posts: 1521
Joined: 2017-09-17 07:12

Re: Clone an SSD drive.

Postby CwF » 2020-11-22 16:03

search !
...and the answer is qemu-img.
I've typed it already.
CwF
 
Posts: 810
Joined: 2018-06-20 15:16

Re: Clone an SSD drive.

Postby Bulkley » 2020-11-22 16:49



+1.
Bulkley
 
Posts: 6016
Joined: 2006-02-11 18:35

Re: Clone an SSD drive.

Postby Islander » 2020-11-23 12:14

gnome-disks has a Create/Restore Disk Image function. Will that work as well?
Islander
 
Posts: 16
Joined: 2020-10-20 08:29

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-23 16:23

p.H wrote:
hack3rcon wrote:I have an SSD drive that a special Operating System installed on it and has some partitions with different sizes. I want to clone it on another SSD. Is below command enough?

No. The command does not clone a drive on another, it only creates an image file from the source drive. You must also write the image to the destination drive.

Also note that :
- If the destination drive is smaller than the source drive, it won't work.
- If the destination drive is bigger than the source drive and the partition scheme is GPT, the available size recorded in the GPT header on the destination drive will be wrong and the backup partition table which is expected to be located at the end of the drive will be at the wrong location unless you run some partitioning tool to fix the partition table.
- dd copies all blocks, used and unused. It is a waste of time and wears the destination. Also, unused copied blocks will be uselessly marked "in use" by the destination SSD unless you run fstrim on each filesystem afterwards. Depending on the partition scheme and filesystem type, clonezilla may be able to copy only used blocks.
- The operating system may not be happy to be moved to another drive without notice. For instance, the Debian package grub-pc (for BIOS boot) records the physical identifier /dev/disk/by-id/xxx of the drive the boot loader was installed to, so that it can reinstall it in the same location after an update.


Thank you so much for your useful information. I have some questions:
1- If the destination drive is bigger than the source drive then what should I do?
2- How about "fstrim" ?
3- "The operating system may not be happy to be moved to another drive without notice.", then what are the options?

If possible, please show me the commands that I must use.
hack3rcon
 
Posts: 472
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-23 16:23

mm3100 wrote:Yes I think that command of yours will do what you want, just be careful of UUID, since dd will copy those as well.

What should I do about UUID?
hack3rcon
 
Posts: 472
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby mm3100 » 2020-11-23 18:46

It is not wise to have two mounted filesystems with same UUIDs, if you dd from one drive directly to another one dd will copy UUID of those filesystems on partitions too, so you would need to change that if you want to use both drives at the same time. You should be able to change UUID without reformatting partitions using gparted, not sure if kde parititon manager can do that too. Just make sure filesystem is not mounted while doing so.
mm3100
 
Posts: 16
Joined: 2020-10-21 21:39

Re: Clone an SSD drive.

Postby p.H » 2020-11-24 07:48

hack3rcon wrote:1- If the destination drive is bigger than the source drive then what should I do?

I already replied to this question in my previous post.

hack3rcon wrote:2- How about "fstrim" ?

Can you elaborate ?
fstrim sends discards for all mounted filesystems. It will do the same on another SSD.

hack3rcon wrote:3- "The operating system may not be happy to be moved to another drive without notice.", then what are the options?

Change the drive identification in relevant configurations. The only one I know in Debian is grub-pc debconf configuration, so you would juste have to run
Code: Select all
dpkg-reconfigure grub-pc

after removing the old SSD and booting the new SSD.

hack3rcon wrote:What should I do about UUID?

Nothing if you are not going to use both drives in the same machine at the same time.
p.H
 
Posts: 1521
Joined: 2017-09-17 07:12

Re: Clone an SSD drive.

Postby bester69 » 2020-11-25 15:48

hack3rcon wrote:Hello,
I have an SSD drive that a special Operating System installed on it and has some partitions with different sizes. I want to clone it on another SSD. Is below command enough?
Code: Select all
# dd if=/dev/XXX of=/home/jason/SSD.dd

This command will clone all parts of SSD like Boot partition and...?

Thank you.


This! >> GPARTED COPY/PASTE

Dude, Im not an expert, but i think clonning whole disk is a very bad idea...Im not sure, cos Ive never done like that but sounds very bad... you clone idividual partitions better, so that , you can later work with them and adjust sizes and postitions... Its very easy to do with gparted, just copy and paste like with clipboard... you just need to use a livecd to have all partitions unmounted... I clonned my HDD to SSD and gparted keep UUID and let you resize once copied partition to target...
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1801
Joined: 2015-04-02 13:15

Re: Clone an SSD drive.

Postby vmclark » 2020-11-25 16:19

@hack3rcon

copy and paste the output of
Code: Select all
lsblk -f
so we can see what special partitions your talking about. Clonezilla or fsarchiver is what I use.
vmclark
 
Posts: 170
Joined: 2008-07-30 15:16

Re: Clone an SSD drive.

Postby Bulkley » 2020-11-25 16:20

Yesterday I got a new SSD drive. I booted up my trusty old Clonzilla live-CD and in less than 30 minutes I'm running my system on the new drive. :D
Bulkley
 
Posts: 6016
Joined: 2006-02-11 18:35

Re: Clone an SSD drive.

Postby CwF » 2020-11-25 16:33

bester69 wrote: i think clonning whole disk is a very bad idea.

It's a very good idea. A bad idea is to mix purpose on a device and complicate it's archival. If you have 100GB of crap mixed in your OS it would be silly to try and image the whole disk, so think ahead maybe. I image to and fro on device and as a file on a regular basis. An OS archives to a few GB's, you can keep that on the simplest phone or usb, or a master spinning rust. I do windows too, for Debian only a single master image is needed for each architecture. UUID's, PTUUID's, domains, users are changeable. A few dozen OS's can be quickly unique-ified at will. User skel's can be zipped and applied to fresh OS copies. User data bought in from separate image files and devices.

Something needed a parallel OS savior just the other week, I just wrote out from tempfs the current bullseye to a ssd and popped it it in. The incomplete system boot up fine straight into a recovery user desktop, with some craziness, but with a working root terminal. Fix at hand, working network, done. All from a 1.7GB image, installed 4 years ago as a Jessie vm on a machine long gone.

Imaging the whole drive works very well. There are a few extra things to know, but it's all doable. I've learned the hard way, no clonezilla for me. By now, my way is way easier.
CwF
 
Posts: 810
Joined: 2018-06-20 15:16

Next

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable