Clone an SSD drive.

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

Re: Clone an SSD drive.

Postby sunrat » 2020-11-25 20:47

CwF wrote:
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.

Totally agree and that's why I use a separate partition for all my data instead of dumping it all in /home . Restores or new distro installs are a piece of cake. My largest OS image using fsarchiver is ~6GB.
On a side note, some people use and even advise to share a /home partition in multiboot but that's crazy IMO. Have /home inside root partition and separate /data partition/s ftw.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!
User avatar
sunrat
 
Posts: 3335
Joined: 2006-08-29 09:12
Location: Melbourne, Australia

Re: Clone an SSD drive.

Postby RU55EL » 2020-11-25 22:35

About six months or so ago, I got a new 1 TB SSD to replace the 256 GB SSD in my work computer. The computer is dual boot, Debian and Windows. [Using Clonezilla] Took about an hour to copy all the files, swapped the drives, and boom, computer worked exactly as before except the SSD was much bigger.
Last edited by RU55EL on 2020-11-27 13:10, edited 1 time in total.
User avatar
RU55EL
 
Posts: 521
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Clone an SSD drive.

Postby RU55EL » 2020-11-25 22:44

sunrat wrote:[...] that's why I use a separate partition for all my data instead of dumping it all in /home . Restores or new distro installs are a piece of cake. [...]


When I initially install Debian, I create /home in a separate partition (sometimes a separate drive.) That makes backups, restores or new Distro installs a piece of cake. I love performing a fresh install without formatting the /home partition, using my old /home partition, and having my setting and data preserved. (Of course, I create a backup first.) A clean install of Debian, say from Stretch to Buster, takes about 15 to 20 minutes, on a computer that isn't too old, using an SSD.
User avatar
RU55EL
 
Posts: 521
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Clone an SSD drive.

Postby bester69 » 2020-11-26 17:54

If you clone a whole disk.. I think you lose free space on the right side of the bigger target disk..I think you cant resize a table partition, unless ive never seen to do that kind of operation...thats why I clone partition to partition by copying them with gparted.. but I might be wrong and gparted let you to expand table partition as well.


sunrat wrote:...
Restores or new distro installs are a piece of cake. My largest OS image using fsarchiver is ~6GB.
......

by the way, right now ive my system fsarchiver backup (7Gb) uploading to box (I do one or two uploads per year) cloud with duplicity and rclone backend at just 100KB/seg, it will take around tree or four days to upload whole system backup.. at that slow speed.. but it pays off; duplicity is as reliable as btrfs in my experience and resuming operations never fails (seems unbreakable 8) ).. and box cloud us very reliable as well. 8)
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1816
Joined: 2015-04-02 13:15

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-27 09:22

Thank you.
The output is:
Code: Select all
$ lsblk -f
NAME FSTYPE LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT

sdc                                                                   
├─sdc1
│    vfat   /sysro
│                 020C-0000                                           
├─sdc2
│    vfat   /db   0257-0000                                           
├─sdc3
│    vfat   /vmail
│                 02F6-0000                                           
├─sdc4
│                                                                     
├─sdc5
│    vfat   /sysro
│                 036A-0000                                           
├─sdc6
│    vfat   /db   037F-0000                                           
└─sdc7
     vfat   /unused
                  03FA-0000                                           


I unmount all partitions:
Code: Select all
$ sudo umount /dev/sdcX

Then:
Code: Select all
$ sudo dd if=/dev/sdc of=/home/jason/SSD.dd
234441648+0 records in
234441648+0 records out
120034123776 bytes (120 GB, 112 GiB) copied, 2850.17 s, 42.1 MB/s

And:
Code: Select all
$ file SSD.dd
SSD.dd: DOS/MBR boot sector; partition 1 : ID=0x6, active, start-CHS (0x0,1,1), end-CHS (0x8f,254,63), startsector 63, 2313297 sectors; partition 2 : ID=0xb, start-CHS (0x90,0,1), end-CHS (0x3ea,254,63), startsector 2313360, 13799835 sectors; partition 3 : ID=0xc, start-CHS (0x3eb,0,1), end-CHS (0x3ff,254,63), startsector 16113195, 29543535 sectors; partition 4 : ID=0xf, start-CHS (0x3ff,0,1), end-CHS (0x3ff,254,63), startsector 45656730, 188784918 sectors

I plugged another SSD and:
Code: Select all
# dd if=/home/jason/SSD.dd of=/dev/sdc

Is it enough? I never defined any "bs" parameter, is it mandatory?
I did above command, but after 1 hour, restoring not finished yet!!! Is it normal?
hack3rcon
 
Posts: 507
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby RU55EL » 2020-11-27 13:22

bester69 wrote:If you clone a whole disk.. I think you lose free space on the right side of the bigger target disk..I think you cant resize a table partition, unless ive never seen to do that kind of operation...thats why I clone partition to partition by copying them with gparted.. but I might be wrong and gparted let you to expand table partition as well.


This is wrong, at least when using Clonezilla to clone a drive.
User avatar
RU55EL
 
Posts: 521
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-27 13:27

Because of the long time, I cancelled previous command and did:
Code: Select all
# dd if=SSD.dd | pv | dd of=/dev/sdc bs=1M
234441648+0 records iniB/s] [                      <=>                         ]
234441648+0 records out
120034123776 bytes (120 GB, 112 GiB) copied, 4376.66 s, 27.4 MB/s
 111GiB 1:12:56 [26.2MiB/s] [                     <=>                          ]
1+2129501 records in
1+2129501 records out
120034123776 bytes (120 GB, 112 GiB) copied, 4415.03 s, 27.2 MB/s

