How can I block devices by the most recent added ones? No option in lsblk seems to have that functionality.


One way to do it is using the ls command, because Linux block devices actually have a working time metadata:

ls -lt /dev/ |grep "^b"| more

For plain device names:

ls -t1 /dev/ | more


ls -lt /dev/ |grep "^b" |sed -r "s/^.* (.*)$/\1/g" | more.

Another possible method: lsblk -p -d --output name |tail.
You might want to use lsblk -p -d --output name /dev/sd? | tail.

| improve this answer | |
  • It just has one limitation: That timestamp is the date of last modification. We would need the date of creation, which the stat command does show. But I will have to figure that out later. – neverMind9 Jul 1 '19 at 20:43
  • USB Block devices are also sorted alphabetically: sda, sdb, sdc, sdd, sde, sdf, … lsblk /dev/sd? – neverMind9 Jul 1 '19 at 20:44
  • Another possible method: lsblk -p -d --output name |tail . – neverMind9 Jul 1 '19 at 23:38
  • 1
    Please note that Linux does not assign new devices to the next letter of the alphabet always, but to the first available one. If the last device is /dev/sdy, but /dev/sde is suddently free, /dev/sde will be used instead of /dev/sdz, making alphabetic sorting ineffective for that purpose. – neverMind9 Jul 1 '19 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.