Why I can see lot more free disk space as root than as a user?

2

When I am logged in as a user, I can see free disk space: 1.2 Gb, with Midnight Commander. Surprisingly when I run "sudo mc" then Midnight Commander shows a lot more free disk space: 1.9 Gb. How is it possible? Should I run fsck on next boot, or do I have a rootkit?

Konstantin

Posted 2019-03-06T04:04:11.047

Reputation: 515

Answers

3

Some filesystems can reserve some disk space for administrators (so that admins have wiggle room in case filesystem gets “full”). By default for ext2/ext3/ext4 filesystems, 5% are reserved.

When running as root, Midnight Commander reports the disk space including the reserved disk space.

Decision to show one value or the other is made in this line of code: https://repo.or.cz/midnight-commander.git/blob/HEAD:/src/filemanager/mountlist.c#l1516

If you want to know more about this topic, info about the filesystem statistics is available in the statvfs(3) man page.

The percentage of reserved disk space for administrators on ext2/ext3/ext4 can be adjusted using tune2fs.

Patrice Levesque

Posted 2019-03-06T04:04:11.047

Reputation: 780

Thx, I also had to run fsck, because after running it I got immediately 1.7 GB free space as a regular user and 2.5 Gb free space as root. – Konstantin – 2019-03-06T05:45:38.423