0

I'm working on a script that requires the device name of the disks in all of the vdevs for an arbitrary pool. (All of the devices in the vdevs in my pools are disks.)

zpool list -v mypoolname seems to mostly be what I want:

$ zpool list -v mypoolname
NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
mypoolname   100G   90G  10.0G    90%  1.00x  ONLINE  -
  mirror   100G   90G  10.0G         -
    devicename1      -      -      -         -
    devicename2      -      -      -         -

But the only obvious way to determine which lines of the output are the disks is to check for four spaces at the start of the line.

Is there a better, script-safe command I could run instead?

2
zpool list -v -H -P

-v verbose
-P show full paths, not just the last component
-H script mode - no headings, fields separated by tab character

That will get you a lot closer.

  • My zpool doesn't have a -P option for list. I see ... module v0.6.3-5~trusty, ZFS pool version 5000, ZFS filesystem version 5 via dmesg | grep ZFS. – Kenny Evitt Mar 31 '18 at 23:50
  • 1
    ah, my version on trusty is module v0.6.5.11-1~trusty, ZFS pool version 5000, ZFS filesystem version 5 The line from my sources.list.d file for zfs is deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main – frymaster May 1 '18 at 21:35

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.