Difference between revisions of "Template:How to Initialize and Format New SSD And HDD"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(updated by API)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
===Connect NVME SSD High Speed Hard Disk===
+
==Connect NVME SSD High Speed Hard Disk==
We suggest you switch to "root" by running the following command:<br />
+
===Detection of SSD===
<syntaxhighlight lang="bash">
+
su -
+
</syntaxhighlight>
+
The password for "root" is "fa".
+
 
+
====Detection of SSD====
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
root@FriendlyELEC:~# cat /proc/partitions  
 
root@FriendlyELEC:~# cat /proc/partitions  
Line 15: Line 9:
 
If there is a nvme0n1 device node it means an SSD is recognized.
 
If there is a nvme0n1 device node it means an SSD is recognized.
  
====Partition of SSD====
+
===Partition of SSD===
 
To mount an SSD under Linux we re-partition it as one section by running the following command:
 
To mount an SSD under Linux we re-partition it as one section by running the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
(echo o; echo n; echo p; echo 1; echo ""; echo ""; echo w; echo q) | fdisk /dev/nvme0n1
+
(echo g; echo n; echo p; echo 1; echo ""; echo ""; echo w; echo q) | fdisk /dev/nvme0n1
 
</syntaxhighlight>
 
</syntaxhighlight>
 
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.
 
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.
  
====Format Section to EXT4====
+
===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:
 
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:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 38: Line 32:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====Auto Mount SSD on System Startup====
+
===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":  
 
Before we mount an SSD's section you need to know its Block ID. You can check it by running "blkid":  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 55: Line 49:
 
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:
 
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:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
mkdir /media/nvme
+
mkdir -p /media/nvme
 
chmod 777 /media/nvme
 
chmod 777 /media/nvme
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 67: Line 61:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
reboot
 
reboot
</syntaxhighlight>
 
 
====SSD Read & Write====
 
You can test SSD read and write speed. In our test we used a LITEON T10 120GB SSD. Different SSDs may have different results.<br /><br />
 
Write to SSD: <br />
 
<syntaxhighlight lang="bash">
 
# dd if=/dev/zero of=/media/nvme/deleteme.dat bs=32M count=128
 
128+0 records in
 
128+0 records out
 
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 12.5671 s, 342 MB/s
 
</syntaxhighlight>
 
<br />
 
Read from SSD: <br />
 
<syntaxhighlight lang="bash">
 
# dd if=/media/nvme/deleteme.dat of=/dev/zero bs=32M count=128
 
128+0 records in
 
128+0 records out
 
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 6.72943 s, 638 MB/s
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 03:26, 14 June 2022

1 Connect NVME SSD High Speed Hard Disk

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 g; 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 -p /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