How to Assign a Label to a File System
Create an encodings file. You must have logged out and logged back in. You also must be a user who can assume the root
role. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.4.
To create a labeled file system, you enable the multilevel
ZFS property. This action can be performed at any time during the lifetime of a ZFS dataset.
Example 3-1 Finding Files of a Specified Label
The following script finds all files of a specified label.
#!/bin/sh # Find all files whose label matches $1 zfs list -Ho multilevel,mounted,mountpoint -t filesystem -r rpool|\ while read multilevel mounted mountpt;do if [ $multilevel == on -a $mounted == yes ];then for file in $(find $mountpt -print); do label=$(getlabel $file 2>/dev/null|cut -d: -f2|\ grep -i "$1" 2>/dev/null) if [[ -n $label ]]; then echo $file echo '\t'$label fi done fi done