{"id":129,"date":"2007-03-06T16:08:07","date_gmt":"2007-03-06T16:08:07","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=129"},"modified":"2007-03-06T16:08:07","modified_gmt":"2007-03-06T16:08:07","slug":"files-on-linux-can-get-fragmented","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=129","title":{"rendered":"Files on linux can get fragmented"},"content":{"rendered":"<p>I vaguely remember someone telling me ages ago that Linux distros don&#8217;t come with a Disk Defragmentation utility (like <a href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Disk_Defragmenter\" title=\"Wikipedia reference\" target=\"_blank\">Windows does<\/a>) because files on Linux don&#8217;t get fragmented. <\/p>\n<p>For some reason, I didn&#8217;t really challenge that very much at the time, and it&#8217;s remained at the back of my mind as a bit of an assumption. One of the things I&#8217;ve learned on my <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=128\">Linux course this week<\/a> is that this isn&#8217;t true. <\/p>\n<p><!--more-->We&#8217;ve been playing with filesystems this afternoon, and one of the options to <code>mke2fs<\/code> that I&#8217;ve not used before is <strong><code>-m<\/code><\/strong>.<\/p>\n<p>When you&#8217;re creating a new filesystem, the <code>-m<\/code> option lets you specify the percentage of blocks that are reserved for the superuser. These reserved blocks are used by the filesystem to avoid fragmentation. So if you set this too low (or worse, set it to 0), then fragmentation can result. <\/p>\n<p>And because this is defined when you create the filesystem, the only way to remove fragmentation is to recreate the filesystem (restoring data from a backup). <\/p>\n<p><code>filefrag<\/code> (again, something I&#8217;ve never come across before!) seems to let you see if a file is fragmented:<\/p>\n<pre><code>[root@station17 ~]# filefrag install.log\r\ninstall.log: 2 extents found, perfection would be 1 extent<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I vaguely remember someone telling me ages ago that Linux distros don&#8217;t come with a Disk Defragmentation utility (like Windows does) because files on Linux don&#8217;t get fragmented. For some reason, I didn&#8217;t really challenge that very much at the time, and it&#8217;s remained at the back of my mind as a bit of an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=129"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}