Skip to content

Instantly share code, notes, and snippets.

@tecfu
Forked from a-maumau/nvme_mount.md
Created August 14, 2021 20:56
Show Gist options
  • Save tecfu/877a6c16a9cf2a8a4b2632857ef72d68 to your computer and use it in GitHub Desktop.
Save tecfu/877a6c16a9cf2a8a4b2632857ef72d68 to your computer and use it in GitHub Desktop.
how to mount m.2 ssd/hdd

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

or might be easy with gdisk/fdisk ?   I'm not sure about this.  

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

see the reference for more detail, if you want.
https://richardstechnotes.wordpress.com/2015/12/18/setting-up-an-nvme-ssd-on-ubuntu-14-04-lts/   http://takatakamanbou.hatenablog.com/entry/2015/10/25/235600 : Japanese website

First you need 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