Prepare a new drive via the command line

Drake Evans
1 min readOct 21, 2021

--

sudo lsblk

Format drive, in this case we are using ext4 format

mkfs [options] [-t type fs-options] device [size]
sudo mkfs -t ext4 /dev/sdb

Add GTP partition table

parted device options command command-options start end
sudo parted /dev/sdc --align optimal mklabel gpt 0 100%

Add partition

sudo parted /dev/sdc -a optimal mkpart primary 2048s 100%

format partition

mkfs -t type [-L Label] device
sudo mkfs -t ext4 -L TMDrive /dev/sdc1

Create a folder in /mnt/ to mount the drive to

sudo mkdir /mnt/TMDrive

Mount the drive

sudo mount -t ext4 -U a4812198-d5fa-4888-9c1d-4bd5ce1dcb63 /mnt/TMDrive

Add hard drives to auto mount

First list UUIDs

lsblk — fs

Take the UUID and add it to fstab, we use UUID in case we add or remove drives later

sudo nano /etc/fstab```

Contents to add for read write

UUID=f178f565–5438–4a38–834d-bdc3b8 /mnt/TMDrive ext4 rw,defaults 0 0

--

--

Drake Evans
Drake Evans

Written by Drake Evans

A smart man can rationalize anything; set rules and don't break them. Biomedical Engineering, Computer Science, Finance, Economics.

No responses yet