Device naming changing

I’ve noticed (only since January) that my device names (/dev/sdb, /dev/sdc,/dev/sdd,etc) have been playing musical chairs.
I tend to write bootable ISOs with dd (a habit that is biting me in the posterior end lately). For my rememberable past (which is at least six months), devices have tended to stay static and I could depend on my USB thumb drive to be /dev/sdd, however, this month I’ve nuked two hard drives. One, well heck two, were just carelessness. I did a lsblk before I started the dd, but apparently didn’t pay close enough attention. This morning I just glanced and saw two partitions (like my thumb drive) and chose /dev/sdc. When the dd finished in about 3 seconds, I groaned and scrolled up…
Well, I didn’t need my Windows data drive anyway, did I ?
Have I just been lucky in the past or is some change in the kernel caused this peregrination?
I either need to pay more attention or start using a GUI to drive my writes.

You are the artisan of your own machine.

I like popsicle or ventoy.

Depending on the partition layout you might be lucky. The data towards the end of the disk will be intact, so if you had a smaller leading partition, and re-create the partition table, you’ll be able to recover the data in partitions that weren’t overwritten.

I started putting a decent sized empty space (or swap) at the beginning of /dev/sd* devices to avoid this issue - if I accidentally write to the wrong device all that gets overwritten is swap (or nothing).

Unfortunately, it was just one big NTFS volume, so…I scrambled it good (the first 2G or so) I think.
Yes, I have 3 hours of scan left to see what’s there (I’m really not sure…haven’t done much Windows work for 2 or 3 years). I’m also not sure it’s worth looking through hardly…I mean old data not much can be important right? I’ll look at least cursorily and probably be amazed at what I can find and pull off to another drive.
It’s amazing these days, even my GOG game saves are in the cloud.

1 Like

In general you cannot count on a certain drive having a constant device name, so if you use scripts to automate writing to various drives and you have device names hardcoded, you are bound to eventually destroy data.

The only thing that you can count on being constant is UUID.

Kresmir, I do it manually (not scripts)…but brain does retain stuff from previous days (well sometimes) and rash actions do occur.
Will the UUID remain constant with different USB slots and rewriting the drive partition table (dd)? I was under the impression (perhaps mistakenly) that UUID was somewhat randomly assigned and would change with a repartition.

Yes, it will change when you change the filesystem. So in that case, even that is not constant.

So in essence, check and pay attention, young padawan? (even if not so young anymore)

Not exactly :stuck_out_tongue:
When writing ISOs on USB drives, you don’t write to a partition, rather on the whole drive.
So, the proper(est) way to check their names is this:

ls /dev/disk/by-id | grep -vE "part[0-9]+$"

and if the outcome is not self-explaining, compare them to the output of fdisk -l or parted -l.

But the simplest almost always adequate method is

lsblk -f


1 Like

Jonathan, Just wanted to let you know that I made a 4 gb partition at the start of the volume after I gave up on recovering anything from the drive. Hopefully this will save me from stupidity/old-age, assuming I haven’t learned better.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.