CloneZilla – Clonare un hard disk su un disco più piccolo

Clonezilla l’efficace tools free e open source per  la clonazione di dischi e partizioni non consente in modalità standard la clonazione verso un disco fisso più piccolo anche quando  la quantità di dati da trasferire non eccede la capacità del disco di destinazione.
Tuttavia se  si utilizza la modalità expert è possibile effettuare la copia del hard disk più grande verso un hard disk più piccolo. L’accorgimento che si deve avere è sfruttare le opzioni -icds e l’opzione –k2 sopratutto che consente di copiare la tabella partizioni manualmente prima dell’avvio definitivo della clonazione.

Di seguito le schermate principali e il listato da terminale generato da clonezilla nella clonazione di un disco seagate SATA 2.5 da 500GB verso un disco hitachi IDE 2.5 da 80GB collegato con adattatore su porta usb 2.0.

Il disco seagate da clonare ha la seguente organizzazione 7 partizioni e circa 55GB di dati nella prima porzioni del disco.

avviare clonezilla da terminale come superuser e avremo a disposizione li menu interativo

# sudo su 
# clonezilla 

Selezionare copia da disco/partizione a disco/partizione senza il passare per un immagine.

Selezionare la modalità Expert

clonezilla-st500nvmego-80_003exp-1.jpg

Selezionare disk to local disk

clonezilla-st500nvmego-80_004dtod.jpg

Selezionare il disco sorgente/ source disk  in questo caso il segate da 500 GB

clonezilla-st500nvmego-80_004dtod_1.jpg

Adesso selezioanre il disco destinazione

clonezilla-st500nvmego-80_004dtod_2-1.jpg

Nella schermata con  i parametri extra di clonezilla selezionare anche il parametro -icds

clonezilla-st500nvmego-80_004dtodexp_1.jpg

Optiamo per il check e l’eventuale repair del source

clonezilla-st500nvmego-80_004dtodexp_2noskip.jpg

La scelta che segue è la più importante -k2 ( Enter command line prompt to create partition manually later ).

Clonezilla-St500nvmeGO-80_004dtodexp_k2

A questo punto appare un messaggio ci informa che la clonazione è in pausa e ci viene permesso di creare la tabella delle partizioni nel disco di destinazione manualmente. Possiamo riavvare successivamente la procedura di clonazione digitando exit da terminale.

...
...
*****************************************************.
Now enter another shell to allow you to create partition table on 
the destination disk. You may use fdisk, cfdisk, sfdisk or parted 
to do that. When everything is done, run "exit" to go back to the original program.
Press "Enter" to continue......

Clonare la partizione del disco sorgente nel disco di destinazione con sgdisk

e riavviare la clonazione digitando exit

# sgdisk -R /dev/sdc /dev/sda
Caution! Secondary header was placed beyond the disk's limits! Moving the
header, but other problems may occur!
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

# exit
exit
Informing the OS of partition table changes.... done!
The disk and partitions in this system now:
*****************************************************.
Model: Hitachi HTS541680J9AT00 (scsi)
Disk /dev/sdc: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  1039MB  1038MB                     bios_grub
 2      1039MB  2622MB  1583MB
 3      2622MB  36.7GB  34.1GB
...

A questo punto si avvia la clonazione vera e propria di tutte le partizioni. la schermata che accompagna la clonazione della partizione sda3

clonezilla-st500nvmego-80_004dtodexp_partclone_4.jpg

Clonezilla è un tools ben fatto per avere tutti ipacchetti a disposizione per i vari tipi di partizione potrebbe essere conventiente usare una live dedicata.
Comunque con un po’ di attenzione e seguendo i messaggi da terminale è possibile individuare tutti i pacchetti che dovessero rendersi necessari compresi quelli per le partizioni macintosh (+hfs).

Il risultato finale partizionamento Hitachi 80GB su porta USB.

ST500-25-xGOnvme-80cloned

Di seguito il listato generato da clonezilla a livello di terminale nella clonazione in modalità expert con l’opzioni -icds e  -k2  da disco grande a disco più piccolo

