Every couple of years, I find myself adding a new drive and inevitably have to search for the installation process each time. To streamline this, I’m compiling all the necessary information here.
Identify your disk with lsblk
and unmount it. Now we can delete any previous partition and create
a new partition with fdisk
, e.g., sudo fdisk /dev/nvme0n1
. d
to delete a partition, n
to
create a new one, and w
to write.
Once you have created the partition you need to “format it”, by creating a file system,
sudo mkfs.ext4 /dev/nvme0n1p1
.
If you forget to create a file system and try to mount the drive you’ll get the following error:
mount: /media/m2_4tb: wrong fs type, bad option, bad superblock on /dev/nvme0n1p1, missing codepage or helper program, or other error
.
Now we can permanently mount a drive by sudo nvim /etc/fstab
and adding the following line,
# mount 4TB m2 to /media/m2_4tb
UUID=edb3ba8f-11fe-4260-8846-0d991e31ac79 /media/m2_4tb ext4 defaults 0 2