how to clone from one USB disk to another with Linux command line commands?

Posted on

Problem :

I have a Bigger 1T USB disk with Fedora 20 and some user data in total about 40GB on one partition which is about 900GB.I want to move this Fedora installation to a smaller 500GB USB disk.

Yesterday I shrank that partition to about 250GB with lvreduce. Now I want to clone/copy/move the Fedora 20 installation from the Bigger 1T USB disk to Smaller 500GB USB disk by command line. I need your help to tell me these commands step by step or point me to the right directon. I tried several GUI software, GPart Live, CloneZilla, Macrium Reflect and AOMEI Backupper. But no one works for me.

This is the Smaller USB disk, sdb, info: (parted -l):

Model: WD My Passport 070A (scsi)
    Disk /dev/sdb: 499GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  525MB  524MB  primary  ext4         boot
 2      525MB   499GB  499GB  primary               lvm

The Bigger USB disk, sdc, (parted -l):

Model: WD My Passport 0830 (scsi)
Disk /dev/sdc: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  525MB   524MB   primary  ext4         boot
 2      525MB   1000GB  1000GB  primary               lvm

And their partition info (lsblk)

NAME                  MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                     8:0    0 465.8G  0 disk 
├─sda1                  8:1    0   500M  0 part /boot
└─sda2                  8:2    0 465.3G  0 part 
  ├─fedora-root       253:0    0    50G  0 lvm  /
  ├─fedora-swap       253:1    0   7.8G  0 lvm  [SWAP]
  └─fedora-home       253:2    0 407.5G  0 lvm  /home
sdb                     8:16   0 465.1G  0 disk 
├─sdb1                  8:17   0   500M  0 part /run/media/bow/4bce62e0-0553-4f55-ba1a-2304064db9f5
└─sdb2                  8:18   0 464.6G  0 part 
sdc                     8:32   0 931.5G  0 disk 
├─sdc1                  8:33   0   500M  0 part /run/media/bow/3514a4dd-b94f-4750-abb4-4bf76a7402e8
└─sdc2                  8:34   0   931G  0 part 
  ├─fedora_lm-swap 253:3    0   3.8G  0 lvm  
  ├─fedora_lm-home 253:4    0   250G  0 lvm  /run/media/bow/2b6acd67-7c0d-4a7a-96e2-777f0edcfd6b
  └─fedora_lm-root 253:5    0    50G  0 lvm  /run/media/bow/fe656868-b7ec-424c-89a6-b08864579961
sr0                    11:0    1  1024M  0 rom  

Another question, why above sdb2 doesn’t have partition info?

Solution :

using dd to copy partition to another partition, while using physical drive

Assuming you have a layout that looks like this:

1 TB = sda, two partitions, sda1 that you booted from and sda2 that you are dd’ing to

320 GB = sdb, one partition, sdb1 that you are dd’ing from

Your command would look like this:

dd if=/dev/sdb1 of=/dev/sda2 bs=1M

The bs=1M parameter is there to ensure that dd copies the data in large chunks instead of issuing a request for each sector.

Leave a Reply

Your email address will not be published. Required fields are marked *