1

I have a ubuntu live usb. I want to check integrity of the live usb. This can be done by comparing checksum of iso file I created with that mentioned at this url. So, I created ISO image of usb using sudo cat /dev/sdb > /home/user/test.iso. The ISO image I am getting is of 4gb since usb is of 4 gb whereas original iso is less than 1 gb. How can I recreate original iso from live usb ?

3
  • edited to answer your queries
    – aks
    Mar 10, 2014 at 16:54
  • I'm not sure that you can ... If you suspect the usb, you'd have to hash the files and compare to hash of the files on the ISO. Otherwise, wipe the usb and reimage,
    – schroeder
    Mar 10, 2014 at 18:15
  • This question does not appear to be about Information security within the scope defined in the help center. Apr 11, 2014 at 9:55

1 Answer 1

0

You could "count" how many bytes you want (using df), and use dd to only copy that amount of blocks:

For example: I write a 1.8MB ISO to a 1GB USB key:

# dd if=/usr/lib/memtest86+/memtest86+.iso of=/dev/sdb

If I do a normal DD, it will copy the entire GB

# dd if=/dev/sdb of=/tmp/full_disk.iso
 1957888+0 records in
 1957888+0 records out
 1002438656 bytes (1.0 GB) copied, 2.56494 s, 391 MB/s

By using df, I can figure out how many k-blocks (or 1024)

# df -P /dev/sdb
 Filesystem     1024-blocks  Used Available Capacity Mounted on
 /dev/sdb              1796  1796         0     100% /mnt

With this, one can copy only the number of blocks, 1796 in my case:

# dd count=1796 bs=1024 if=/dev/sdb of=/tmp/usb.iso
 1796+0 records in
 1796+0 records out
 1839104 bytes (1.8 MB) copied, 0.00999846 s, 184 MB/s

Using md5sum we can see that the usb.iso file is the same as the original ISO:

# md5sum /usr/lib/memtest86+/memtest86+.iso /tmp/full_disk.iso /tmp/usb.iso 
 bbd27e6fb8747109cde9bb1e3e7117ab  /usr/lib/memtest86+/memtest86+.iso
 a42d80c87c091d04ae9d6426d70c4e82  /tmp/full_disk.iso
 bbd27e6fb8747109cde9bb1e3e7117ab  /tmp/usb.iso

You must log in to answer this question.