And finally:
https://pasteboard.co/JCjcAYs.png
hack3rcon
 
Posts: 507
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-27 14:00

Failed and not booted :(
It is an SSD of MITEL 3300 switch.
hack3rcon
 
Posts: 507
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby bester69 » 2020-11-27 14:15

hack3rcon wrote:Failed and not booted :(
It is an SSD of MITEL 3300 switch.


I think you might need to reinstall grub loader....use a livecd and follow standard procedure.:

sudo mount -t vfat /mySystemPartition /mnt
sudo --bind /dev /mn/dev
sudo --bind /dev/pts /mn/dev/pts
sudo --bind /proc /mnt/proc
sudo --bind /sys /mnt/sys
sudo chroot /mnt
grub-install /dev/sdX
update-grub
exit && reboot

You also might need to set AHCI in BIOS for SSD.. but your system is very weird to me, all partitions are vfat, so i dont know what you have there installed. :shock:

p.d.: perhaps would be better than dd.. to use specific tools for clonning partitions; for example gparted uses ntfsclone for ntfs.. Also you could use clonezilla, thought i dont think this is the problem, I guess you clonning disk was ok.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1816
Joined: 2015-04-02 13:15

Re: Clone an SSD drive.

Postby CwF » 2020-11-27 14:39

Wow that's slow.
So a 120GB SSD with a 8GB swap drive? Not encrypted? With qemu-img you have the compression option for the file stage of an image, so dd doesn't waste time on empty space! ...and I thought my dramless SSD's were slow!

Actually with compression you do need a beefy many thread cpu or it's slower I'd think. That last bullseye I wrote out is a 8.4GB partition size, it slowly gets there with use when residing in tempfs ram. It compressed last step to 1576MB, and the write out to the cheap SSD took about 8 minutes which seems slow to me. Full lvm luks drives write out to device size regardless of free space, so don't bother with compression, but those take about 20-30 minutes.

qemu-img is available from package qemu-utils, it's small. from memory (check)...
first image the drive to a file, if it's not encrypted it will not take full space...
Code: Select all
qemu-img convert -c -p -O qcow2 /path/to/device /path/to/file.qcow2

..from imgae file to device
Code: Select all
qemu-img convert -p -O raw /path/to/file.qcow2 /path/to/device


A few versions ago dd was superior for damaged disk recovery. I think qemu-img has gained some ability lately, so rarely a need for dd anymore. The state of the filesystem should be considered and you should massage the running OS before imaging. IE, Bleachbit, or something to zero unused and deleted sectors, otherwise the undelete data is still available in the image. While a file, a qcow2, you can run virt-sparsify --in-place to re-trim the image if you'd like to compress it more for archival - you'd run the qemu-img command AGAIN from file to file to reclaim the unused sectors. btw, I ignore trim in the running systems as everything goes through this process periodically and the ssd's get cycled. I use this to create the first OS a new system sees, no fresh installs for the last 4 years! Yes, I use a magnifier to read the MAC stickers so the network naming is correct OOB!

Enjoy
CwF
 
Posts: 872
Joined: 2018-06-20 15:16

Re: Clone an SSD drive.

Postby CwF » 2020-11-27 14:42

bester69 wrote:think you might need to reinstall grub loader.

This is why you do the entire disk and not partitions.
CwF
 
Posts: 872
Joined: 2018-06-20 15:16

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-27 15:06

bester69 wrote:
hack3rcon wrote:Failed and not booted :(
It is an SSD of MITEL 3300 switch.


I think you might need to reinstall grub loader....use a livecd and follow standard procedure.:

sudo mount -t vfat /mySystemPartition /mnt
sudo --bind /dev /mn/dev
sudo --bind /dev/pts /mn/dev/pts
sudo --bind /proc /mnt/proc
sudo --bind /sys /mnt/sys
sudo chroot /mnt
grub-install /dev/sdX
update-grub
exit && reboot

You also might need to set AHCI in BIOS for SSD.. but your system is very weird to me, all partitions are vfat, so i dont know what you have there installed. :shock:

p.d.: perhaps would be better than dd.. to use specific tools for clonning partitions; for example gparted uses ntfsclone for ntfs.. Also you could use clonezilla, thought i dont think this is the problem, I guess you clonning disk was ok.


Excuse me, It is a switch not a PC!
hack3rcon
 
Posts: 507
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby hack3rcon » 2020-11-27 15:15

Which part of my command is wrong?
hack3rcon
 
Posts: 507
Joined: 2015-02-16 09:54

Re: Clone an SSD drive.

Postby CwF » 2020-11-27 15:16

hack3rcon wrote:Excuse me, It is a switch not a PC!

same
CwF wrote:This is why you do the entire disk and not partitions.

doesn't matter what it is, use qemu-img and image the entire device. This includes boot sectors, magic offsets, propriety hiding places, etc...
Same advice applies to dd on unknowns. The superiority of qemu-img is it does understand file systems and can manipulate accordingly. dd does a stupid blind copy, which at times may be an advantage.
CwF
 
Posts: 872
Joined: 2018-06-20 15:16

Re: Clone an SSD drive.

Postby bester69 » 2020-11-27 17:44

CwF wrote:....The superiority of qemu-img is it does understand file systems and can manipulate accordingly. dd does a stupid blind copy, which at times may be an advantage.



Fantastic tool (great discover :o), I thought that was a propietary windows app.

you should post more of that if you have it, in linux commands apps post:
List of your linux commands Apps
viewtopic.php?f=3&t=126446&start=75

thanks CwF :P
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1816
Joined: 2015-04-02 13:15

PreviousNext

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 14 guests

fashionable