5 ms·
> I don't know why dd remains the standard for so many tutorials You can also do something like dd if=file.iso of=/dev/disk/by-id/ata-Samsung_SSD_840_EVO_
by phiresky 6y ago
> I don't know why dd remains the standard for so many tutorials
You can also do something like
dd if=file.iso of=/dev/disk/by-id/ata-Samsung_SSD_840_EVO_120GB
Where the last part is basically the brand and name of your USB stick, not much guess work required. Though I've never seen that in any tutorials.
- smcameron 6y agoWhat I do to find out which is which is use lsscsi: $ lsscsi [0:0:0:0] disk ATA ST2000DX001-1NS1 CC41 /dev/sda [3:0:0:0] cd/dvd ASUS SH-224FB 1.00 /dev/sr0 [4:0:0:0] disk Generic- Multiple Reader 1.11 /dev/sdb
- dirkt 6y agoUnfortunately you have to do this again after each reboot, or whenever you plug in an USB stick, so the dev/by-* option does help when you do that repeatedly for the same device.
- jeroenhd 6y agoIt's really unfortunate how tutorials still spell out all the basics to keep the beginners with them, but then rely on the old-fashioned device names when it comes to writing images. Using sda is fine if you're experienced and know what drive has what name, but technical references should stop relying on them already. It's not like you're getting some useful cross-platform compatibility out of old-fashioned commands or anything, every modern Unix has its own way to specify disk names.
- csydas 6y agoI think the simplest explanation is that the authors themselves never considered the other options or were even aware of them -- they simply are sharing some historical knowledge they had. Very kind and good behavior! But I would imagine it's something rote and probably just a shortcoming in collective knowledge. In short, I think ignorance is the simpler answer ;)
- simonmales 6y agoYep, every couple of years I need to use dd. Never knew of an alternative to sda.
- nitrogen 6y agoWhen I was first learning Linux it was pretty helpful to look at a few random things in /dev and /bin and /etc and learn what they did, whenever I had a few spare minutes.
- micro-ram 6y agoZFS has open my eyes to /dev/disk/by-id/. It's the only way when you have many of the exact same make/model/size drives per machine. You will learn by fire the first time you need to determine which drive you need to replace.
- alex_smart 6y ago>Using sda is fine if you're experienced and know what drive has what name Not even then. The prospect of making an occasional mistake, while low, is clearly much higher than when you are selecting the disk using its name. Being experienced doesn't excuse you from the responsibility of using a less risky tool.
- codetrotter 6y agoTo avoid mistakes I always do “lsblk” (on Linux) or “diskutil list” (on macOS) or “gpart show” (on FreeBSD) and carefully read the output before I do the dd to something. Usually on Linux I only use /dev/disk/by-id/foo in scripts and config files. But using it when doing routine stuff with dd is a pretty good idea too. It’s too bad that macOS and FreeBSD hasn’t anything similar to my knowledge. And since I use both of these operating systems so much, and so often for things involving dd, I think in my case I don’t gain much from doing by-id for dd on Linux unfortunately.
- alex_smart 6y ago>To avoid mistakes I always do “lsblk” Even this is faulty solution. By default, it only lists the devices with their "/dev/sd*" names.
- neilv 6y agoYou're not alone. :) The installer for the USB stick Debian Live-based distro I made years ago will only install to a path starting `/dev/disk/by-id/usb-` (or `/dev/loop`). I've also been doing paths through `/dev/disk/by-id/` in the ops documentation and scripts for my startup. It's a tiny convention for us promote, and one of countless good practices we exercise, but this particular one can save much misery, at negligible cost. And early, precarious startups are one of the contexts in which some of these tiny negligible-cost good practices seem to pay off especially well: in an early startup, it's easy for me to imagine a data loss, bad downtime, or missed opportunity ending the company (when a more-established company might be able to weather a mess-up better).
- mongol 6y agoLifehack of the month! So obvious and so little used.
- FriedrichN 6y agoI love this tip! I always get sweaty armpits whenever I'm using dd and I check the of parameter several times just to be sure. This will save me from a lot of pit stains.
- gjvc 6y agoExcellent suggestion. It also includes the serial number for non-removable devices, like so: /dev/disk/by-id/ata-Samsung_SSD_860_PRO_1TB_S42NNF0K123456N -> ../../sdc
- m463 6y agoI learned of this from this (rather long and detailed) article: https://perfectmediaserver.com/ https://perfectmediaserver.com/ It's full of other great nuts-and-bolts advice. I feel it's important to mention you want by-id as there are 5 permutations of /dev/disk/by-*: /dev/disk/by-id /dev/disk/by-partlabel /dev/disk/by-partuuid /dev/disk/by-path /dev/disk/by-uuid
- stonecharioteer 6y agoTIL! Thank you so much for this. I didn't know.
- saagarjha 6y agoWhat happens if you have two?