1

I would like to get a list of all my hard disks including the following information. Serial Number, UUID, Size and the names and sizes of all of the partitions on each disk. I found this which gets me half way there

for file in $(find /sys/block/[sh][dr]*/device/ /sys/block/[sh][dr]*/ -maxdepth 1 2>/dev/null|egrep '(vendor|model|/size|/sys/block/[sh][dr]./$)'|sort); do [ -d $file ] && echo -e "\n -- DEVICE $(basename $file) --" && continue; grep -H . $file|sed -e 's|^/sys/block/||;s|/d*e*v*i*c*e*/*\(.*\):| \1 |'|awk '{if($2 == "size") {printf "%-3s %-6s: %d MB\n", $1,$2,(($3 * 512)/1048576)} else {printf "%-3s %-6s: ", $1,$2;for(i=3;i<NF;++i) printf "%s ",$i;print $(NF) };}';done

My preference is for it to go to a text file. I assume I can do that just by adding "> ~/disks.txt" to the end of the line

Would really appreciate it if someone could help me figure out how to modify the command so it adds partition names and sizes.

2
  • 2
    what about lshw command? try this link
    – Lety
    Jun 29, 2014 at 13:33
  • 1
    Thanks. Itś not as convenient and compact as I would like but it does have all the info I need - especially "lshw -C disk -C volume"
    – user289455
    Jun 30, 2014 at 11:55

0

You must log in to answer this question.

Browse other questions tagged .