Template:How to Initialize and Format New SSD And HDD
Contents
1 Connect NVME SSD High Speed Hard Disk
We suggest you switch to "root" by running the following command:
su -
The password for "root" is "fa".
1.1 Detection of SSD
root@FriendlyELEC:~# cat /proc/partitions major minor #blocks name 1 0 4096 ram0 259 0 125034840 nvme0n1
If there is a nvme0n1 device node it means an SSD is recognized.
1.2 Partition of SSD
To mount an SSD under Linux we re-partition it as one section by running the following command:
(echo o; echo n; echo p; echo 1; echo ""; echo ""; echo w; echo q) | fdisk /dev/nvme0n1
If you want to re-partition it to multiple sections you can run "fdisk /dev/nvme0n1". For more detail about this command refer to the fdisk's manual.
1.3 Format Section to EXT4
After an SSD is successfully partitioned you can check its sections by running "cat /proc/partitions". The /dev/nvme0n1p1 section is used to store data:
root@FriendlyELEC:~# cat /proc/partitions major minor #blocks name 1 0 4096 ram0 259 0 125034840 nvme0n1 259 2 125033816 nvme0n1p1
The following command formats a section to ext4:
mkfs.ext4 /dev/nvme0n1p1
1.4 Auto Mount SSD on System Startup
Before we mount an SSD's section you need to know its Block ID. You can check it by running "blkid":
blkid /dev/nvme0n1p1 /dev/nvme0n1p1: UUID="d15c4bbf-a6c3-486f-8f81-35a8dbd46057" TYPE="ext4" PARTUUID="887628f0-01"
Add a "Block ID" to "/etc/fstab" and here is what it looks like
UUID=<Block ID> /media/nvme ext4 defaults 0 0
You need to replace <Block ID> with the UUID obtained by running "blkid". To mount the SSD in our example we made the "/etc/fstab" file as follows:
UUID=d15c4bbf-a6c3-486f-8f81-35a8dbd46057 /media/nvme ext4 defaults 0 0
We want to mount an SSD to "/media/nvme" but this directory doesn't exist. Therefore we create it and change its access right by running the following commands:
mkdir /media/nvme chmod 777 /media/nvme
Run "mount" to check if the SSD is mounted successfully:
mount /media/nvme
You can reboot your board to check if your SSD will be automatically mounted:
reboot