root@mx-nvme:/home/ms# clonezilla
Clonezilla mode is device-device
Setting the TERM as xterm-256color
Starting /usr/sbin/ocs-onthefly at 2019-06-25 14:05:21 CEST...
Excluding busy partition or disk...
Disk number: 3
Excluding busy partition or disk...
Disk number: 2
PS. Next time you can run this command directly:
/usr/sbin/ocs-onthefly -g auto -e1 auto -e2 -j2 -r -icds -fsck-src-part -k2  -f sda -t sdc
This command is also saved as this file name for later use if necessary: /tmp/ocs-onthefly-2019-06-25-14-11
****************************************************.
Press "Enter" to continue...
*****************************************************.
///WARNING/// filesystem.squashfs not found! No idea where is LIVE MEDIA!!! Assume this is running in DRBL client.
*****************************************************.
setterm: terminal xterm-256color does not support --blank
*****************************************************.
Searching for data partition(s)...
Excluding busy partition or disk...
Unmounted partitions (including extended or swap): sdc1 sdc2
Collecting info... done!
Getting /dev/sdc1 info...
Getting /dev/sdc2 info...
WARNING!!! WARNING!!! WARNING!!!
WARNING! THE EXISTING DATA IN THIS HARDDISK/PARTITION(S) WILL BE OVERWRITTEN! ALL EXISTING DATA WILL BE LOST: sdc
*****************************************************.
Machine: Unknown product name
sdc (80.0GB_HTS541680J9AT00__Hitachi_HTS541680J9AT00-0:0)
sdc1 (59.3G_exfat(In_HTS541680J9AT00_)_Hitachi_HTS541680J9AT00-0:0)
sdc2 (15.2G_ext4(In_HTS541680J9AT00_)_Hitachi_HTS541680J9AT00-0:0)
*****************************************************.
*****************************************************.
Are you sure you want to continue? (y/n) y
OK, let's do it!!
*****************************************************.
Let me ask you again.
WARNING!!! WARNING!!! WARNING!!!
WARNING! THE EXISTING DATA IN THIS HARDDISK/PARTITION(S) WILL BE OVERWRITTEN! ALL EXISTING DATA WILL BE LOST: sdc
Are you sure you want to continue? (y/n)
re you sure you want to continue? (y/n) y
OK, let's do it!!
*****************************************************.
Saving the GPT of /dev/sda as /tmp/ocs_onthefly_local.Ri34n8/src-gpt.gdisk by sgdisk...
The operation has completed successfully.
Saving the primary GPT of /dev/sda as /tmp/ocs_onthefly_local.Ri34n8/src-gpt-1st.img by dd...
34+0 records in
34+0 records out
17408 bytes (17 kB, 17 KiB) copied, 0.000222642 s, 78.2 MB/s
Saving the secondary GPT of /dev/sda as /tmp/ocs_onthefly_local.Ri34n8/src-gpt-2nd.img by dd...
32+0 records in
32+0 records out
16384 bytes (16 kB, 16 KiB) copied, 0.000175774 s, 93.2 MB/s
*****************************************************.
Collecting partition /dev/sda1 info...
Collecting partition /dev/sda2 info...
Collecting partition /dev/sda3 info...
Collecting partition /dev/sda4 info...
Collecting partition /dev/sda5 info...
Collecting partition /dev/sda6 info...
Collecting partition /dev/sda7 info...
Non-grub boot loader found on /tmp/ocs_onthefly_local.Ri34n8/sdc-mbr...
The CHS value of hard drive from EDD will be used for sfdisk.
Sfdisk >= 2.26 does not support C/H/S option. Skip using C/H/S option.
*****************************************************.
Searching for data partition(s) in source disk: sda ...
Excluding busy partition or disk...
Unmounted partitions (including extended or swap): sda1 sda2 sda3 sda4 sda5 sda6 sda7
Collecting info........ done!
*****************************************************.
Running file system check and repair for /dev/sda1...
Running: fsck -f  /dev/sda1
fsck from util-linux 2.29.2
fsck.fat 4.1 (2017-01-24)
/dev/sda1: 3 files, 34/252940 clusters
Running file system check and repair for /dev/sda2...
Running: fsck -f  /dev/sda2
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda2: 11/96000 files (0.0% non-contiguous), 15356/386560 blocks
Running file system check and repair for /dev/sda3...
Running: fsck -f  /dev/sda3
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
rootMX18.1: 265235/2088960 files (0.0% non-contiguous), 1641803/8326912 blocks
Running file system check and repair for /dev/sda4...
Running: fsck -f  /dev/sda4
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
boot: 779/106496 files (0.5% non-contiguous), 164652/407040 blocks
Running file system check and repair for /dev/sda5...
Running: fsck -f  /dev/sda5
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda5: 341/169680 files (1.5% non-contiguous), 49544/657664 blocks
Running file system check and repair for /dev/sda6...
Running: fsck -f  /dev/sda6
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda6: 314/171024 files (1.6% non-contiguous), 73266/685312 blocks
Running file system check and repair for /dev/sda7...
Running: fsck -f  /dev/sda7
fsck from util-linux 2.29.2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda7: 11/640848 files (0.0% non-contiguous), 65844/2560000 blocks
*****************************************************.
Will create the partition on the target machine...
Trying to clean the MBR and GPT partition table on the destination disk first: /dev/sdc
Informing the OS of partition table changes... done!
*****************************************************.
Now enter another shell to allow you to create partition table
on the destination disk. You may use fdisk, cfdisk, sfdisk or parted
to do that. When everything is done, run "exit" to go back to the original program.
Press "Enter" to continue......

