partedmkfs.xfsblkidmount -amkswapswapon| Term | Meaning |
|---|---|
| Disk / block device | The raw physical (or virtual) storage device, e.g. /dev/sdb |
| Partition | A defined section of a disk, e.g. /dev/sdb1 |
| Filesystem | The structure that organizes files and directories on a partition |
| Mount point | The directory a filesystem is attached to and accessed through |
# Confirm the device you're about to partition (always double-check!) lsblk # Open parted interactively on a specific disk sudo parted /dev/sdb # Inside parted: create a GPT partition table (required before adding partitions) (parted) mklabel gpt # Create a primary partition spanning most of the disk (parted) mkpart primary 0% 100% # Show the current partition layout (parted) print # Exit parted (parted) quit
# Or, non-interactively in a single command line sudo parted /dev/sdb --script mklabel gpt mkpart primary 0% 100% # Confirm the kernel sees the new partition lsblk /dev/sdb
lsblk first.# Create an XFS filesystem (RHEL's default) on the new partition sudo mkfs.xfs /dev/sdb1 # Or ext4, if that's what you need sudo mkfs.ext4 /dev/sdb1 # Confirm the filesystem type and get its UUID blkid /dev/sdb1
| Filesystem | Notes |
|---|---|
| XFS | RHEL's default; scales well to very large filesystems, but cannot be shrunk |
| ext4 | Mature and widely compatible; supports both growing and shrinking |
A manual mount doesn't survive a reboot. Permanent mounts go in /etc/fstab.
# /etc/fstab fields: # device mount-point fs-type options dump pass UUID=1a2b3c4d-... /data xfs defaults 0 2
# Get the UUID to use in fstab (preferred over a raw device name, # which can shift if disks are added/removed) blkid /dev/sdb1 # Create the mount point sudo mkdir -p /data # After editing /etc/fstab, test it WITHOUT rebooting sudo mount -a # Confirm it mounted as expected df -h /data
sudo systemctl daemon-reload after editing fstab.# Format a partition as swap sudo mkswap /dev/sdb2 # Enable it immediately sudo swapon /dev/sdb2 # Confirm it's active swapon --show free -h
# Make it persistent by adding to /etc/fstab
UUID=5e6f7a8b-... none swap defaults 0 0
fallocate or dd, format it with mkswap. It's easier to resize than a partition.# Disk space usage across mounted filesystems df -h # Check and repair a filesystem (UNMOUNTED only) sudo umount /data sudo fsck /dev/sdb1 sudo mount /data
fsck does nothing. Use xfs_repair on the unmounted device instead.mkfs.xfslsblk before running parted?/dev/sdb1 in /etc/fstab?/etc/fstab entry without rebooting?/dev/sdc1 as swap and activate it immediately?fsck?