Hot answers tagged

363

Linux automatically detects SSD, and since kernel version 2.6.29, you may verify sda with: cat /sys/block/sda/queue/rotational You should get 1 for hard disks and 0 for a SSD. It will probably not work if your disk is a logical device emulated by hardware (like a RAID controller). See this answer for more information...


119

With lsblk (part of the util-linux package): lsblk -d -o name,rota NAME ROTA sda 0 sdb 0 sdc 1 where ROTA means rotational device (1 if true, 0 if false)


88

If you worry about write cycles, you won't get anywhere. You will have data on your SSD that changes frequently; your home, your configs, your browser caches, maybe even databases (if you use any). They all should be on SSD: why else would you have one, if not to gain speed for the things you do frequently? The number of writes may be limited, but a modern ...


86

Unmount any filesystems on the disk. (umount ...) Deactivate any LVM groups. (vgchange -an) Make sure nothing is using the disk for anything. Once you've done that, it should be safe to unplug. If you want to be extra cautious, do echo 1 > /sys/block/(whatever)/device/delete first. That'll unregister the device from the kernel, so you know nothing's ...


57

Use smartctl (install by installing smartmontools) to retrieve vendor information, sudo smartctl -a /dev/sdb If you see a line like this, Rotation Rate: Solid State Device That would be a SSD drive.


53

async is the opposite of sync, which is rarely used. async is the default, you don't need to specify that explicitly. The option sync means that all changes to the according filesystem are immediately flushed to disk; the respective write operations are being waited for. For mechanical drives that means a huge slow down since the system has to move the ...


43

I like hddtemp, which provides a pretty standard way of getting the temperature for supported devices. It requires SMART support though. Example Usage: sudo hddtemp /dev/sd[abcdefghi] Example Response: /dev/sda: WDC WD6401AALS-00J7B0: 31°C /dev/sdb: WDC WD7501AALS-00J7B0: 30°C


31

I needed to do this on the VPS and none of the provided solutions worked for me, this answer did the trick https://serverfault.com/questions/551453/how-do-i-verify-that-my-hosting-provider-gave-me-ssds/551495#551495 so, it is about reading random data from the drive and assessing the time. time for i in `seq 1 1000`; do dd bs=4k if=/dev/sda count=1 ...


31

Ok, so the goal is to get as much bang for the buck as possible - Speed vs. the price of replacement hardware (assuming a single large harddisk and medium-size SSD, which seems to be the norm). To simplify you can to weigh how much you notice the speed increase from moving a file to the SSD against the number of sectors written to move that file to the SSD. ...


30

TRIM does at least three things: minimize write amplification prevent long-term performance degradation irrecoverably delete your data Now it depends where your priorities are. For 1), you should not be using fstrim at all, but make use of the discard option of your filesystem. Only if everything is trimmed instantly will the SSD stop copying no longer ...


30

This is the fastest way to securely erase a drive I know of. For SSDs, no, it's not. blkdiscard /dev/device is dozens times faster and should be equally safe for your use case. Would cat /dev/zero > /dev/sdX be as fast? From the look of it these two commands should be equally fast. Fast is what I need while not decreasing the SSD's life span. You do ...


29

I'd say fio would have no trouble producing those workloads. Note that despite its name CrystalDiskMark is actually a benchmark of a filesysystem on a particular disk - it can't do I/O raw to the disk alone. As such it will always have filesystem overhead in it (not necessarily a bad thing but something to be aware of e.g. because the filesystems being ...


29

Using nvme-cli, I can get temperature from a Samsung 950 Pro with this command: nvme smart-log /dev/nvme0 | grep "^temperature" You can get other informations too: nvme smart-log /dev/nvme0 Smart Log for NVME device:nvme0 namespace-id:ffffffff critical_warning : 0 temperature : 45 C available_spare ...


29

Writing a block to an SSD does not overwrite the old block. That's because all recent SSDs use something called "wear leveling". To write a block to an SSD, you need to erase it first, and then you can write the new data. But erasing is an operation that can only be executed a limited number of times; each time you do an erase, you "weaken&...


24

On a hybrid solid-state and spinning disk system (like the one I'm typing this), you have two to three aims: Speed up your system: as much commonly used data as possible stays on the SSD. Keep volatile data off the SSD to reduce wear. Optional: have some level of redundancy by using an md(4) (‘software RAID’) setup across the SSD and HDD(s). If you're just ...


24

Statically configured swap space (the type that pretty much every distribution uses) is configured in /etc/fstab just like filesystems are. A typical entry looks something like: UUID=21618415-7989-46aa-8e49-881efa488132 none swap sw 0 0 You may also see either discard or nofail specified in the flags field (the fourth field). Every such ...


23

I suggest using a different testing method. hdparm is a bit weird as it gives device addresses rather than filesystem addresses, and it doesn't say which device those addresses relate to (e.g. it resolves partitions, but not devicemapper targets, etc.). Much easier to use something that sticks with filesystem addresses, that way it's consistent (maybe except ...


22

If the filesystem is ext4, there are reserved blocks, mostly to help handling and help avoid fragmentation and available only to the root user. For this setting, it can be changed live using tune2fs (not all settings can be handled like this when the filesystem is mounted): -m reserved-blocks-percentage Set the percentage of the filesystem which may ...


21

let's say Fedora and Ubuntu? … both of which are nowadays systemd operating systems. What happens in systemd operating systems the native mechanism Systemd employs various kinds of units. .mount unit files instruct it to mount volumes. .swap unit files instruct it to tell the kernel about swap partitions. (.service unit files instruct it how to ...


21

It's currently not possible to install anything except Windows 10 on Apple computers equipped with T2 chip. This security chip makes it impossible to see the internal drive, Apple generously did an exception only for Windows 10 (but only if you install it via Boot Camp). A possible option could be Linux installed on a USB/Thunderbolt external drive, ...


19

In your first example, what I think you are referring to is the "Media Wearout Indicator" on Intel drives, which is attribute 233. Yes, it has a range of 0-100, with 100 being a brand new, unused drive, and 0 being completely worn out. According to your ouptut, this field doesn't seem to exist. In your second example, please read the official docs about ...


17

Bcache could be exactly what you're looking for: Bcache is a Linux kernel block layer cache. It allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives. I'm eagerly awaiting its inclusion into Linux mainline, but unfortunately it's still not quite there. Some nice and ...


17

For Samsung SSDs, check SMART attribute 177 (Wear Leveling Count). ID # 177 Wear Leveling Count This attribute represents the number of media program and erase operations (the number of times a block has been erased). This value is directly related to the lifetime of the SSD. The raw value of this attribute shows the total count of P/E Cycles. ...


16

I would suggest you use udev to set parameters for the SSD disks. This way you can configure a specific queue scheduler that is more appropriate for SSD, etc. You can also apply parameters only to some of the devices, based on a lot of parameters. You can obtain the specific attributes necessary to match your devices (eg. the disk model and manufacturer) by ...


14

The other answers already tell you how to get this information in a number of ways , including /proc. But you must expect all these mechanisms to lie if there's any virtualisation in the way, such as a hybrid SAN array with multiple tiers, or if the Linux machine is a virtual machine (where Linux will probably report the disk as a basic SCSI rotating disk, ...


14

In general you can just ignore fragmentation altogether. More so for SSD which do not suffer from seek times like HDD. Defragmenting a SSD will do nothing except waste write cycles. Although there may be extreme cases where fragmentation has a noticable effect, such as a sparse file written to in random order (as some BitTorrent clients do), or when the ...


14

Samsung is really, really weird and it took me many hours to figure this one out because it's absolutely counterintuitive. It turned out that I was right with my skepticism of an image provided by Samsung probably actually being suitable to boot from it. Putting the image they offer you on a thumb drive doesn't work. It's not that it's super fast and you ...


14

I have a MacBook Pro Mid 2018 and managed to get the SSD working for like 10 seconds. When you live boot Linux Mint or Ubuntu and do: modprobe nvme Then check for the hardware ID of the Apple Storage controller by doing: lspci -nn | grep NVMe Then put that ID in the new_id file under nvme: echo 106b 2005 > /sys/bus/pci/drivers/nvme/new_id When you ...


13

Original Answer: https://unix.stackexchange.com/revisions/480191/12 I created a script that tries to replicate the behavior of crystaldiskmark 6 with fio, and I also added support for older tests (like the 512kb test) this answer is updated now a long while after I initially created it, the script has much needed improvements. A changelog is included for ...


13

The physical block size reported by fdisk is the physical block size reported by the disk when asked. It seldom has any relationship with SSD pages or erase blocks. 4 KiB reads/writes are a common measure of I/O performance, representing "small" I/O operations. There is no standard way for a SSD to report its page size or erase block size. Few if any ...


Only top voted, non community-wiki answers of a minimum length are eligible