User Tools

Site Tools


wiki:linux:basics:format_new_drive_linux

How To Format a New Drive on Linux

1. Open a terminal.

2. Use the fdisk tool to find your disk:

sudo fdisk -l

3. Search the output for the disk path that maps to your new drive. It should read something like /dev/sda for SATA disks or /dev/nvmen0p0 for NVMe disks. Replace /dev/sda in the remaining commands with the path for your disk.

4. Create a filesystem on the new disk (e.g. for ext4):

sudo mkfs.ext4 /dev/sda

5. Create a new directory to mount your disk to; replace “new_disk” with whatever name you want:

sudo mkdir /mnt/new_disk

6. Mount the disk to your new mount point:

sudo mount -t ext4 /dev/sda /mnt/new_disk

7. Grant your user ownership of the new disk:

sudo chown my_user: /mnt/new_disk; sudo chmod 755 /mnt/new_disk

8. Use blkid to find your disk's UUID:

sudo blkid

Search the output for the line that maps to your disk's path.

9. Open /etc/fstab in your favorite text editor with root privileges, e.g. vim:

sudo vim /etc/fstab

10. Add the following line to the end of the file (this will make sure your disk mounts at boot):

UUID=whatever-blkid-gave-me /mnt/new_disk ext4 defaults 0 0

11. You're done!

wiki/linux/basics/format_new_drive_linux.txt · Last modified: 2025/01/07 13:09 by Greg