How do I use dd to copy the first 2 partitiions of /dev/sda (windows reserved, window7) to a file on /Dev/sdb?
I think I can cd to /media/sam/1TB-NTFS/{ a folder I create } and run dd from there:
dd if=/dev/sda of={the folder created}/filename`
but I'm having trouble figuring out how many bytes to copy from sda so when I restore it I don't step on sda3.
................. results of fdisk ...............
am@Homebuilt:~$ sudo fdisk -l
[sudo] password for sam:
Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: WDC WD5000AZLX-0
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: dos
Disk identifier: 0xc1f6d562
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 206847 204800 100M 7 HPFS/NTFS/exFAT
/dev/sda2 206848 585312209 585105362 279G 7 HPFS/NTFS/exFAT
/dev/sda3 * 585312256 586362879 1050624 513M ef EFI (FAT-12/16/32)
/dev/sda4 586364926 976771071 390406146 186.2G 5 Extended
/dev/sda5 586364928 976771071 390406144 186.2G 83 Linux
Partition 4 does not start on physical sector boundary.
Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 244190646 sectors
Disk model: EZEX-00BN5A0
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x000e72ed
Device Boot Start End Sectors Size Id Type
/dev/sdb1 256 244189951 244189696 931.5G 7 HPFS/NTFS/exFAT
.........................................................................
204800 + 585105362 = 585310162 total sectors for sda1 + sda2 @ 512 byts/sector =
299678802944 (bytes)/ 1024 = 292655081 1k blocks
299678802944 (bytes)/ 2048 = 146327540.5 2k blocks
something isn't right here, the # of bytes should be evenly divisible by 2048,4096,8192 ....etc should it not?
dd /dev/sda1 of=sda1.imgwithout acountattribute, so the whole partition gets copied to the file, then the same thing with sda2. When copying back,ddstops at the end of the file, so nothing will go wrong, no matter how the disk is formatted. – Philippos Apr 24 '23 at 05:36ddthe whole disk to a file and restore only the first 2 partitions to the disk? Eitherddthe partitions separate (easy approach) or calculate manually. The sector size ofsdbhas nothing to do with that. Sector count ofsdahas to be divideable by 512 as it's the logical sector size. – stoney Apr 24 '23 at 05:51