Getting HDD’s serial number in Linux without hdparm

I had to test some new HDDs with badblocks. I found that the Debian installer has this utility, so you can test your disks. I started testing and one of the disks started failing. I needed to get the disk’s serial number in order to know which one I had to replace. Normally hdparm tells you this, but it’s not available in debian’s installer disk.

Thanks to this stackoverflow question I got the answer:

/sbin/udevadm info --query=property --name=sda