mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
fef637a6c6
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
78 lines
1.7 KiB
Text
78 lines
1.7 KiB
Text
---
|
|
title: About the filesystem Resource
|
|
platform: linux
|
|
---
|
|
|
|
# filesystem
|
|
|
|
Use the `filesystem` InSpec resource to audit filesystem disk space usage.
|
|
|
|
<br>
|
|
|
|
## Availability
|
|
|
|
### Installation
|
|
|
|
This resource is distributed along with InSpec itself. You can use it automatically.
|
|
|
|
### Version
|
|
|
|
This resource first became available in v1.51.0 of InSpec.
|
|
|
|
## Syntax
|
|
|
|
A `filesystem` resource block declares tests for disk space in a partition:
|
|
|
|
describe filesystem('/') do
|
|
its('size') { should be >= 32000 }
|
|
its('free') { should be >= 5000000 }
|
|
its('percent_free') { should be >= 20 }
|
|
its('type') { should cmp 'ext4' }
|
|
end
|
|
|
|
where
|
|
|
|
* `filesystem('/')` states that the resource will look at the root (/) partition.
|
|
* `size` is the total partition size and is measured in kilobytes (KB).
|
|
* `free` is the available space on the partition and is measured in kilobytes (KB).
|
|
* `percent_free` is the percentage of available free space, and ranges from 0 to 100.
|
|
|
|
<br>
|
|
|
|
## Resource Property Examples
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
### Test if the root partition is greater than 32000 KB
|
|
|
|
describe filesystem('/') do
|
|
its('size') { should be >= 32000 }
|
|
end
|
|
|
|
<br>
|
|
|
|
### Test that the root partition has more than 5GB free
|
|
|
|
describe filesystem('/') do
|
|
its('free') { should be >= 5000000 }
|
|
end
|
|
|
|
<br>
|
|
|
|
### Test if the C:\ partition is NTFS
|
|
|
|
describe filesystem('c:\') do
|
|
its('type') { should cmp 'NTFS' }
|
|
end
|
|
|
|
<br>
|
|
|
|
### Test if the /var partition has sufficient free space
|
|
|
|
describe filesystem('/var') do
|
|
its('percent_free') { should be >= 20 }
|
|
end
|
|
|
|
## Matchers
|
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|