Reserved blocks are disk blocks reserved by the kernel for processes owned by privileged users to prevent operating system from a crash due to unavailability of storage space for critical processes. For example, just imagine the size of root file system is 14 GB and the root file system is 100% full, all the non privileged user processes would not be able to write data to the root file system whereas processes which are owned by privileged user (root by default) would still be able to write the data to the file system. With the help of reserved blocks, operating system keeps running for hours or sometimes days even though root file system is 100% full.
The default percentage of reserved block is 5 % of the total size of file system and can be increased or decreased based upon the requirement. However, it is not recommended to reduce the percentage of reserved block less than 5 %. Reserved blocks are supported on ext2 and ext3 file system(s).
How to check how many blocks are reserved :
To check the number of blocks reserved on a file system, execute the following command.
[root@VCSNode2 ~]# dumpe2fs -h /dev/VolGroup00/LogVol00 | grep -i blockdumpe2fs 1.39 (29-May-2006)Block count: 3637248Reserved block count: 181862Free blocks: 2709898First block: 0Block size: 4096Reserved GDT blocks: 887Blocks per group: 32768Inode blocks per group: 1024Reserved blocks uid: 0 (user root)Reserved blocks gid: 0 (group root)Journal backup: inode blocks[root@VCSNode2 ~]#
To find the value for reserved block percentage, compare "Block Count" and "Reserved Block Count" values. In above example, Block Count (Total Blocks) = 3637248 and Reserved Block Count = 181862 so the reserved block percentage option is set to 181862/3637248*100 i.e. 5 % (default value).
How to change/configure reserve block percentage value :
The value for Reserved Block Percentage can be set at the time of creating the file system as well as after creating the file system. To set the value at the time of creating file system, pass -m option followed by desired value (in percentage) for reserved blocks to the mkfs command.
To set the reserved block percentage value after creating file system, use the following command.
[root@VCSNode2 ~]# tune2fs -m 3 /dev/VolGroup00/LogVol00tune2fs 1.39 (29-May-2006)Setting reserved blocks percentage to 3% (109117 blocks)[root@VCSNode2 ~]#
Above command would set the reserved block percentage value to 3 % of total block count.
Just in case if you do not want to provide percentage and would like to set exact reserved blocks, you can also accomplish that with the help of below command
[root@VCSNode2 ~]# tune2fs -r 109117 /dev/VolGroup00/LogVol00tune2fs 1.39 (29-May-2006)Setting reserved blocks count to 109117[root@VCSNode2 ~]#
Which user can access reserved blocks:
By default, only root user is allowed to access reserved blocks, but this can be changed. To allow any other user or group to access reserved blocks, execute the following commands.
[root@VCSNode2 ~]# tune2fs -u oracle /dev/VolGroup00/LogVol00tune2fs 1.39 (29-May-2006)Setting reserved blocks uid to 500[root@VCSNode2 ~]#[root@VCSNode2 ~]# tune2fs -g dba /dev/VolGroup00/LogVol00tune2fs 1.39 (29-May-2006)Setting reserved blocks gid to 500[root@VCSNode2 ~]#
To check which user/group is allowed to access reserved blocks, execute the following command.
[root@VCSNode2 ~]# dumpe2fs -h /dev/VolGroup00/LogVol00 | grep -i reserveddumpe2fs 1.39 (29-May-2006)Reserved block count: 109117Reserved GDT blocks: 887Reserved blocks uid: 500 (user oracle) // oracle user is allowed to access reserved blocksReserved blocks gid: 500 (group dba) // dba group is allowed to access reserved blocks[root@VCSNode2 ~]#
If the available storage is limited, it is always a good idea to set this option specifically for Oracle/Mysql Database Servers where there is a risk of operating system/database being crashed due to file system full. This option give some extra time to system administrator/database administrator to fix space issues and prevents Operating System/Database from crash.
Note : It is never recommended to reduce reserved block percentage or changes in reserved block uid/gid on root file system.
Cheers !!
Vaibhav
awesome post
ReplyDelete