{"id":3835,"date":"2012-06-21T22:17:22","date_gmt":"2012-06-22T05:17:22","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=3835"},"modified":"2012-06-21T22:17:22","modified_gmt":"2012-06-22T05:17:22","slug":"size-discrepany-in-the-du-command","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/size-discrepany-in-the-du-command\/","title":{"rendered":"Size Discrepany in the &#8216;du&#8217; Command"},"content":{"rendered":"<p>I had a problem today while using the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Du_%28Unix%29\">common Unix command &#8216;du&#8217;<\/a>. As a refresher, &#8216;du&#8217; stands for disk usage and is a handy tool for understanding how much disk space is being occupied.<\/p>\n<p>I think &#8216;du&#8217; is probably doing the right thing. The problem might be that I&#8217;m getting strange (read: 1\/2 the expected number) when running the tool against directories on vmhgfs, the VMware filesystem.<\/p>\n<p><strong>Science Project<\/strong><br \/>\nOn an Ubuntu Linux VMware session, my home directory is on the main file system, which is ext4. The directory \/mnt\/hgfs is reported by &#8216;mount&#8217; to be of type vmhgfs and is shared with the host machine.<\/p>\n<p>Create a directory in the home directory and generate a 10 MiB file:<\/p>\n<pre>\r\nmkdir \/home\/melanson\/dir\r\ndd if=\/dev\/urandom of=\/home\/melanson\/dir\/random-file bs=1048576 count=10\r\n<\/pre>\n<p>Create  a directory on the shared drive and copy the same file:<\/p>\n<pre>\r\nmkdir \/mnt\/hgfs\/vmshare\/dir\r\ncp \/home\/melanson\/dir\/random-file \/mnt\/hgfs\/vmshare\/dir\r\n<\/pre>\n<p>Run &#8216;du&#8217; on each directory using the -k and -h options:<\/p>\n<pre>\r\ndu -k \/home\/melanson\/dir \/mnt\/hgfs\/vmshare\/dir\r\n10244   \/home\/melanson\/dir\r\n5120    \/mnt\/hgfs\/vmshare\/dir\r\n\r\ndu -h \/home\/melanson\/dir \/mnt\/hgfs\/vmshare\/dir\r\n11M    \/home\/melanson\/directory\r\n5.0M   \/mnt\/hgfs\/vmshare\/directory\r\n<\/pre>\n<p>I noticed this discrepancy when I was trying to pack a set of files (akin to &#8216;tar&#8217;-ing) living in a directory in the shared location. I was going mad trying to understand why the original directory was only 2 MB as reported by &#8216;du&#8217; but the final packed file was 4 MB.<\/p>\n<p>To be fair, the man page for &#8216;du&#8217; succinctly states that the tool&#8217;s purpose is merely to <em>&#8220;<strong>estimate<\/strong> file space usage&#8221;<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Either the &#8216;du&#8217; command has an issue or the vmhgfs filesystem works in a strange manner<\/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-3835","post","type-post","status-publish","format-standard","hentry","category-general"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=3835"}],"version-history":[{"count":6,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3835\/revisions"}],"predecessor-version":[{"id":3841,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3835\/revisions\/3841"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=3835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=3835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=3835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}