5. Mounting Drives
5.1 Identify the Disk UUIDs
A command-line utility to locate/print block device attributes. The blkid
command prints information about available block devices, including their UUIDs, labels, and filesystem types.
blkid
Example Output
/dev/sda1: UUID="2E24-96A5" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="1d3a9e74-0c4d-4aee-8248-2d0a6f9b23b1"
/dev/sda2: UUID="1b09ae30-7e74-4d6c-88b6-e59f7d8b26a6" TYPE="ext4" PARTUUID="3e5dc77f-5f7d-4d6e-9c2f-1e4a99b5ed42"
/dev/sda3: UUID="a71e2e84-18f4-4c5f-8989-f7356f48a1a0" TYPE="swap" PARTUUID="c2b1b88d-3e49-45f2-a920-1c5b88e32b93"
/dev/sdb1: LABEL="disk1" UUID="e1a9b6d5-6d67-4c8c-9f21-0d8a2b58d1c2" TYPE="ext4" PARTUUID="be839f16-019e-4a83-9ff6-7f0a6c88c5b1"
Document the secondary partition UUID.
Explanation
of Example Output
/dev/sda1,
/dev/sda2, /dev/sda3, /dev/sdb1: Device names for partitions on the disks.
UUID: The Universally Unique Identifier for the filesystem on the partition. For
example, UUID="e1a9b6d5-6d67-4c8c-9f21-0d8a2b58d1c2" uniquely
identifies the filesystem on /dev/sdb1.
TYPE: The type of filesystem on the partition (e.g., ext4, vfat, swap).
LABEL: The label assigned to the filesystem, such as disk1 for /dev/sdb1.
PARTLABEL: The label for the partition, if any (e.g., EFI System Partition for /dev/sda1).
PARTUUID: The unique identifier for the partition itself, distinct from the filesystem
UUID.
5.2 Create Mount Points
Create directories where the disks will be mounted:
mkdir /disk1
mkdir /disk2
mkdir /disk3
mkdir /disk4
5.3 Backup and Edit /etc/fstab
5.3.1 Create a backup of the fstab file:
cp /etc/fstab /root/fstab.bak
Command Breakdown
cp: The command used to copy files or directories.
/etc/fstab: The source file, which is the filesystem table file that defines how disk partitions and other devices are mounted.
/root/fstab.bak: The destination file, a backup copy of the fstab file, stored in the /root directory with the name fstab.bak.
5.3.2 Edit the fstab file to include the new partitions:
sudo nano/etc/fstab
Add the following lines, replacing the UUIDs with the ones from your blkid output in the following format:
UUID=7bfe4cc6-c79a-434f-9028-7e03908466a9 /disk1 ext4 defaults 1 2
UUID=9e56b27c-de41-4a2a-be3d-9cc5b3da932d /disk2 ext4 defaults 1 2
UUID=some-uuid-for-disk3 /disk3 ext4 defaults 1 2
UUID=some-uuid-for-disk4 /disk4 ext4 defaults 1 2
Explanation of Fields
UUID: The universally unique identifier for the filesystem. This ensures that the correct filesystem is mounted even if the device name changes.
<mount point>: The directory where the filesystem will be mounted.
<type>: The type of filesystem, such as ext4, xfs, etc.
<options>: Mount options, such as defaults, noatime, nodiratime, etc.
<dump>: Controls the backup utility dump; 0 indicates no dump, and 1 indicates the filesystem should be dumped.
<pass>: Controls the order in which filesystems are checked at boot time by fsck. 0 means no check, 1 is the first filesystem to be checked, and 2 is for other filesystems
Save and exit the editor (i to insert, Esc to exit insert mode, :wq! to write and quit).
5.4 Mount All Drives
5.4.1 Mount the new filesystems:
mount -a
The mount -a command is particularly useful after making changes to /etc/fstab. It allows you to mount all the filesystems specified in the file without having to reboot the system.
5.4.2 Verify the mounts:
df -h
Example Output
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 476G 20G 432G 5% /
udev 7.9G 0 7.9G 0% /dev
tmpfs 1.6G 1.9M 1.6G 1% /run
tmpfs 7.9G 252M 7.7G 4% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/sdb1 1.8T 100M 1.7T 1% /disk1
/dev/sdc1 1.8T 100M 1.7T 1% /disk2
/dev/sdd1 1.8T 100M 1.7T 1% /disk3
/dev/sde1 1.8T 100M 1.7T 1% /disk4
Explanation of Output
Filesystem: The name of each mounted filesystem.
Size: The total size of each filesystem.
Used: The amount of space used on each filesystem.
Avail: The amount of space available on each filesystem.
Use%: The percentage of the filesystem that is used.
Mounted on: The directory where the filesystem is mounted.
Conclusion
Following these steps, you can successfully partition, format, and mount secondary drives in a Linux system using manual drive configuration (MDC). This ensures that the drives are correctly set up and accessible upon system startup. Always verify each step to avoid data loss and ensure system stability.