Изменение номера раздела sda в clonezilla img

330
Red

Я хочу скопировать систему Linux с компьютера на мой. Эта система Linux использует два раздела. ("/" и еще один)

Я использовал clonezilla, чтобы скопировать эти два раздела и поместить их в изображение. Но когда я их клонировал, они сохранили имена разделов, которые называются sda5 и sda7. Когда я использую Gparted на моем компьютере, у меня уже есть раздел sda5, поэтому, если я использую clonezilla, он ослабит этот раздел, чтобы скопировать другой.

Есть ли способ избежать этого? Может быть, переименование раздела внутри IMG?

1

1 ответ на вопрос

1
Tomas Tudja

I would recommend using dd on both computers, like this:

First, get rid of old data and deleted files by writing zeros all over the unoccupied space in that partition:

dd if=/dev/zero of=/mnt/original_partition/zerofile bs=16M conv=fdatasync 

This command will stop, when there is no space left on the partition. After that, remove the zerofile:

rm /mnt/original_partition/zerofile 

Now you only have your desired data on the partition on binary level, therefore compression will be easier. Now, make a binary image of your partition. Use fdisk -l to see what is the partition identifier (let's make it /dev/sdb5 in this example) and use that identifier in the next command. Note that in this example i'm using pigz instead of gzip. Pigz is parallel implementation of gzip and makes operations faster by using all cores of the system:

dd if=/dev/sdb5 bs=16M | pigz | dd of=/path/to/backup/storage/sdb5.img.gz bs=16M conv=fdatasync 

Now you have a compressed binary image of the partition. Transfer that to the other machine. Now you have to prepare your partition using fdisk (fdisk is very straight-forward to use). Make the partition as big as necessary and write changes to disk. Lets say, you have just created partition /dev/sdb3.

Now, use the following command to decompress your binary image and write it to the new partition:

dd if=/path/to/backup/storage/sdb5.img.gz bs=16M | pigz -d | dd of=/dev/sdb3 bs=16M conv=fdatasync 

After this command is done, you should be able to mount the copied partition using mount command:

mount /dev/sdb3 /mnt/copied-partition/ 

Please mind the partition size - it must be at least as big as the original one.

Похожие вопросы