Keep the partition type unchange when to dd a file into it

List the file type on sdb:

debian@debian:~$ sudo blkid |grep  sdb
/dev/sdb1: UUID="19a2c9fa-f793-415d-9e25-082fa3bbbb3d" TYPE="ext4" PARTUUID="eb3ae1bb-01"
/dev/sdb2: UUID="11d2d221-e53e-4828-8e3e-50e63ffb01ce" TYPE="ext4" PARTUUID="eb3ae1bb-02"

DD a image file into sdb1.

debian@debian:~$ sudo dd if=openwrt-19.07.7-x86-64-combined-ext4.img of=/dev/sdb1   bs=4M
68+1 records in
68+1 records out
285736960 bytes (286 MB, 272 MiB) copied, 0.156294 s, 1.8 GB/s
debian@debian:~$ sync

Show the file type again:

debian@debian:~$ sudo blkid |grep sdb
/dev/sdb1: PTUUID="eb3ae1bb" PTTYPE="dos" PARTUUID="eb3ae1bb-01"
/dev/sdb2: UUID="11d2d221-e53e-4828-8e3e-50e63ffb01ce" TYPE="ext4" PARTUUID="eb3ae1bb-02"

How to keep the partition type unchange when to dd a file into it

Change it back using fdisk/gdisk?

The "combined" image is an image of the whole disk, including a partition table. It should be written to the base disk (/dev/sda, note there is no partition number so it is the whole disk). Of course that will wipe out any existing partition table and lose access to any existing data on the disk.

If you only want to flash the rootfs you need an image of the rootfs, which is the rootfs-ext4.img.gz file in the distribution directory. Write this to an existing partition (/dev/sda2 etc) which is large enough to hold the filesystem.

1 Like