{"id":137,"date":"2021-10-27T08:45:42","date_gmt":"2021-10-27T13:45:42","guid":{"rendered":"https:\/\/xkahn.zoned.net\/blog\/?p=137"},"modified":"2021-10-27T08:45:42","modified_gmt":"2021-10-27T13:45:42","slug":"dealing-with-a-dmg-file-on-linux","status":"publish","type":"post","link":"https:\/\/xkahn.zoned.net\/blog\/2021\/10\/27\/dealing-with-a-dmg-file-on-linux\/","title":{"rendered":"Dealing with a DMG file on Linux"},"content":{"rendered":"\n<p>I received a <code>.dmg<\/code> file from a Mac user today claiming it was a video file. It took a long while to figure out how to examine this file, so here are my notes so I don&#8217;t ever have to do it again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Uncompress the file<\/h2>\n\n\n\n<p>My first step was to use <code>7z<\/code> to uncompress it, but that produced the wrong results for some reason. Use <code>dmg2img<\/code> instead.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u00b1 <strong>dmg2img ~\/Downloads\/file.dmg<\/strong>\n\ndmg2img v1.6.5 (c) vu1tur (to@vu1tur.eu.org)\n\n~\/Downloads\/file.dmg --> ~\/Downloads\/file.img\n\n\ndecompressing:\nopening partition 0 ...             100.00%  ok\nopening partition 1 ...             100.00%  ok\nopening partition 2 ...             100.00%  ok\nopening partition 3 ...             100.00%  ok\nopening partition 4 ...             100.00%  ok\nopening partition 5 ...             100.00%  ok\nopening partition 6 ...             100.00%  ok\nopening partition 7 ...             100.00%  ok\n\nArchive successfully decompressed as ~\/Downloads\/file.img<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Locate the partition inside the <code>img<\/code> file<\/h2>\n\n\n\n<p>Okay. So now you have an <code>.img<\/code> file which is actually a virtual hard disk. You need to find the filesystems inside that virtual disk.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u00b1 <strong>sudo losetup --find --show ~\/Downloads\/file.img<\/strong>\n\/dev\/loop0\n\u00b1 <strong>sudo partprobe -s \/dev\/loop9<\/strong>\n\/dev\/loop0: gpt partitions 1<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Mount the partition as a filesystem<\/h2>\n\n\n\n<p>You now have two new virtual devices: <code>\/dev\/loop0<\/code> and <code>\/dev\/loop0p1<\/code> (from the two commands in the last step!) and you can mount them now.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u00b1 <strong>sudo mount \/dev\/loop0p1 \/mnt<\/strong>\n\u00b1 <strong>ls \/mnt<\/strong>\ntotal 0\n0 file.app\/<\/pre>\n\n\n\n<p>Now you can do all the actions you want on the archive. Enjoy!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Cleaning up<\/h2>\n\n\n\n<p>Once you&#8217;re done, you need to clean up the mess we just made&#8230; Make sure no applications are using the files or you&#8217;ll get errors. (Hint: use the <code>fuser<\/code> command if you need to identify processes using the files. Also remember that your shell might be blocking it if you are in the directory.)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u00b1 <strong>sudo umount \/mnt\/ext<\/strong>\n\u00b1 <strong>sudo losetup -d \/dev\/loop0<\/strong><\/pre>\n\n\n\n<p>You&#8217;re done!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I received a .dmg file from a Mac user today claiming it was a video file. It took a long while to figure out how to examine this file, so here are my notes so I don&#8217;t ever have to do it again. Step 1: Uncompress the file My first step was to use 7z\u2026 <span class=\"read-more\"><a href=\"https:\/\/xkahn.zoned.net\/blog\/2021\/10\/27\/dealing-with-a-dmg-file-on-linux\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-137","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/posts\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":1,"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":138,"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/posts\/137\/revisions\/138"}],"wp:attachment":[{"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xkahn.zoned.net\/blog\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}