Before you can use a drive in Linux, you need to partition it and create a filesystem on it.
Command | Explanation |
---|---|
sudo fdisk -l |
List all drives and their partitions. |
sudo parted /dev/nvme1n1 mklabel gpt |
Create a new GPT partition table on the drive. |
sudo parted -a optimal /dev/nvme1n1 mkpart primary ext4 0% 100% |
Create a single ext4 partition covering the whole drive. |
sudo mkfs.ext4 /dev/nvme1n1p1 |
Format the new partition with the ext4 filesystem. |
Once you have a filesystem on your drive, you can mount it to access its contents.
Command | Explanation |
---|---|
sudo mount /dev/nvme1n1p1 /mnt/mydrive |
Mount the drive at the specified location. |
sudo umount /dev/nvme1n1p1 |
Unmount the drive. |
sudo nano /etc/fstab |
Edit the fstab file to configure drives to mount at boot. |
To check a filesystem for errors and potentially repair it, you can use the e2fsck tool.
Command | Explanation |
---|---|
sudo e2fsck /dev/nvme1n1p1 |
Check the ext4 filesystem for errors. |
sudo e2fsck -p /dev/nvme1n1p1 |
Automatically fix any filesystem errors that are found. |
You can use the smartmontools package to monitor your drive's S.M.A.R.T. status and perform self-tests.
Command | Explanation |
---|---|
sudo smartctl -a /dev/nvme1n1 |
Check the drive's S.M.A.R.T. status. |
sudo smartctl -t long /dev/nvme1n1 |
Start a long self-test on the drive. |
sudo smartctl -l selftest /dev/nvme1n1 |
View the results of the last self-test. |
The nvme-cli package provides some NVMe specific commands.
Command | Explanation |
---|---|
sudo nvme list |
List all NVMe devices and their status. |
sudo nvme smart-log /dev/nvme1n1 |
Check the drive's S.M.A.R.T. status. |
sudo nvme self-test /dev/nvme1n1 --short |
Start a short self-test on the drive. |
sudo nvme self-test-log /dev/nvme1n1 |
View the results of the last self-test. |
For troubleshooting a variety of issues, here are some general suggestions and commands to start with.
Issue | Solution |
---|---|
Drive not recognized | Check physical connection. Try different PCIe slot or cable. Check dmesg for error messages. |
Filesystem errors | Unmount the filesystem and run sudo e2fsck /dev/nvme1n1p1 . Try mounting it again after. |
Performance issues | Check iostat or similar tool for drive activity. Run smartctl or nvme self-tests to check drive health. |
For advanced users who want to tune their system, here are some additional options and commands.
Command | Explanation |
---|---|
sudo nano /etc/sysctl.conf |
Edit the sysctl configuration file to tune various kernel parameters. |
cat /sys/module/nvme_core/parameters/default_ps_max_latency_us |
Check the NVMe power saving setting. |
`echo 0 | sudo tee /sys/module/nvme_core/parameters/default_ps_max_latency_us` |
Please note, the above suggestions are provided as general guidance and may not work for all specific cases. Always test changes in a controlled environment before deploying them in a production environment.
ŧChatGPT may produce inaccurate information about people, places, or facts.