gortc.disk
Disk
This role lets you format extra disks and connect them to different locations.
You can use it to move data from various services to another disk.
Configuration
Inventory
You need to store the configuration for additional disks using YAML syntax in a group_vars
directory.
# inventory/group_vars/GROUP_NAME
disk_additional_disks:
- disk: /dev/sdb
fstype: ext4
mount_options: defaults
mount: /data
user: www-data
group: www-data
disable_periodic_fsck: false
- disk: /dev/nvme0n1
part: /dev/nvme0n1p1
fstype: xfs
mount_options: defaults,noatime
mount: /data2
disk
is the device you want to mount.part
is the name of the first partition. If you don't specify it,1
is added to the disk name.fstype
lets you choose the type of filesystem for the new disk.mount_options
allows you to set custom options for mounting.mount
is the directory where the new disk will be attached.user
sets who owns the mount directory (default isroot
).group
sets the group for the mount directory (default isroot
).disable_periodic_fsck
turns off the regular filesystem check for the new disk.
You can also add:
disk_package_use
specifies the package manager to use (yum, apt, etc.). The default 'auto' will automatically detect it.
Supported Filesystems:
*) Note: To use these filesystems, you need to install additional software packages. Make sure to find the correct package names for your operating system.
# inventory/group_vars/GROUP_NAME
additional_fs_utils:
- xfsprogs # package for mkfs.xfs on RedHat / Ubuntu
- btrfs-progs # package for mkfs.btrfs on CentOS / Debian
How it works
The process uses sfdisk
to create a primary partition that covers the whole disk. Then, it creates the specified filesystem using mkfs
. Finally, it mounts the new partition to the designated path.