434 words
2 minutes
CIS Benchmark-Aligned Partitioning Scheme for Rocky Linux 9.5

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)#

PartitionSizeFilesystemMount OptionsPurpose
/boot1024 MiBext4nodev, noexec, nosuidBootloader partition
/home100 GiBxfsnodevUser data storage
/var40 GiBxfsnodevApp & system logs
/var/log60 GiBxfsnodevSystem logs
/var/log/audit15 GiBxfsnodevSecurity audit logs
/var/tmp20 GiBxfsnodev, noexec, nosuidTemporary storage
/tmp20 GiBxfsnodev, noexec, nosuidPrevent script execution in /tmp
/srv30 GiBxfsnodevApplication data
/opt30 GiBxfsnodevThird-party software
/swap16 GiBswapN/AVirtual memory swap
/ (root)88 GiBxfsDefaultMain OS partition

Total Used: 400 GiB βœ…


πŸ”§ Filesystem Choices#

FilesystemReason
XFS (for most partitions)Best for high-performance and large storage
EXT4 (for /boot)Needed for compatibility with bootloaders
SwapVirtual memory

πŸ“Œ Security-Hardened /etc/fstab Configuration#

UUID=<boot-uuid> /boot ext4 defaults,nodev,noexec,nosuid 1 2
UUID=<home-uuid> /home xfs defaults,nodev 0 2
UUID=<var-uuid> /var xfs defaults,nodev 0 2
UUID=<log-uuid> /var/log xfs defaults,nodev 0 2
UUID=<audit-uuid> /var/log/audit xfs defaults,nodev 0 2
UUID=<tmp-uuid> /tmp xfs defaults,nodev,noexec,nosuid 0 2
UUID=<vtmp-uuid> /var/tmp xfs defaults,nodev,noexec,nosuid 0 2
UUID=<srv-uuid> /srv xfs defaults,nodev 0 2
UUID=<opt-uuid> /opt xfs defaults,nodev 0 2
UUID=<root-uuid> / xfs defaults 0 1
UUID=<swap-uuid> swap swap defaults 0 0

πŸ“ Replace <UUID> with actual disk UUIDs using blkid command


πŸ›  Steps to Configure During Installation#

  1. Manual Partitioning: Choose β€œCustom Partitioning” in Rocky Linux installer.
  2. Format the Partitions:
    • Set /boot as ext4.
    • Set all other partitions as XFS.
    • Set swap as swap.
  3. Assign Mount Points as per the table.
  4. Apply Mount Options:
    • Click on Modify Mount Options β†’ Set nodev, noexec, nosuid as needed.
  5. 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:

---
- name: Configure CIS-compliant partitioning
hosts: rocky_servers
become: true
tasks:
- name: Install required packages
dnf:
name:
- parted
- lvm2
state: present
- name: Configure partitions
block:
- name: Create partitions
# Commands to create partitions
# This would typically involve parted commands
- name: Format partitions
# Format each partition with the correct filesystem
- name: Update fstab
# Add entries to /etc/fstab
- name: Set correct permissions
file:
path: "{{ item }}"
mode: "1777"
with_items:
- /tmp
- /var/tmp

For 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.

CIS Benchmark-Aligned Partitioning Scheme for Rocky Linux 9.5
https://mranv.pages.dev/posts/cis-benchmark-rocky-linux-partitioning-scheme/
Author
Anubhav Gain
Published at
2024-04-24
License
CC BY-NC-SA 4.0