Linux available disk capacity adjustment reserved space

  

When we use df to view disk information, we will generally find the disk size "display abnormal", the sum of the used space and free space of the disk is smaller than the total disk space . Where is this part of the lost capacity?

1. Reserved space

Reserved space refers to a certain amount of disk space reserved by Linux hard disk partitioning program for root or specified users. The default is 5%, which causes us to use When df goes to view the disk information, the size of the disk is "exception", the total space of the disk is not equal to the sum of the used space and the available space.

1.1.

[root@RhelTEST2 ~]# df -hlFilesystem Size Used Avail Use% Mounted on/dev/sda2 18G 6.9G 9.7G 42% /tmpfs 935M 72K 935M 1% /Dev/shm/dev/sda1 291M 39M 238M 14% /boot

Use df –hl to see the disk usage space example. You can see that the current total size of the /dev/sda2 partition is 18G, and the available space size is The sum of the used space is 16.6G with a difference of 1.4G.

1.2. Reserved space


[root@RhelTEST2 ~]# tune2fs -l /dev/sda2 |  Grep -i blockBlock count: 4641536Reserved block count: 232076Free blocks: 2762496First block: 0Block size: 4096Reserved GDT blocks: 1022Blocks per group: 32768Inode blocks per group: 511Flex block group size: 16Reserved blocks uid: 0 (user root)Reserved blocks gid: 0 (group root) Journal backup: inode blocks

ext file system, including ext2, ext3, ext4 will reserve 5% disk space by default, reserved for the root user to maintain the system or record the system key log (For example, if the disk usage space is already 100%), this is why the 1.4G space is not available.

The command of tune2fs –l can clearly see that the partition is configured with 232076 blocks as reserved space, which is exactly 5% of the total size. It is necessary to set a reserved space in the root partition or an important data partition to ensure that the system does not crash when the disk space is full. However, for general data partitioning, the configuration of reserved space seems to be a waste of resources.

1.3. Adjusting reserved space


[root@RhelTEST2 ~]# df -hlFilesystem Size Used Avail Use% Mounted on/dev/sda2 18G 6.9G 11G 40% /tmpfs 935M 72K 935M 1% /dev/shm/dev/sda1 291M 39M 238M 14% /boot

[root@RhelTEST2 ~]# tune2fs -m 1 /dev/sda2tune2fs 1.41.12 (17-May -2010)Setting reserved blocks percentage to 1% (46415 blocks)

Tune2fs –m can adjust the size of the reserved space by percentage. After running this command, you can see the reduced share in the reserved space. Immediately released. We can also set the fixed size as a reserved space by tune2fs –r.

[root@RhelTEST2 ~]# tune2fs -r 1000 /dev/sda2tune2fs 1.41.12 (17-May-2010)Setting reserved blocks count to 1000

Copyright © Windows knowledge All Rights Reserved