# sgdisk -R /dev/sdc /dev/sda
Caution! Secondary header was placed beyond the disk's limits! Moving the
header, but other problems may occur!
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

# exit
exit
Informing the OS of partition table changes.... done!
The disk and partitions in this system now:
*****************************************************.
Model: Hitachi HTS541680J9AT00 (scsi)
Disk /dev/sdc: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 1039MB 1038MB bios_grub
2 1039MB 2622MB 1583MB
3 2622MB 36.7GB 34.1GB
4 36.7GB 38.4GB 1667MB
5 38.4GB 41.1GB 2694MB
6 45.7GB 48.5GB 2807MB
7 48.5GB 59.0GB 10.5GB

*****************************************************.
done!
*****************************************************.
*****************************************************.
Searching for data partition(s) in source disk: sda ...
Excluding busy partition or disk...
Unmounted partitions (including extended or swap): sda1 sda2 sda3 sda4 sda5 sda6 sda7
Collecting info........ done!
*****************************************************.
Source partition file system is vfat...
Cloning the /dev/sda1 to /dev/sdc1...
Clean filesystem header in device /dev/sdc1...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.vfat -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda1 -O /dev/sdc1
Cloned successfully.
*****************************************************.
Source partition file system is ext4...
Cloning the /dev/sda2 to /dev/sdc2...
Clean filesystem header in device /dev/sdc2...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda2 -O /dev/sdc2
Cloned successfully.
*****************************************************.
Source partition file system is ext4...
Cloning the /dev/sda3 to /dev/sdc3...
Clean filesystem header in device /dev/sdc3...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda3 -O /dev/sdc3
Cloned successfully.
*****************************************************.
Source partition file system is ext4...
Cloning the /dev/sda4 to /dev/sdc4...
Clean filesystem header in device /dev/sdc4...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda4 -O /dev/sdc4
Cloned successfully.
*****************************************************.
Source partition file system is ext4...
Cloning the /dev/sda5 to /dev/sdc5...
Clean filesystem header in device /dev/sdc5...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda5 -O /dev/sdc5
Cloned successfully.
*****************************************************.
Source partition file system is ext4...
Cloning the /dev/sda6 to /dev/sdc6...
Clean filesystem header in device /dev/sdc6...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda6 -O /dev/sdc6
Cloned successfully.
*****************************************************
Source partition file system is ext4...
Cloning the /dev/sda7 to /dev/sdc7...
Clean filesystem header in device /dev/sdc7...
*****************************************************.
Using partclone to clone...
Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -b -s /dev/sda7 -O /dev/sdc7
Cloned successfully.
*****************************************************.
*****************************************************.
Searching for data partition(s) in target disk for post process: sdc...
Excluding busy partition or disk...
Unmounted partitions (including extended or swap): sdc1 sdc2 sdc3 sdc4 sdc5 sdc6 sdc7
Collecting info........ done!
*****************************************************.
Now tuning the file system size on partition /dev/sdc1 to fit the partition size...
Program fatresize not found! Skip this partition /dev/sdc1
*****************************************************.
Now tuning the file system size on partition /dev/sdc2 to fit the partition size...
e2fsck -f -y /dev/sdc2; resize2fs -p -f /dev/sdc2
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdc2: 11/96000 files (0.0% non-contiguous), 15356/386560 blocks
resize2fs 1.43.4 (31-Jan-2017)
The filesystem is already 386560 (4k) blocks long. Nothing to do!

*****************************************************.
Now tuning the file system size on partition /dev/sdc3 to fit the partition size...
e2fsck -f -y /dev/sdc3; resize2fs -p -f /dev/sdc3
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
rootMX18.1: 265235/2088960 files (0.0% non-contiguous), 1641803/8326912 blocks
resize2fs 1.43.4 (31-Jan-2017)
The filesystem is already 8326912 (4k) blocks long. Nothing to do!

