Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:linux:basics:format_new_drive_linux [2025/01/07 12:50] – removed - external edit (Unknown date) 127.0.0.1wiki:linux:basics:format_new_drive_linux [2025/01/07 13:09] (current) – Re-formatted code blocks Greg
Line 1: Line 1:
 +====== How To Format a New Drive on Linux ======
  
 +1. Open a terminal.
 +
 +2. Use the ''fdisk'' tool to find your disk:
 +
 +<code>sudo fdisk -l</code>
 +
 +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):
 +
 +<code>sudo mkfs.ext4 /dev/sda</code>
 +
 +5. Create a new directory to mount your disk to; replace "new_disk" with whatever name you want:
 +
 +<code>sudo mkdir /mnt/new_disk</code>
 +
 +6. Mount the disk to your new mount point:
 +
 +<code>sudo mount -t ext4 /dev/sda /mnt/new_disk</code>
 +
 +7. Grant your user ownership of the new disk:
 +
 +<code>sudo chown my_user: /mnt/new_disk; sudo chmod 755 /mnt/new_disk</code>
 +
 +8. Use ''blkid'' to find your disk's UUID:
 +
 +<code>sudo blkid</code>
 +
 +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:
 +
 +<code>sudo vim /etc/fstab</code>
 +
 +10. Add the following line to the end of the file (this will make sure your disk mounts at boot):
 +
 +<code>UUID=whatever-blkid-gave-me /mnt/new_disk ext4 defaults 0 0</code>
 +
 +11. You're done!