{"id":908,"date":"2022-10-27T03:04:26","date_gmt":"2022-10-26T21:04:26","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=908"},"modified":"2022-10-27T03:04:26","modified_gmt":"2022-10-26T21:04:26","slug":"how-to-mount-raw-img-images-in-linux","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-mount-raw-img-images-in-linux.html","title":{"rendered":"How to mount raw (.img) images in Linux"},"content":{"rendered":"\n<p>You may have raw images in your system coming from some bare metal VM, like KVM\/Vmware. You may mount them directly to the host machine without attaching them to a VM. To do so, you need two things:<\/p>\n\n\n\n<ol><li>Partition to mount<\/li><li>Sector size of the partition and the first position of the partition. <\/li><\/ol>\n\n\n\n<p>Both of these, can be derived using a command called fdisk with attribute l as the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@vps5 vpsextra]# fdisk -l mhdevelopment.img\n\nDisk mhdevelopment.img: 268.4 GB, 268435456000 bytes, 524288000 sectors\nUnits = sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk label type: dos\nDisk identifier: 0x000f1752\n\n            Device Boot      Start         End      Blocks   Id  System\nmhdevelopment.img1            2048   523241471   261619712   83  Linux\nmhdevelopment.img2       523241472   524287999      523264   82  Linux swap \/ Solaris\nYou have new mail in \/var\/spool\/mail\/root\n[root@vps5 vpsextra]#\n<\/pre>\n\n\n\n<p>Here, we are trying to mount an old image of mine, called &#8216;mhdevelopment.img. I would like to mount the partition that is not swap, which is namely &#8216;mhdevelopment.img2&#8217; here. This partition starts from 2048 and the sector size is 512 bytes. <\/p>\n\n\n\n<p>So to mount the partition, you can now use the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo mount -o loop,offset=$((2048 * 512)) mhdevelopment.img \/mnt<\/pre>\n\n\n\n<p>This will mount the the partition mhdevelopment.img1 to \/mnt. If you want to change the mount destination, you may do this at the end in replace of \/mnt to wherever you want this to be.<\/p>\n\n\n\n<p>Happy shooting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may have raw images in your system coming from some bare metal VM, like KVM\/Vmware. You may mount them directly to the host machine without attaching them to a VM. To do so, you need two things: Partition to mount Sector size of the partition and the first position of the partition. Both of &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-mount-raw-img-images-in-linux.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to mount raw (.img) images in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[169,12],"tags":[159,695,696,697,698],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/908"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=908"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/908\/revisions"}],"predecessor-version":[{"id":909,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/908\/revisions\/909"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}