{"id":630,"date":"2014-07-12T12:57:43","date_gmt":"2014-07-12T18:57:43","guid":{"rendered":"http:\/\/vostorga.org\/?p=630"},"modified":"2014-07-12T12:57:43","modified_gmt":"2014-07-12T18:57:43","slug":"mounting-a-partition-from-a-dd-image","status":"publish","type":"post","link":"https:\/\/vostorga.org\/?p=630","title":{"rendered":"Mounting a partition from a dd image"},"content":{"rendered":"<p>At some point, everybody may have done a dd image of a USB\/SD stick, as the below example shows:<\/p>\n<blockquote>\n<pre><code>dd if=\/dev\/sdb of=foo.img \r\n<\/code><\/pre>\n<\/blockquote>\n<p>But it is usual that at some point in time we would like to access the information inside the image, doing that is quite easy:<\/p>\n<p><code>First,you should do a fdisk on the image:<br \/>\n<\/code><\/p>\n<blockquote><p>fdisk -l foo.img<\/p>\n<p>Disk foo.img: 7998 MB, 7998537728 bytes, 15622144 sectors<br \/>\n<strong>Units = sectors of 1 * 512 = 512 bytes<\/strong><br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0x0002fc6d<\/p>\n<p>Device Boot\u00a0\u00a0\u00a0\u00a0\u00a0 <strong>Start<\/strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0\u00a0\u00a0\u00a0\u00a0 Blocks\u00a0\u00a0 Id\u00a0 System<br \/>\nfoo.img1\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong> 1\u00a0<\/strong>\u00a0\u00a0 15622143\u00a0\u00a0\u00a0\u00a0 7811071+\u00a0\u00a0 c\u00a0 W95 FAT32 (LBA)<\/p><\/blockquote>\n<p>Then some maths are needed. The operators are the start of the partition and the sector size in bytes.\u00a0 The operation is simply start * sector size in bytes.<\/p>\n<p>In this particular case the operation is 1 * 512 = 512.<\/p>\n<p>Now that we have the result, that we call the offset. In other words, 512 is the offset where the partition starts in this dd image.<\/p>\n<p>So the command to mount the partition is:<\/p>\n<blockquote><p>mount -t vfat -o loop,ro,noexec,offset=512 foo.img \/mnt\/mountpoint<\/p><\/blockquote>\n<p>And then we can copy the information from the partition inside!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At some point, everybody may have done a dd image of a USB\/SD stick, as the below example shows: dd if=\/dev\/sdb of=foo.img But it is usual that at some point in time we would like to access the information inside the image, doing that is quite easy: First,you should do a fdisk on the image: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92,48,3],"tags":[],"class_list":["post-630","post","type-post","status-publish","format-standard","hentry","category-debian","category-gentoo","category-linux"],"_links":{"self":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/630"}],"collection":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=630"}],"version-history":[{"count":4,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/630\/revisions"}],"predecessor-version":[{"id":634,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/630\/revisions\/634"}],"wp:attachment":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}