Inspect quota setup with quotacheck
In this step, you will use the quotacheck
command. The quotacheck
command is used to scan a filesystem for disk usage and create, check, and repair quota files. It's a crucial step when setting up or verifying quotas.
Before running quotacheck
, it's important to understand that it needs to scan the filesystem. For accurate results, the filesystem should ideally be unmounted or mounted read-only. However, in a live system, this is often not feasible for the root filesystem (/
). quotacheck
can often run on a mounted filesystem, but it might issue warnings.
Since we are working in a LabEx environment and cannot easily unmount the root filesystem, we will run quotacheck
on the mounted filesystem.
The basic syntax for quotacheck
is quotacheck [options] filesystem
. We will use the following options:
-c
: Create new quota files (aquota.user
and aquota.group
).
-u
: Check user quotas.
-g
: Check group quotas.
-v
: Verbose output, showing what the command is doing.
-M
: Don't try to remount the filesystem read-only.
We need to run quotacheck
with sudo
because it requires root privileges to scan the filesystem and create/modify quota files.
Type the following command in your terminal and press Enter:
sudo quotacheck -cugvM /
You will see output indicating that quotacheck
is scanning the filesystem. The exact output may vary depending on the system state, but it will look something like this:
quotacheck: Scanning /dev/sda1 [/] done
quotacheck: Checked 10 directories and 100 files
This command scans the root filesystem (/
), checks for user (-u
) and group (-g
) disk usage, creates new quota files (-c
) if they don't exist, provides verbose output (-v
), and avoids trying to remount the filesystem read-only (-M
).
After running quotacheck
, if the filesystem is configured for quotas in /etc/fstab
and the quota package is installed, it would typically create or update the quota files (aquota.user
and aquota.group
) at the root of the filesystem (e.g., /aquota.user
, /aquota.group
).
You can check for the existence of these files using the ls
command:
ls -l /aquota.*
If quota files were created, you might see output like this (again, this depends on the system configuration and if quotas are truly active):
-rw------- 1 root root 6144 Feb 13 10:00 /aquota.group
-rw------- 1 root root 7168 Feb 13 10:00 /aquota.user
In our current LabEx environment, since quotas are not fully configured, these files might not be created or might show zero size. The key takeaway is understanding that quotacheck
is the tool used to generate and maintain the data in these quota files based on the actual disk usage.
This step concludes our exploration of checking quota status and configuration files. You've learned how to use quota
to see current usage, cat /etc/fstab
to check for quota mount options, and quotacheck
to scan the filesystem and manage quota data files.
Click Continue to finish the lab.