Get device size

https://unix.stackexchange.com/questions/52215/determine-the-size-of-a-block-device

blockdev --getsize64 /dev/sda | numfmt --to=iec-i

Create image from device

https://www.cyberciti.biz/faq/unix-linux-dd-create-make-disk-image-commands/

Restore

gunzip -c IMAGE.HERE-GZ | dd of=/dev/OUTPUT/DEVICE-HERE

MBR

https://www.cyberciti.biz/faq/howto-copy-mbr/

Linux Badblocks Command Examples to Check Disks and Partitions

badblocks command is used on a disk or partition to check whether any bad blocks are present. The following are few examples that will help you to identify bad blocks.

Warning: Do not perform this command if you don’t know what you are doing. Combining this command with other disk related command can be dangerous and erase all your data. So, try this command only on a test system for learning purpose.

1. Basic Usage of badblocks

When you execute badblocks command on a disk partition, depending on the size of the disk, it might take a long time to complete. Execute this command only on a partition that is not mounted.

By default, it doesn’t display any output on the screen, when there are no bad blocks as shown below.

# badblocks /dev/sda2

To see what the command is doing, and how much scanning it has done so far, use the badblocks -v option as shown below.