2018-01-25 08:29:31 -06:00
|
|
|
---
|
|
|
|
title: About the filesystem Resource
|
2018-02-15 18:28:15 -06:00
|
|
|
platform: linux
|
2018-01-25 08:29:31 -06:00
|
|
|
---
|
|
|
|
|
|
|
|
# filesystem
|
|
|
|
|
2018-02-07 05:27:48 -08:00
|
|
|
Use the `filesystem` InSpec resource to audit filesystem disk space usage.
|
|
|
|
|
2018-01-25 08:29:31 -06:00
|
|
|
<br>
|
|
|
|
|
2018-08-09 08:34:49 -04:00
|
|
|
## 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.
|
|
|
|
|
2018-01-25 08:29:31 -06:00
|
|
|
## Syntax
|
|
|
|
|
2018-03-20 21:43:30 +09:00
|
|
|
A `filesystem` resource block declares tests for disk space in a partition:
|
2018-01-25 08:29:31 -06:00
|
|
|
|
|
|
|
describe filesystem('/') do
|
|
|
|
its('size') { should be >= 32000 }
|
2019-01-29 15:23:05 -06:00
|
|
|
its('free') { should be >= 5000000 }
|
2019-01-31 17:18:39 -05:00
|
|
|
its('percent_free') { should be >= 20 }
|
2019-01-29 15:23:05 -06:00
|
|
|
its('type') { should cmp 'ext4' }
|
2018-01-25 08:29:31 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
where
|
|
|
|
|
2018-02-07 05:27:48 -08:00
|
|
|
* `filesystem('/')` states that the resource will look at the root (/) partition.
|
2019-01-29 15:23:05 -06:00
|
|
|
* `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).
|
2019-01-31 17:18:39 -05:00
|
|
|
* `percent_free` is the percentage of available free space, and ranges from 0 to 100.
|
2018-01-25 08:29:31 -06:00
|
|
|
|
|
|
|
<br>
|
|
|
|
|
2018-02-07 05:27:48 -08:00
|
|
|
## Resource Property Examples
|
2018-01-25 08:29:31 -06:00
|
|
|
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
|
2018-05-03 18:46:07 +05:30
|
|
|
### Test if the root partition is greater than 32000 KB
|
2018-01-25 08:29:31 -06:00
|
|
|
|
|
|
|
describe filesystem('/') do
|
|
|
|
its('size') { should be >= 32000 }
|
|
|
|
end
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
2019-01-29 15:23:05 -06:00
|
|
|
### 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>
|
|
|
|
|
2019-01-31 17:18:39 -05:00
|
|
|
### Test if the /var partition has sufficient free space
|
|
|
|
|
|
|
|
describe filesystem('/var') do
|
|
|
|
its('percent_free') { should be >= 20 }
|
|
|
|
end
|
|
|
|
|
2018-01-25 08:29:31 -06:00
|
|
|
## Matchers
|
|
|
|
|
2018-02-15 19:07:18 -08:00
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|