Skip to content

Instantly share code, notes, and snippets.

@hnhnarek
Forked from a-maumau/nvme_mount.md
Last active October 12, 2022 10:31
Show Gist options
  • Save hnhnarek/d7713c36db6c4edf7a390f0ef33d329d to your computer and use it in GitHub Desktop.
Save hnhnarek/d7713c36db6c4edf7a390f0ef33d329d to your computer and use it in GitHub Desktop.
how to mount m.2 ssd/hdd

Setup nvme disk

[NOTE] if you can access to the GUI environment, It is very easy using "disks" application.

------------------------------------------------------------------------  

Check attached devices

lsblk -o NAME,HCTL,SIZE,MOUNTPOINT

First you need to create a partition of it

sudo fdisk /dev/nvme0n1

You can see commands by m.
Choose “n” to create a new partition, then “p” then “1” to create a new primary partition.
Just use defaults, or just press enter when you asked about sector numbers.
Then “w” to write the data to the disk.
(in my case I did't need "w")

Make file system

# reference site shows /dev/nvme0n1p1 but in may case, it was /dev/nvme0n1
sudo mkfs -t ext4 /dev/nvme0n1p1

You can pick which file systems you want, but ext4 might be the best, I think.

Make mount point

( /mnt/ is better?)

sudo mkdir /media/what_you_want

Change owner and permissions

sudo chown -R <user>:<user> /media/what_you_want
sudo chmod 764 /media/what_you_want

Mount

mount /dev/nvme0n1p1 /media/what_you_want
(in my case /dev/nvme0n1p1 was /dev/nvme0n1)

Write /etc/fstab for auto mount

# check uuid and file system type
sudo blkid
# write /etc/fstab like
UUID=uuid_of_your_device /media/what_you_want   ext4    defaults        1       1
# for detail see http://docs.cray.com/books/S-2341-22/html-S-2341-22/le14643-parent.html
# or something.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment