Linux 101 : "Root" space, filesystem checking - mkfs.ext4, fsck.ext4, tune2fs -



We can specify in our filesystem, how much space should be dedicated to the "root" files. 
We could do that using the "-m" parameter with the "mkfs.ext4" command.

Remark:

The default space dedicated to the "privileged" files is "5%".

We can reserve "10%" of the filesystem to the "privileged" space using the below command:


We do that to keep the "normal" files from using up too much space at the expense of the "privileged" files used by "privileged" programs or the "root" user.

Remark:

We could either use "mkfs -t ext4" or "mkfs.ext4"

The "fsck.ext4" command:

The "fsck.ext4" command is used to check the "ext4" filesystems and to correct the errors.

We could use it as below:


We can see that since the "/dev/sdb1" partition is mounted, we can't check it.
Since our partition is mounted on the "/mnt" directory, we unmount it first using the below command:


Then we could check it using the below command:


In case the partition has issues, it is better to use the "fsck.ext4" command with the "-y" parameter to be able to interact with the command by answering its questions:


The "tune2fs" command:

To change the parameters of a filesystem, we could use the "tune2fs" command.

For example, we could change the percentage allocated to the "root" files, that was set in the above example to "10%", by using the below command:


We change the percentage to "1%".

We could also use "tune2fs" to label a filesystem u
sing the "-L" parameter.
Then we could use the label instead of the partition name "/dev/sdb1" for example with the "mount" command.

We could give our partition "/dev/sdb1" the label "my-partition" for example:


We
 could use that label in the "/etc/fstab" by mentioning "LABEL= my-partition" instead "/dev/sdb1".

This avoid confusing the system when adding a new hard drives, since the labels don't change when we add new drives as opposed to the  partition names which could change from "/dev/sdb" to "/dev/sdc" causing errors.

Comments

Leave as a comment:

Archive