*****************************************************.
Now tuning the file system size on partition /dev/sdc4 to fit the partition size...
e2fsck -f -y /dev/sdc4; resize2fs -p -f /dev/sdc4
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
boot: 779/106496 files (0.5% non-contiguous), 164652/407040 blocks
resize2fs 1.43.4 (31-Jan-2017)
The filesystem is already 407040 (4k) blocks long. Nothing to do!

*****************************************************.
Now tuning the file system size on partition /dev/sdc5 to fit the partition size...
e2fsck -f -y /dev/sdc5; resize2fs -p -f /dev/sdc5
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdc5: 341/169680 files (1.5% non-contiguous), 49544/657664 blocks
resize2fs 1.43.4 (31-Jan-2017)
The filesystem is already 657664 (4k) blocks long. Nothing to do!

*****************************************************.
Now tuning the file system size on partition /dev/sdc6 to fit the partition size...
e2fsck -f -y /dev/sdc6; resize2fs -p -f /dev/sdc6
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdc6: 314/171024 files (1.6% non-contiguous), 73266/685312 blocks
resize2fs 1.43.4 (31-Jan-2017)
The filesystem is already 685312 (4k) blocks long. Nothing to do!

*****************************************************.
Now tuning the file system size on partition /dev/sdc7 to fit the partition size...
e2fsck -f -y /dev/sdc7; resize2fs -p -f /dev/sdc7
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdc7: 11/640848 files (0.0% non-contiguous), 65844/2560000 blocks
resize2fs 1.43.4 (31-Jan-2017)
The filesystem is already 2560000 (4k) blocks long. Nothing to do!

*****************************************************.
Creating the swap partition if exists...
*****************************************************.
Trying to remove udev hardware record in the restored OS...
The specified destination device: sdc1 sdc2 sdc3 sdc4 sdc5 sdc6 sdc7
Trying to remove udev persistent files. The devices to be searched: sdc1 sdc2 sdc3 sdc4 sdc5 sdc6 sdc7...
Skip /dev/sdc1 (vfat).
Now searching possible device /dev/sdc2...
Now searching possible device /dev/sdc3...
Now searching possible device /dev/sdc4...
Now searching possible device /dev/sdc5...
Now searching possible device /dev/sdc6...
Now searching possible device /dev/sdc7...
done!
*****************************************************.
Device /dev/sdc2 is not a FAT partition.
Skip updating syslinux on that.
Device /dev/sdc3 is not a FAT partition.
Skip updating syslinux on that.
Device /dev/sdc4 is not a FAT partition.
Skip updating syslinux on that.
Device /dev/sdc5 is not a FAT partition.
Skip updating syslinux on that.
Device /dev/sdc6 is not a FAT partition.
Skip updating syslinux on that.
Device /dev/sdc7 is not a FAT partition.
Skip updating syslinux on that.
*****************************************************.
Run grub install on disk sdc...
Found grub partition: /dev/sdc3
Found grub 2 installed in the restored OS.
Test if we can chroot the restored OS partition /dev/sdc3...
Yes, we are able to chroot the restored OS partition /dev/sdc3.
Trying to use the grub2 in the restored OS...
Running: run_grub2_from_restored_os "/dev/sdc3" "/dev/sdc3" "/dev/sdc"
Re-installing grub2 on disk/partition /dev/sdc with grub2 dir in partition /dev/sdc3 and root partition /dev/sdc3...
Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.
Unable to use the grub 2 in the restored OS, trying another method...
Trying to use the grub2 from the running OS...
Checking grub-install version...
Running: grub-install --force --recheck --root-directory=/tmp/hd_img.MOkrC9 /dev/sdc
Installing for x86_64-efi platform.
grub-install: error: /tmp/hd_img.MOkrC9 doesn't look like an EFI partition.
Failed to install grub!!!
*****************************************************.
Try to run partclone.ntfsfixboot for NTFS boot partition if it exists. Scanning partition(s): sdc1 sdc2 sdc3 sdc4 sdc5 sdc6 sdc7...
The NTFS boot partition was not found or not among the restored partition(s). Skip running partclone.ntfsfixboot.
*****************************************************.
Checking if udevd rules have to be restored...
Now syncing - flush filesystem buffers...

Ending /usr/sbin/ocs-onthefly at 2019-06-25 14:31:55 CEST...
Press "Enter" to continue......

Risorse:

Annunci

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...