Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1
-c—Checks   for bad blocks  and then    marks   them    as  bad
-f—Forces checking on a clean file system
-v—Enters verbose mode

The badblocks Command


Although not a performance-tuning program per se, the utility badblocks
checks a partition (preferably unmounted) for bad blocks. It is not
recommended that you run this command by itself; rather, you should allow it
to be called by fsck. You should use it directly only if you specify the block
size accurately; don’t guess or assume anything.


The options available for badblocks are detailed in the man page. They
allow for very low-level manipulation of the file system that is useful for data
recovery by file system experts or for file system hacking, but they are
beyond the scope of this chapter and the average user.


Disabling File Access Time


Whenever Linux reads a file, it changes the last access time (known as the
atime). This is also true for your web server: If you are getting hit by 50
requests a second, your hard disk will be updating the atime 50 times a
second. Do you really need to know the last time a file was accessed? If not,
you can disable the atime setting for a directory by typing this:


Click here to view code image
matthew@seymour:~$ chattr –R +A /path/to/directory


The chattr command changes file system attributes, of which “don’t
update atime” is one. To set that attribute, use +A and specify -R so that it is
recursively set. /path/to /directory gets changed, and so do all the
files and subdirectories it contains.


Kernel


As the Linux kernel developed over time, developers sought a way to fine-
tune some of the kernel parameters. Before sysctl, those parameters had to
be changed in the kernel configuration, and then the kernel had to be
recompiled.


The sysctl command can change some parameters of a running kernel. It

Free download pdf