Mounting a disk in Linux
Kort antwoord
Partition the disk with parted, format it with mkfs.ext4, mount it to a new, empty folder, then add its UUID to /etc/fstab so it survives a reboot.
An additional disk attached to your server needs a partition, a filesystem, and a mount point before you can use it. This walks through all four steps: finding the disk, partitioning and formatting it, mounting it, and making that mount persistent.
Locate the disk
List block devices
Run lsblk to see all disks and identify the one without partitions, this is the disk you need to prepare:
lsblkCreate a partition and filesystem
Partition the disk
Open the disk in parted, replacing /dev/sdb with your disk's device name:
sudo parted /dev/sdbInside the parted prompt, create a GPT partition table and a single partition spanning the whole disk:
mklabel gpt
mkpart primary ext4 0% 100%
quitFormat the partition
sudo mkfs.ext4 /dev/sdb1Create a mount point and mount the disk
Create a folder to mount to
This example uses /home2, but any empty folder works. Make sure the folder doesn't already exist with files in it: mounting over an existing folder hides its contents and can make the system harder to work with until you unmount it again.
sudo mkdir /home2Mount the partition
sudo mount /dev/sdb1 /home2Confirm it's mounted:
lsblk
df -hMake the mount persistent
Find the partition's UUID
sudo blkidAdd an entry to /etc/fstab
Open /etc/fstab and add a line for the new partition, following the format of the existing entries, using the UUID from the previous step:
UUID=your-uuid-here /home2 ext4 defaults 0 2The disk now mounts automatically at boot. Test it without rebooting by unmounting and remounting via fstab:
sudo umount /home2
sudo mount -aIf a step doesn't go as expected, especially around partitioning, stop and contact support before continuing. Partitioning mistakes on the wrong disk can cause data loss.