When provisioning additional storage volumes for GlusterFS and Kubernetes worker VMs, interactive fdisk prompts slow down automation. Using GNU parted in script mode (-s), you can initialize a partition table and allocate 100% of the disk in a single command:
sudo parted -s /dev/sdb mklabel msdos mkpart primary 0% 100%Note: Replace /dev/sdb with your target block device. Running parted -s executes non-interactively with zero confirmation prompts.
Formatting with ext4 and Persistent /etc/fstab Mounting
After using this single line to use 100% of the new volume in parted, we want to make a quick ext4 format:
sudo mkfs.ext4 /dev/sdb1After this is completed you are good to mount the partition of our new disk.
To make the mount resilient to device-name shifts across reboots, assign a filesystem label with e2label, create the mount point, and register `LABEL=glusterfs` in /etc/fstab:
sudo e2label /dev/sdb1 glusterfs
sudo mkdir /glusterfs
sudo echo 'LABEL=glusterfs /glusterfs ext4 defaults 0 0' >> /etc/fstabThese four commands can be dropped directly into Ansible playbooks, Cloud-Init user-data, or shell scripts to provision new Linux disks unattended. View the complete script on GitLab: script_on_git
Using
parted -s -a optimal /dev/sdb mklabel gpt -- mkpart primary ext4 1MiB -1sin a single non-interactive command is a lifesaver for Ansible disk provisioning playbooks.That 1MiB starting sector alignment (
1MiB -1s) is so important on modern 4Kn enterprise SSDs and hardware RAID LUNs—prevents the classic parted alignment warning every time.