0

I need a hex dump of a usb flash drive from the first few kilobytes. The flashdrive is fresh formatted with fat32 what i did is checking with lsblk where is my usb device and i got:

sdb                     8:16   0 186.3G  0 disk 
└─sdb1                  8:17   0 186.3G  0 part /media/me/E614-2E0B

Then i copy the data with: dd if=/dev/sdb1 of=usb.img bs=1024 count=5

And the result is:

00000000: eb58 906d 6b66 732e 6661 7400 0240 4000  .X.mkfs.fat..@@.
00000010: 0200 0000 00f8 0000 3f00 ff00 3f00 0000  ........?...?...
00000020: 82dd 4917 80ba 0000 0000 0000 0200 0000  ..I.............
00000030: 0100 0600 0000 0000 0000 0000 0000 0000  ................
00000040: 8001 290b 2e14 e64e 4f20 4e41 4d45 2020  ..)....NO NAME
00000050: 2020 4641 5433 3220 2020 0e1f be77 7cac    FAT32   ...w|.
00000060: 22c0 740b 56b4 0ebb 0700 cd10 5eeb f032  ".t.V.......^..2
00000070: e4cd 16cd 19eb fe54 6869 7320 6973 206e  .......This is n
00000080: 6f74 2061 2062 6f6f 7461 626c 6520 6469  ot a bootable di
00000090: 736b 2e20 2050 6c65 6173 6520 696e 7365  sk.  Please inse
000000a0: 7274 2061 2062 6f6f 7461 626c 6520 666c  rt a bootable fl
000000b0: 6f70 7079 2061 6e64 0d0a 7072 6573 7320  oppy and..press
000000c0: 616e 7920 6b65 7920 746f 2074 7279 2061  any key to try a
000000d0: 6761 696e 202e 2e2e 200d 0a00 0000 0000  gain ... .......
000000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000100: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000110: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000120: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000140: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000150: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000160: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000170: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000180: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000190: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.
00000200: 5252 6141 0000 0000 0000 0000 0000 0000  RRaA............
00000210: 0000 0000 0000 0000 0000 0000 0000 0000  ................

In the right column I can see the text "this is not a bootable disk. Please insert a bootable floppy and..press any key to try again". Now im not sure if this is really the content of my usb flash drive or if there was an error. Is this the right way to get the byte data from my flash drive or is there a other way to get a hex dump from my usb device?

Edit: if I use /dev/sdb I get:

