Pages

Thursday, February 28, 2019

What is atime and noatime in fstab

Linux has a special mount option for file systems called noatime that can be added to each line that addresses one file system in the /etc/fstab file. If a file system has been mounted with this option, reading accesses to the file system will no longer result in an update to the atime information associated with the file like we have explained above. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to. In our example below, we will set the noatime option to our /chroot file system.


Edit the fstab file vi /etc/fstab and add in the line that refer to /chrootfile system the noatime option after the defaults option as show below:

            /dev/sda7          /chroot          ext2          defaults,noatime          1  2
           

You need not reboot your system for the change to take effect, just make the Linux system aware about the modification you have made to the /etc/fstab file. This can be accomplished with the following commands:

           [root@deep] /#mount -oremount /chroot/
           

Then test your results with the flowing command:

           [root@deep]# cat /proc/mounts
           

 /dev/root / ext2 rw 0 0 /proc /proc proc rw 0 0 /dev/sda1 /boot ext2 rw 0 0 /dev/sda8 /cache ext2 rw 0 0 /dev/sda7 /chroot ext2 rw,noatime 0 0 /dev/sda6 /home ext2 rw 0 0 /dev/sda11 /tmp ext2 rw 0 0 /dev/sda5 /usr ext2 rw 0 0 /dev/sda9 /var ext2 rw 0 0 none /dev/pts devpts rw 0 0


If you see something like: /dev/sda7 /chroot ext2 rw,noatime 0 0

Monday, February 18, 2019

SED Options

Example HTML page
We know sed command is used for file processing.

To Match Digit

sed -r 's/([^0-9]*([0-9]*)){2}.*/\2/' file

This extracts the second number:


sed -r 's/([^0-9]*([0-9]*)){1}.*/\2/' file

sed 's/[[:digit:]]\+\.//g'

$ echo "This is an example: 65 apples" | sed -r  's/^[^0-9]*([0-9]+).*/\1/'

65

59

Two problems:

sed does not support \d. Use [0-9] or [[:digit:]].


+ must be backslashed to get the special meaning: \+.

sed -r 's/.*_([0-9]*)\..*/\1/g'