Skip to content

Instantly share code, notes, and snippets.

@a-maumau
Last active November 2, 2024 15:47
Show Gist options
  • Save a-maumau/b826164698da318f992aad5498d0d934 to your computer and use it in GitHub Desktop.
Save a-maumau/b826164698da318f992aad5498d0d934 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 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