💾 Archived View for chirale.org › 2019-02-02_4937.gmi captured on 2024-08-18 at 17:31:57. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

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:

lsblk

If your disk is new, the new device will appear empty (without children on the tree).

Then:

fdisk /dev/sdc

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):

mkfs -t ext4 /dev/sdc1

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:

sudo blkid /dev/sdc1

Create the mount directory with:

mkdir /mnt/mydata

Then mount the new partition with:

mount /mnt/mydata