{"id":330,"date":"2007-11-24T15:50:07","date_gmt":"2007-11-24T20:50:07","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/2007\/11\/24\/filesystems\/"},"modified":"2007-11-24T15:50:07","modified_gmt":"2007-11-24T20:50:07","slug":"filesystems","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/11\/24\/filesystems\/","title":{"rendered":"Filesystems"},"content":{"rendered":"<p>On my continuing obsession with squeezing every bit of performance out of this system&#8230; They say that Linux filesystems don&#8217;t get fragmented. I never understood this. It&#8217;s apparently smarter about where files are placed. But still, frag-proof? If it was that easy, other filesystems would have figured it out long ago too. I figured that the explanation was just over my head. In reality, the &#8220;explanation&#8221; is that it&#8217;s a myth.<\/p>\n<pre><blockquote>\n<b>oxygen bin # <a href=\"http:\/\/forums.gentoo.org\/viewtopic-p-3081971.html\">fragck.pl<\/a> \/home<\/b>\n2.19458018658374% non contiguous files, 1.03385162150155 average fragments.\n<strong>oxygen bin # fragck.pl \/var\/log<\/strong>\n56.3218390804598% non contiguous files, 28.9425287356322 average fragments.\n<strong>oxygen bin # fragck.pl \/var\/www\/<\/strong>\n1.45061443222766% non contiguous files, 1.05527580153377 average fragments.\n<strong>oxygen bin # fragck.pl \/etc<\/strong>\n2.18023255813953% non contiguous files, 1.05450581395349 average fragments.\n<strong>oxygen bin # fragck.pl \/var\/lib\/mysql\/<\/strong>\n16.5424739195231% non contiguous files, 2.93740685543964 average fragments.<\/blockquote><\/pre>\n<p>The results kind of make sense: \/var\/log is full of files where you&#8217;re <em>constantly<\/em> appending a line or two to various files, so it only stands to reason that, if the filesystem isn&#8217;t <em>very<\/em> careful, fragmentation would build up. The other one is \/var\/lib\/mysql, where MySQL stores its data. It&#8217;s the same deal as \/var\/log, really, in that it&#8217;s continually adding files.<\/p>\n<p>\/var\/log\/messages, the system log file, is in 75 pieces. Its backup, messages.1.gz,was in 68.<\/p>\n<p>Realistically the performance hit is negligible. It&#8217;s not like a core system file is in hundreds of pieces. (Like, say, the paging file!) \/bin has very low fragmentation. Log files can be fragmented an not impact anything. (Except my OCD.) Although I am concerned about MySQL&#8217;s data stores building up fragmentation. In theory I can bring the database down and shuffle the files around, but it&#8217;s probably best left alone right now.<\/p>\n<p>Fortunately, there&#8217;s hope&#8230; By moving a file to another partition, you cause it to move physical locations. Something like <tt>mv messages \/tmp\/ramdisk && mv \/tmp\/ramdisk\/messages .<\/tt> will cause the file to be rewritten. (Granted, this particular command was an awful idea: syslog-ng keeps \/var\/log\/messages open, and doesn&#8217;t like it when the file randomly disappears. The fact that it was only gone for a split-second doesn&#8217;t change the fact that the files location has changed.) Although don&#8217;t get too excited about this: for some reason, fragmentation sometimes ends up worse! access_log was in 60 pieces. Now it&#8217;s in 76.<\/p>\n<p>I&#8217;ve also heard it said that some fragmentation isn&#8217;t necessarily a bad thing: a few files close together on the disk with light fragmentation is better than frag-free files on opposite ends of the disk. But that doesn&#8217;t satisfy my OCD. I guess the moral of the story is to not muck around too much with things. Or, &#8220;if it ain&#8217;t broke, don&#8217;t fix it!&#8221;<\/p>","protected":false},"excerpt":{"rendered":"<p>On my continuing obsession with squeezing every bit of performance out of this system&#8230; They say that Linux filesystems don&#8217;t get fragmented. I never understood this. It&#8217;s apparently smarter about where files are placed. But still, frag-proof? If it was &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/11\/24\/filesystems\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5,10,12,13,18,22,24],"tags":[],"class_list":["post-330","post","type-post","status-publish","format-standard","hentry","category-computers","category-cool-links","category-ideas","category-interesting","category-linux-tips","category-ocd","category-programming","category-rants-raves"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=330"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/330\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}