Managing Disk Partitions and Mount Points in CentOS 7

Symbolic links provide a way to reference a source directory from a different location. To create a soft link, ensure the target link name does not already exist within the parent directory. Navigate to the parent directory (e.g., /home) and execute the link command.

# Syntax: ln -s /path/to/source /path/to/link
ln -s /data/source_directory /home/user_link

To verify the link, list the contents of the directory. You should see the link pointing to the source. To remove the link, it is safer to use unlink or rm on the link name itself. Avoid using rm -rf on a symbolic link to prevent unintended data loss in the source directory.

unlink user_link
# Alternatively
rm user_link

Identifying and Partitioning New Disks

Before using a new hard drive, you must verify its existence and create a partition table. Use the fdisk utility to list all connected block devices.

fdisk -l

To partition a specific device, such as /dev/sdb, run the interactive tool:

fdisk /dev/sdb

Within the interactive menu, the following commands are frequently used:

  • n: Create a new partition.
  • p: Print the partition table.
  • d: Delete a partition.
  • w: Write changes to the disk and exit.
  • q: Quit without saving changes.

To create a new primary parttition, follow these inputs sequentially: type n (new), then p (primary), then 1 (partition number). Press Enter twice to accept the default first and last sectors, then type wq to write the changes and quit.

Formatting and Mounting the Filesystem

Once the partition is created (e.g., /dev/sdb1), it must be formatted with a filesystem. The following command formats the partition using the ext4 filesystem.

mkfs.ext4 /dev/sdb1

Create a directory to serve as the mount point.

mkdir /mnt/data_drive

Mount the newly formatted partition to the directory.

mount /dev/sdb1 /mnt/data_drive

The general syntax for the mount command allows specifying the filesystem type and options:

mount -t <filesystem_type> -o <options> <device> <mount_point>

To detach the filesystem, use the umount command specifying the device or the mount point.

umount /dev/sdb1

Configuring Persistent Mounts

Mounts created via the command line are temporary and will be lost after a reboot. To mount a disk automatically during system boot, edit the /etc/fstab configuration file.

vi /etc/fstab

Add a new line following the structure: <device> <mount_point> <fs_type> <options> <dump> <pass>.

/dev/sdb1 /mnt/data_drive ext4 defaults 0 0

For more robust configuration, its recommended to use the filesystem UUID instead of the device path. Retrieve the UUID using the blkid command.

blkid
# Output example:
# /dev/sdb1: UUID="a1b2-c3d4" TYPE="ext4"

After modifying the fstab file, you can apply the changes immediately or restart the server.

shutdown -r now

Tags: centos Linux System Administration Disk Management fdisk Mount

Posted on Wed, 28 Oct 2026 16:29:57 +0000 by tomms