This particular question is related to Raspberry Pi, but in fact, this is a general question.
So, I have an SD card with RPI system running on it consisting of two partitions:
Disk /dev/mmcblk0: 59.5 GiB, 63864569856 bytes, 124735488 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf4481065
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 532479 524288 256M c W95 FAT32 (LBA)
/dev/mmcblk0p2 532480 124735487 124203008 59.2G 83 Linux
Also, I have an external HDD connected which works as a data storage now consisting of four partitions:
Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: EZRZ-00Z5HB0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 9E92BCDF-4CF7-4ECE-ABCD-5B6794FE747E
Device Start End Sectors Size Type
/dev/sda1 2048 125831167 125829120 60G Linux filesystem
/dev/sda2 125831168 754976767 629145600 300G Linux filesystem
/dev/sda3 754976768 2331002879 1576026112 751.5G Linux filesystem
/dev/sda4 2331002880 3907028991 1576026112 751.5G Linux filesystem
What I want to do is to move my RPI system from the SD card to the first partition of the HDD. Can I use the following command to clone the entire SD card (two partitions) to the first partition of the HDD?
dd if=/dev/mmcblk0 of=/dev/sda1 ...
As the destination partition is a bit larger (124735488 vs 125829120 sectors) I expect that the first HDD partition will be split by two (boot and root) and all the others sda2, sda3, etc. will remain intact. So after this operation, I will be able to boot from the HDD instead of the SD card (of course after checking all the UUIDs which may change after the migration).
It should be okay AFAIK, but I have no possibility to test this process currently. So want to double-check everything and be 100% sure to not mess up the entire system.
upd. Yes, I understand that the sda1 content will be destroyed permanently.