here's a nice script to show disk info within pools...

All your general support questions for OpenZFS on OS X.

here's a nice script to show disk info within pools...

Postby tangles » Sat Dec 30, 2017 10:32 am

The "zpool status" command references drives using the "/var/run/disk/by-id/" pointer.

Not much help if you want to do/see things in Disk Utility.app so I wrote the following little script to help.

Running "zpool status" will output the media-hex… entries such as media-AC82D552-8108-0141-A3A8-654FD6F0CA89.

Copy the media-hex string to your clipboard and invoke the script with "lz" will give back the following:

Code: Select all
=> lz media-AC82D552-8108-0141-A3A8-654FD6F0CA89
   Device Identifier:        disk4
   Whole:                    Yes
   Part of Whole:            disk4
   Device / Media Name:      WDC WD20EARS-00J99B0
   Disk Size:                2.0 TB (2000398934016 Bytes) (exactly 3907029168 512-Byte-Units)
   Device Block Size:        512 Bytes


save the following into your .bash_profile file:
Code: Select all
lz() {
diskutil info  `ls -l  /var/run/disk/by-id | grep "$1" | awk -F" " '{print $11}' | sed 's/s1//' | sed 's|\/dev\/||'` | egrep '(Device Identifier:)|(Whole:)|(Device / Media Name)|(Disk Size:)|(Device Block Size:)'
}


It's not the prettiest script and I know it could be done better, but figured I'd share for all anyway.

Another function I use a lot is:

Code: Select all
pdz() {
echo "Warning, you're about to destroy data on disks "$@"! Have you diskutil -list to be certain?"
for i in "$@"
do
sudo diskutil partitiondisk /dev/disk"$i" GPTFormat "Free Space" "Free Space" 100%;
done
}


i.e.
Code: Select all
=>pdz 2 5 8
will erase/destroy any partitions on the given drives and prepare them for zfs use. It's a dangerous script though, so be warned!

and finally another script I use to create new pools:

Code: Select all
zpc9() {
echo "creating pool for rotational disks, ashift=9 -> 512b bytes sector size"
sudo zpool create -f -o ashift=9 -O compression=lz4 -O checksum=skein -O casesensitivity=insensitive -O atime=off -O normalization=formD "$@"
sudo zfs set reservation=1m "$1"; sudo zfs set com.apple.mimic_hfs=on "$1"; sudo chown -Rf unknown:staff /Volumes/"$1"; sudo chmod o-rwx /Volumes/"$1"; sudo chmod -RN /Volumes/"$1"; sudo chmod -R +a "admin allow delete,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit,list,search,add_file,add_subdirectory,delete_child,list,search,add_file,add_subdirectory,delete_child" /Volumes/"$1"
 }


I have zpc12 too. ;)

Cheers,
tangles
 
Posts: 195
Joined: Tue Jun 17, 2014 6:54 am

Re: here's a nice script to show disk info within pools...

Postby lundman » Fri Jan 05, 2018 12:28 am

zpool status -L ?
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan


Return to General Help

Who is online

Users browsing this forum: Google [Bot] and 21 guests