Partition a new disk on linux using fdisk, lsblk and mkfs
First, you’ve to create a new partition.
You can list all available storage device with:
If your disk is new, the new device will appear empty (without children on the tree).
Then:
Press m to show the manual.
To create a partition larger than 2TB, you’ve to use a GPT partition (g) then create a new extended partition (n) then with (p) it will show you how the partition will like before you write (w) them.
Then, lsblk will show the device with the new partition, e.g.:
sdc 8:32 0 5T 0 disk └─sdc1 8:33 0 5T 0 part
Then format the new partition /dev/sdc1 with the specified filesystem (e.g. ext4):
If you haven’t take not of the UUID shown by mkfs after format, use blkid command to list the UUID of the device, so if device name change the fstab is still valid.
And add to /etc/fstab (put the last 0 to 1 to check filesystem on startup):
UUID=xxxxxxx-xxx-xxxx-xxx-xxxx /mnt/mydata ext4 defaults 0 0
To get the UUID later:
Create the mount directory with:
Then mount the new partition with: