User Tools

Site Tools


wiki:linux:basics:format_new_drive_linux

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
wiki:linux:basics:format_new_drive_linux [2025/01/07 12:50] – ↷ Page moved from format_new_drive_linux to wiki:linux:basics:format_new_drive_linux Gregwiki:linux:basics:format_new_drive_linux [2025/01/07 13:09] (current) – Re-formatted code blocks Greg
Line 5: Line 5:
 2. Use the ''fdisk'' tool to find your disk: 2. Use the ''fdisk'' tool to find your disk:
  
-''sudo fdisk -l''+<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. 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.
Line 11: Line 11:
 4. Create a filesystem on the new disk (e.g. for ext4): 4. Create a filesystem on the new disk (e.g. for ext4):
  
-''sudo mkfs.ext4 /dev/sda''+<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: 5. Create a new directory to mount your disk to; replace "new_disk" with whatever name you want:
  
-''sudo mkdir /mnt/new_disk''+<code>sudo mkdir /mnt/new_disk</code>
  
 6. Mount the disk to your new mount point: 6. Mount the disk to your new mount point:
  
-''sudo mount -t ext4 /dev/sda /mnt/new_disk''+<code>sudo mount -t ext4 /dev/sda /mnt/new_disk</code>
  
 7. Grant your user ownership of the new disk: 7. Grant your user ownership of the new disk:
  
-''sudo chown my_user: /mnt/new_disk; sudo chmod 755 /mnt/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: 8. Use ''blkid'' to find your disk's UUID:
  
-''sudo blkid''+<code>sudo blkid</code>
  
 Search the output for the line that maps to your disk's path. Search the output for the line that maps to your disk's path.
Line 33: Line 33:
 9. Open ''/etc/fstab'' in your favorite text editor with root privileges, e.g. vim: 9. Open ''/etc/fstab'' in your favorite text editor with root privileges, e.g. vim:
  
-''sudo vim /etc/fstab''+<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): 10. Add the following line to the end of the file (this will make sure your disk mounts at boot):
  
-''UUID=... /mnt/new_disk ext4 defaults 0 0''+<code>UUID=whatever-blkid-gave-me /mnt/new_disk ext4 defaults 0 0</code>
  
 11. You're done! 11. You're done!
wiki/linux/basics/format_new_drive_linux.txt · Last modified: 2025/01/07 13:09 by Greg