Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
CIS Benchmark-Aligned Partitioning Scheme for Rocky Linux 9.5#
To align your Rocky Linux 9.5 installation with CIS Benchmark recommendations and fully utilize 400 GiB of storage, follow this partitioning scheme and filesystem recommendations.
📌 Partitioning Plan (CIS Benchmark Aligned)#
| Partition | Size | Filesystem | Mount Options | Purpose |
|---|---|---|---|---|
/boot | 1024 MiB | ext4 | nodev, noexec, nosuid | Bootloader partition |
/home | 100 GiB | xfs | nodev | User data storage |
/var | 40 GiB | xfs | nodev | App & system logs |
/var/log | 60 GiB | xfs | nodev | System logs |
/var/log/audit | 15 GiB | xfs | nodev | Security audit logs |
/var/tmp | 20 GiB | xfs | nodev, noexec, nosuid | Temporary storage |
/tmp | 20 GiB | xfs | nodev, noexec, nosuid | Prevent script execution in /tmp |
/srv | 30 GiB | xfs | nodev | Application data |
/opt | 30 GiB | xfs | nodev | Third-party software |
/swap | 16 GiB | swap | N/A | Virtual memory swap |
/ (root) | 88 GiB | xfs | Default | Main OS partition |
Total Used: 400 GiB ✅
🔧 Filesystem Choices#
| Filesystem | Reason |
|---|---|
| XFS (for most partitions) | Best for high-performance and large storage |
EXT4 (for /boot) | Needed for compatibility with bootloaders |
| Swap | Virtual memory |
📌 Security-Hardened /etc/fstab Configuration#
1UUID=<boot-uuid> /boot ext4 defaults,nodev,noexec,nosuid 1 22UUID=<home-uuid> /home xfs defaults,nodev 0 23UUID=<var-uuid> /var xfs defaults,nodev 0 24UUID=<log-uuid> /var/log xfs defaults,nodev 0 25UUID=<audit-uuid> /var/log/audit xfs defaults,nodev 0 26UUID=<tmp-uuid> /tmp xfs defaults,nodev,noexec,nosuid 0 27UUID=<vtmp-uuid> /var/tmp xfs defaults,nodev,noexec,nosuid 0 28UUID=<srv-uuid> /srv xfs defaults,nodev 0 29UUID=<opt-uuid> /opt xfs defaults,nodev 0 210UUID=<root-uuid> / xfs defaults 0 111UUID=<swap-uuid> swap swap defaults 0 0📝 Replace
<UUID>with actual disk UUIDs usingblkidcommand
🛠 Steps to Configure During Installation#
- Manual Partitioning: Choose “Custom Partitioning” in Rocky Linux installer.
- Format the Partitions:
- Set
/bootas ext4. - Set all other partitions as XFS.
- Set swap as swap.
- Set
- Assign Mount Points as per the table.
- Apply Mount Options:
- Click on Modify Mount Options → Set
nodev, noexec, nosuidas needed.
- Click on Modify Mount Options → Set
- Confirm Total Usage is ~400 GiB and proceed with installation.
🔍 Additional Hardening#
✔ Enable Automatic fsck (Filesystem Check) on Boot
✔ Ensure SELinux is Enforcing (getenforce should return Enforcing)
✔ Set correct file permissions (chmod 1777 /tmp /var/tmp)
🔥 Final Thoughts#
- ✅ This layout follows CIS Benchmark best practices.
- ✅ Provides security, prevents attacks on
/tmp, and separates logs. - ✅ Optimized for server use (Rocky Linux, CentOS, RHEL-based).
- ✅ Will scale well for both production and development workloads.
Automation with Ansible#
This partitioning scheme can be automated using Ansible for consistent deployments across multiple servers. A basic playbook structure would include:
1---2- name: Configure CIS-compliant partitioning3 hosts: rocky_servers4 become: true5 tasks:6 - name: Install required packages7 dnf:8 name:9 - parted10 - lvm211 state: present12
13 - name: Configure partitions14 block:15 - name: Create partitions16 # Commands to create partitions17 # This would typically involve parted commands18
19 - name: Format partitions20 # Format each partition with the correct filesystem21
22 - name: Update fstab23 # Add entries to /etc/fstab24
25 - name: Set correct permissions26 file:27 path: "{{ item }}"28 mode: "1777"29 with_items:30 - /tmp31 - /var/tmpFor production use, a more detailed playbook with proper error handling and idempotence checks would be necessary.
By following this partitioning scheme and security recommendations, you’ll have a solid foundation for a secure Rocky Linux 9.5 server that aligns with CIS Benchmark standards.