00000000  33 c0 fa 8e d8 8e d0 bc  00 7c 89 e6 06 57 8e c0  |3........|...W..|
00000010  fb fc bf 00 06 b9 00 01  f3 a5 ea 1f 06 00 00 52  |...............R|
00000020  52 b4 41 bb aa 55 31 c9  30 f6 f9 cd 13 72 13 81  |R.A..U1.0....r..|
00000030  fb 55 aa 75 0d d1 e9 73  09 66 c7 06 8d 06 b4 42  |.U.u...s.f.....B|
00000040  eb 15 5a b4 08 cd 13 83  e1 3f 51 0f b6 c6 40 f7  |..Z......?Q...@.|
00000050  e1 52 50 66 31 c0 66 99  e8 66 00 e8 21 01 4d 69  |.RPf1.f..f..!.Mi|
00000060  73 73 69 6e 67 20 6f 70  65 72 61 74 69 6e 67 20  |ssing operating |
00000070  73 79 73 74 65 6d 2e 0d  0a 66 60 66 31 d2 bb 00  |system...f`f1...|
00000080  7c 66 52 66 50 06 53 6a  01 6a 10 89 e6 66 f7 36  ||fRfP.Sj.j...f.6|
00000090  f4 7b c0 e4 06 88 e1 88  c5 92 f6 36 f8 7b 88 c6  |.{.........6.{..|
000000a0  08 e1 41 b8 01 02 8a 16  fa 7b cd 13 8d 64 10 66  |..A......{...d.f|
000000b0  61 c3 e8 c4 ff be be 7d  bf be 07 b9 20 00 f3 a5  |a......}.... ...|
000000c0  c3 66 60 89 e5 bb be 07  b9 04 00 31 c0 53 51 f6  |.f`........1.SQ.|
000000d0  07 80 74 03 40 89 de 83  c3 10 e2 f3 48 74 5b 79  |[email protected][y|
000000e0  39 59 5b 8a 47 04 3c 0f  74 06 24 7f 3c 05 75 22  |9Y[.G.<.t.$.<.u"|
000000f0  66 8b 47 08 66 8b 56 14  66 01 d0 66 21 d2 75 03  |f.G.f.V.f..f!.u.|
00000100  66 89 c2 e8 ac ff 72 03  e8 b6 ff 66 8b 46 1c e8  |f.....r....f.F..|
00000110  a0 ff 83 c3 10 e2 cc 66  61 c3 e8 62 00 4d 75 6c  |.......fa..b.Mul|
00000120  74 69 70 6c 65 20 61 63  74 69 76 65 20 70 61 72  |tiple active par|
00000130  74 69 74 69 6f 6e 73 2e  0d 0a 66 8b 44 08 66 03  |titions...f.D.f.|
00000140  46 1c 66 89 44 08 e8 30  ff 72 13 81 3e fe 7d 55  |F.f.D..0.r..>.}U|
00000150  aa 0f 85 06 ff bc fa 7b  5a 5f 07 fa ff e4 e8 1e  |.......{Z_......|
00000160  00 4f 70 65 72 61 74 69  6e 67 20 73 79 73 74 65  |.Operating syste|
00000170  6d 20 6c 6f 61 64 20 65  72 72 6f 72 2e 0d 0a 5e  |m load error...^|
00000180  ac b4 0e 8a 3e 62 04 b3  07 cd 10 3c 0a 75 f1 cd  |....>b.....<.u..|
00000190  18 f4 eb fd 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  56 b4 07 1e 00 00 80 01  |........V.......|
000001c0  01 00 07 fe ff ff 3f 00  00 00 82 dd 49 17 00 00  |......?.....I...|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

There the string "operating system load error" occurs.

What I want is a dump which contains the FAT - The file allocation table.

2
  • 1
    "Now im not sure if this is really the content of my usb flash drive" - it is... what did you expect to see?
    – Attie
    Commented Jun 27, 2018 at 12:14
  • The text "this is not a bootable disk. Please insert a bootable floppy and..press any key to try again" makes me curious, why is it there?
    – Eisen
    Commented Jun 27, 2018 at 12:18

2 Answers 2

1

This is correct if you're trying to get a dump of the partition (/dev/sdb1) - which it sounds like you are.

This text is present because it is used by (and stored at the end of) a very rudimentary "boot_code" block that mkfs.fat places on the partition. This ensures compatibility with old technology like floppies "just in case". The reason this text is there is largely "because of history" in the modern world.

You can see this text in the mkfs.fat source code here: src/mkfs.fat.c:209

The file allocation table isn't a "small thing you can see", but (in the case of FAT - thanks @grawity) is stored as a large chunk a little further into the partition. You'll need to be very comfortable with handling raw data and doing base-16 maths in your head to understand the file table without a tool.

You might want to research further into FAT:

1

Yes – but because you specified 'sdb1' as the device name, the read starts at the beginning of 1st partition rather than the beginning of the whole drive (which is 'sdb').

So you are seeing the first few sectors of a FAT32 filesystem. FAT reserves this space for a VBR ("volume boot record") and various FAT formatting tools add a basic 'placeholder' VBR here, hence the boot error message.

(Additionally, floppy disks and other "superfloppy"-formated devices don't have partitions – the filesystem starts at sector 0, so the FAT VBR is the floppy disk's MBR.)

To read data from the entire disk (ignoring partition boundaries) use /dev/sdb as the input file. (You can use any tool, e.g. head -c 5k /dev/sdb | hexdump -C if you want.)

4
  • Hello thank you for your answer. What I want is to see the file allocation table and the first few data. If i use /dev/sdb I get a result where the string "Operating system load error" occurs.
    – Eisen
    Commented Jun 27, 2018 at 12:36
  • 1
    The file allocation table isn't a "small thing you can see", but is spread throughout the disk. If this is what you want to see, then using the partition (/dev/sdb1) is correct. You'll need to be very comfortable with handling raw data and doing base-16 maths in your head to understand the FAT without a tool.
    – Attie
    Commented Jun 27, 2018 at 12:39
  • 1
    It's not very spread out in case of FAT (there seems to be just a single table containing everything), but it's located slightly deeper into the partition. (For example, fsck -v /dev/sdb1 for me shows "First FAT starts at byte 16384" and "Data area starts at byte 4146176".) Commented Jun 27, 2018 at 12:42
  • Depending on filesystem, though, the layout can vary from "dead simple" to "insanely complicated", so if you ever want to examine e.g. ext4 or NTFS, then prefer dedicated tools (debugfs etc.) instead of raw hexdumps. Commented Jun 27, 2018 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .