Fragmentation Of The Ext4 File System In Ubuntu

0
6

DIFFERENCE BETWEEN WINDOWS AND GNU / LINUX

"Data in the computer is stored in files that are written on the hard disk which is like a giant closet with millions of drawers and each drawer has the same capacity (usually 512 bytes). be accessed faster than if it was in a discontinuous (fragmented) order into the closet. So far, it is understood that "things" can be found faster in an ordered closet than in a messy one. the closet organized when it is frequently used. "

(Extracted from an external article).

Now imagine a company that keeps its records in a huge closet with millions of drawers. The goal is to have all the documents relating to the same file in adjunct bins. The company needs to hire a secretary. There are two candidates:

The first candidate (Windows) works as follows: when a file is deleted from the file, simply empty the drawers; when a new file needs to be entered, it separates it into small groups of documents with the size of a drawer (512 bytes), and archives each group randomly, in the first empty drawer in the closet. Sooner or later it will become very difficult to quickly find all documents related to a file and the company will have to hire, every weekend, a dozen assistants to put everything back in order.

The second (GNU / Linux), keeps a list of contiguous empty drawers on her desk, which is updated every time a file is closed and removed from the drawers. When a new file is entered, it searches its list for a set of contiguous empty drawers as necessary, and that is where it places the new record. So the cabinet will always be tidy, even though there are many records movements.

KNOWING THE FRAGMENTATION LEVEL IN A GNU / LINUX SYSTEM

How can the user know the defragmentation an ext4 file system has in Ubuntu or any GNU / Linux?

It's a simple method that will let the user know how fragmented is the file system,

Warning:

DO NOT RUN FSCK COMMAND ON MOUNTED PARTITION as this may damage the file system. There may be an application working with the files, as it usually happens with mounted partitions.

To do this safely, it is best to start in Live-CD mode (without changing the computer) or from another Linux partition (if exists) and open a Terminal.

Users can see partitions are installed installed in Ubuntu with the following command:

sudo fdisk-l

The terminal will return something like this:

/ dev / sda1 * 1 12748 102398278+ 7 HPFS / NTFS / dev / sda2 12749 60802 385988219+ 5 Extendida / dev / sda5 60316 60802 3905536 82 Linux swap / Solaris

/ dev / sda6 55864 60315 35760658 + 83 Linux

Locate the Linux partition that says 83 for the ID number. In this case it is:

/ Dev / sda6

Now see how the filesystem is doing with this command:

sudo fsck.ext4 -vpf / dev / sda6

Where ext4 is the file system that the system has (can also be ext3) and sda6 is the partition where Ubuntu is installed.

The terminal will return something like:

177653 inodes used (7.27%) 197 non-contiguous files (0.1%) 240 non-contiguous directories (0.1%) # de nodos-i con bloques ind / dind / tind: 0/0/0 Extent depth histogram: 137975/93 2545505 blocks used (26.07%) 0 bad blocks 1 large file 113484 regular files 17973 directories 60 character device files 26 block device files 0 fifos 729 links 46094 symbolic links (39482 fast symbolic links) 7 sockets

In this case (shown in red), the file system has 0.1% of defragmentation, This is from a computer that has a lot of applications being installed and removed all the time.

DEFRAGMENTATION TOOL FOR GNU / LINUX

Desktop users do not need this application, but can be useful for servers that handle a lot of information. There is defragmentation application called "e4defrag" not suitable for beginners and for now is only recommended for experts. For more information:

http://polishlinux.org/apps/cli/ext4-defragmentation-with-e4defrag/

Learn more about ext4 partitions in U buntu.

Source

Leave a Reply