xe1phix

Xe1phix-[ZFS]-Cheatsheet-[v14.7.54].sh

Oct 6th, 2022
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 62.57 KB | None | 0 0
  1. #!/bin/bash
  2. ## Xe1phix-zfs-v*.*.sh    
  3. ##       
  4.  
  5.    
  6. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  7.      [+] VDEVs (Virtual Block Devices)
  8.      [+] COW (Copy-on-Write) Filesystem                                              
  9.                                                    _________________________________________________________________________________________
  10.      [+] Primary Cache (ARC)                       |_|_ _ _________________________________________________________________              |
  11.                                                    |_|_____| [+]_Attribute_Details      |____________| [+]_Attribute_Value |_____________|
  12.                                                      / #||-> Primary Cache (ARC) Method       |                            \ \ | |  / /
  13.                                                     / /#||-> User Data + Metadata is Cached   |        primarycache=all     \ \| | / /
  14.                                                    / / #||-> Metadata (Only) Is Cached        |   primarycache=metadata      \ | |/ /
  15.                                               ____/ / /#||-> Neither User Nor Metadata Cached |       primarycache=none       \|_| /
  16.                                         ##   (____}~===~{+}-===================================================================||=======~##
  17.      [+] Secondary Cache (L2ARC)                  \ \ \#||-> User Data + Metadata is Cached.  |      secondarycache=all       /| | \
  18.                                                    \ \ #||-> Metadata (Only) Is Cached        | secondarycache=metadata      / | |\ \
  19.                                                     \ \#||-> Neither User Nor Metadata Cached |     secondarycache=none     / /| | \ \
  20.                                                      \ #||  ________________________________ _|_ _________________________ /_/_|_|__\ \___
  21.                                                       \#||_|________________________________|___|_________________________________________|
  22.                                                    
  23.  
  24.  
  25. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  26.      [+] SHA256 Checksum Integrity Verification
  27.      [+] Deduplication
  28.      [+] Ditto Blocks (Replicated Metadata)
  29.      
  30. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  31.      [+] ZFS Snapshots
  32.          ▪ Sending a ZFS Snapshot
  33.          ▪ Receiving a ZFS Snapshot
  34.          ▪ Rolling Back a ZFS Snapshot
  35.          ▪ Snapshot User Holds
  36.          ▪ ZFS Snapshot Diff Parser
  37.          ▪ Rolling Snapshots                                ## @yesterday @today @friday @thursday @wednesday @tuesday
  38.          ▪ Incremental Sending of Snapshot Streams          ## ZFS hole_birth Feature
  39.      [+] ZFS Clones
  40. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  41.      [+] ZFS Quotas (User & group)
  42.          ▪ quota=
  43.          ▪ refquota=
  44.          ▪ userquota=
  45.          ▪ groupquota=
  46.      [+] Dataset Reservations
  47. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  48.  
  49.                     ##                                 |    |
  50. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  51.      [+] ACL Inheritance
  52.          ▪ ACL Inheritance Flags
  53.      [+] Access Control Entries (ACEs)
  54.          ▪ Trivial ACLs
  55.          ▪ Non-Trivial ACLs
  56.             ♦ ACL Entry Types
  57.             ♦ ACL Access Privileges
  58.      [+] Extended Attributes                            ## Enable xattr on Specified Dataset|       xattr |
  59.      [+] ZFS User Delegating Permissions                ##   Annotate Datasets For Admin    |  dept:users |
  60.        ------------------------------------------------ ##  FileSystem, Volumes, Snapshots  | ----------- |
  61.      [+] Transaction Group Number                       ## ZFS Background Recording         | enabled_txg |
  62.      [+] Trusted Extension on Datasets                  ## SELinux Labeled Privilege Zone   |    mlslabel |
  63.      [+] Virus Scan Service                             ## Scan Files In Dir For Viruses    |       vscan |
  64.      [+] ZFS Zone Restriction                           ## Dataset Managed Non-Global Zone  |       zoned |
  65.      [+] Temporary Mount Points                         ## Temporary Mount Point Properties |      
  66.      [+] Blocked Processes Execution                    ## (from within this file system)   |     exec=no |
  67.      [+] Future Device Node Blocking                    ## Blocks Device Nodes From Opening | devices=off |        
  68.        ------------------------------------------------ ## --- (on this file system.) ----- | ----------- |
  69.      [+] Read-Only Datasets Modification                ## Prevents Dataset Modification    |    readonly |
  70.      [+] Enable The Set-UID Bit                         ## Enable Set-UID Bit on Dataset    |   setuid=on |
  71. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  72.      [+] Log - ZFS Intent Log (ZFS ZIL)
  73.          ▪ Mirrored Log Devices
  74.          ▪ Separate Intent Log Devices
  75.      [+] ZFS Data Scrubbing and Resilvering
  76.          ▪ Automatic Repair (scrubbing)
  77. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  78.      [+] ZFS VDEVs RAIDs:
  79.          ▪ Striped VDEVS
  80.          ▪ Mirrored VDEVs
  81.          ▪ Striped Mirrored VDEVs
  82.      [+] RAID-Z Storage Pool:
  83.          ▪ RAIDZ (4 Disks)
  84.          ▪ Double-Parity RAID-Z | RAIDZ2 (5 Disks)
  85.          ▪ Triple-Parity RAID-Z | RAIDZ3 (6 Disks - 3/6 Parity)
  86.          ▪ Nested RAIDZ (8 Disks)
  87.      [+] RAID-Z Virtual Devices (Loop)
  88. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  89.      [+] Large ZFS Dataset Blocks | 128KB                                            ## allows record size on dataset to be set larger than 128KB
  90.      [+] ZFS - Hybrid Block Pointer | Embedded Data Feature
  91.      [+] Maximum 16 Exabyte File Size
  92.      [+] Maximum 256 Quadrillion Zettabytes
  93.      [+] Unlimited Dataset Creation
  94. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  95.      [+] Compression (Applied to Individual Datasets)
  96.          ▪ LZ4     (The latest and greatest - recommended)
  97.          ▪ gzip-N  (Where N is 1 (fastest) - 9 (best compression ratio) - not recommended)
  98.          ▪ LZJB    (Provides a good trade-off between speed and space)
  99. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  100.      [+] I/O Statistics Display
  101.      [+] ZFS Admin Web Console
  102.      [+] Zpool History
  103. '##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##'
  104.  
  105.  
  106.  
  107.  
  108.  
  109. zfs get all
  110. zfs get all ZPool-ZFS/Scriptz
  111. zfs get mounted,readonly,mountpoint,type
  112. zfs get used,available,mountpoint
  113. zfs get -H -o value compression
  114. zfs get -r -s local -o name,property,value all pool/home/bob
  115. zfs get -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild -t filesystem,volume
  116.  
  117.  
  118. zfs list -o mounted,name,used,avail,copies,rdonly,mountpoint,type
  119. zfs list -o name,used,avail,aclmode,aclinherit,zoned,xattr,copies,checksum,compress,rdonly
  120.  
  121.  
  122.  
  123. zfs get -s local all
  124. zfs get -s local all zfs/dir
  125. zfs get -r -s temporary all zfs/dir
  126. zfs get -H -o value -p used
  127. zfs get -H -o name,value -r used
  128. zfs get refquota,quota
  129.  
  130. df | awk 'NR==1||/zfs/'
  131. df | awk 'NR==1||/(zfs|dir)/'
  132.  
  133.  
  134. lsmod | awk 'NR==1||/zfs/'
  135.  
  136.  
  137. zfs -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild -t filesystem,volume
  138. zfs -t filesystem
  139. zfs -t snapshot
  140. zfs -t volume
  141. zfs -t all
  142.  
  143. zfs get -o name,property,value,received,source
  144. zfs get -s local,default,inherited,temporary,received
  145. zfs get -p
  146.  
  147.  
  148. zpool history
  149.  
  150.  
  151. zpool import
  152. zfs mount ZPool-ZFS
  153. mount | grep ZPool-ZFS
  154. zfs set mountpoint=/mnt/ZPool-ZFS ZPool-ZFS
  155. zpool import -d /mnt/ZPool-ZFS
  156. zpool import -d /mnt/ZPool-ZFS ZPool-ZFS
  157. zpool status -v
  158.  
  159.  
  160. zfs mount | grep ZPool-ZFS
  161. zfs mount ZPool-ZFS
  162. mount -F zfs ZPool-ZFS/$Dir
  163.  
  164. zfs mount -o ro ZPool-ZFS
  165. zfs mount -o remount,rw ZPool-ZFS
  166.  
  167. zfs unmount ZPool-ZFS/$dir/$dir/
  168. zfs unmount -f ZPool-ZFS/$dir/$dir/
  169. umount /mnt/ZPool-ZFS
  170.  
  171. zpool scrub ZPool-ZFS
  172.  
  173.  
  174. zpool offline ZPool-ZFS sdc
  175.  
  176. umount ZPool-ZFS/$Dir
  177.  
  178.  
  179.  
  180.  
  181. version=1 | 2 | current
  182. snapdir=hidden | visible
  183. logbias = latency | throughput
  184. sharenfs=off
  185. sharesmb=off
  186. shareiscsi=off
  187.  
  188.  
  189.  
  190. echo "##-==============================-##"
  191. echo "    [+] Nested Datasets             "
  192. echo "##-==============================-##"
  193.  
  194. echo "##-==========================================-##"
  195. echo "    [?] Datasets dont need to be isolated.      "
  196. echo "##-==========================================-##"
  197.  
  198. echo "##-===========================================================-##"
  199. echo "    [?] You can create nested datasets within each other.         "
  200. echo "##-===========================================================-##"
  201.  
  202. echo "##-=================================================-##"
  203. echo "##        This allows you to create namespaces,        "
  204. echo "##      while tuning a nested directory structure,     "
  205. echo "##              without affecting the other.           "
  206. echo "##-=================================================-##"
  207.  
  208. echo "##-=================================================-##"
  209. echo "    [?] If you want to compress zfs/log:              "
  210. echo "    [?] but not on the parent zfs/ directory:         "
  211. echo "##-=================================================-##"
  212.  
  213.  
  214. ## Consists of a ZIL header, which points to a list of records,
  215. ## ZIL blocks and a ZIL trailer.
  216.  
  217.  
  218. zfs create zfs/log
  219. zfs set compression=on zfs/log          ## Enables or disables compression for a dataset.
  220. zfs get compressratio zfs/log
  221. zfs inherit -r compression zfs/log
  222. zfs set exec=off zfs/log
  223. zpool add zfs log /dev/sd -f
  224.  
  225.  
  226.  
  227. zpool create -f -m /mnt/ZPool-ZFS ZPool-ZFS /dev/sdd
  228.  
  229. zpool create -m /mnt/ZPool-ZFS ZPool-ZFS disk /dev/sdd
  230.  
  231. zpool create pool
  232.  
  233. zfs create ZPool-ZFS/Xe1phixGitLab
  234.  
  235. zfs destroy -r ZPool-ZFS/Scripts
  236.  
  237. chmod -v -R ugo+rwx /mnt/ZPool-ZFS
  238. chown -v -R xe1phix /mnt/ZPool-ZFS
  239.  
  240. zpool get all ZPool-ZFS
  241.  
  242. zpool set listsnapshots=on ZPool-ZFS
  243.  
  244. zfs list
  245.  
  246. zfs create -p ZPool-ZFS
  247. zfs set mountpoint=/mnt/ZPool-ZFS ZPool-ZFS
  248.  
  249. chmod -v -R ugo+rwx /mnt/ZPool-ZFS/
  250. chown -v -R xe1phix /mnt/ZPool-ZFS/
  251. cd /mnt/ZPool-ZFS/
  252. mkdir Xe1phixGitLab
  253.  
  254. zpool import -d /mnt/ZPool-ZFS
  255. zpool import -d /mnt/ZPool-ZFS ZPool-ZFS
  256. zpool import -a -R /mnt
  257.  
  258. zpool status -v
  259.  
  260. /mnt/zfspool    /srv/nfs4/music none    bind,defaults,nofail,x-systemd.requires=zfs-mount.service
  261.  
  262.  
  263. zfs create ZPool-ZFS/Xe1phixGitLab
  264. zfs create ZPool-ZFS/infosec
  265. zfs create ZPool-ZFS/BrowntownAlpha
  266. zfs create ZPool-ZFS/BrownTown
  267. zfs create ZPool-ZFS/Audio
  268. zfs create ZPool-ZFS/Scripts
  269. zfs create ZPool-ZFS/Wordlists
  270. zfs create ZPool-ZFS/OS
  271.  
  272. zfs create ZPool-ZFS/Torrents
  273. zfs create ZPool-ZFS/Podcasts
  274. zfs create ZPool-ZFS/'Quantum Physics'
  275. zfs create ZPool-ZFS/Scripts{old}
  276. zfs create ZPool-ZFS/Videos
  277. zfs create ZPool-ZFS/'VirtualBox VMs'
  278. zfs create ZPool-ZFS/ZBro
  279. zfs create ZPool-ZFS/ManArchive
  280. zfs create ZPool-ZFS/icons
  281. zfs create ZPool-ZFS/'b {Archive}'
  282.  
  283.  
  284. chgrp -hR xe1phix /mnt/ZPool-ZFS/Wordlists
  285.  
  286. chmod -v -R ugo+rwx /mnt/ZPool-ZFS && chown -v -R xe1phix /mnt/ZPool-ZFS
  287.  
  288. chmod -v ugo-x /mnt/ZPool-ZFS/Wordlists/
  289. chmod -v ugo+rw /mnt/ZPool-ZFS/Wordlists/
  290.  
  291. chmod -v ugo-x /mnt/ZPool-ZFS/OS
  292. chown -v -R xe1phix /mnt/ZPool-ZFS/OS
  293.  
  294. chmod -v ugo-x ZPool-ZFS/Pr0n
  295. chown -v -R xe1phix ZPool-ZFS/Pr0n
  296.  
  297. chmod -v ugo-x ZPool-ZFS/Audio
  298. chown -v -R xe1phix ZPool-ZFS/Audio
  299.  
  300. chmod -v ugo-x ZPool-ZFS/Scripts
  301. chown -v -R xe1phix ZPool-ZFS/Scripts
  302.  
  303. chmod -v ugo-x ZPool-ZFS/infosec
  304. chown -v -R xe1phix ZPool-ZFS/infosec
  305.  
  306. chmod -v ugo-x /mnt/ZPool-ZFS/OS
  307. chown -v -R xe1phix /mnt/ZPool-ZFS/OS
  308.  
  309.  
  310. chmod -v ugo-x /mnt/ZPool-ZFS/OS
  311. chown -v -R xe1phix /mnt/ZPool-ZFS/OS
  312.  
  313.  
  314. chmod -v ugo-x /mnt/ZPool-ZFS/OS
  315. chown -v -R xe1phix /mnt/ZPool-ZFS/OS
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326. zfs set checksum=sha256 ZPool-ZFS/Scripts
  327.  
  328. zfs set exec=off ZPool-ZFS/Scripts
  329. zfs set compression=zls ZPool-ZFS/Scripts
  330. zfs set zoned=on ZPool-ZFS/Scripts
  331. zfs set acltype=posixacl ZPool-ZFS/Scripts
  332. zfs set setuid=off ZPool-ZFS/Scripts
  333. zfs set vscan=on ZPool-ZFS/Scripts
  334. zfs allow -s ZPool-ZFS/Scripts
  335. zfs allow cindys create,destroy,mount,snapshot tank/cindys
  336.  
  337.  
  338. snapdir
  339. aclmode
  340. aclinherit
  341.  
  342.  
  343.  
  344. exec=off
  345. zoned=on
  346. aclmode=
  347. aclinherit=
  348. mlslabel=
  349.  
  350. zfs set sync=always
  351.  
  352.  
  353.  
  354. zfs set exec=off ZPool-ZFS/Xe1phixGitLab
  355. zfs set zoned=on ZPool-ZFS/Xe1phixGitLab
  356. zfs set exec=off ZPool-ZFS/BrowntownAlpha
  357. zfs set copies=2 ZPool-ZFS/Xe1phixGitLab
  358. zfs set exec=off ZPool-ZFS/Scripts
  359. zfs set readonly=on ZPool-ZFS/Scripts
  360. zfs set compression=on ZPool-ZFS/Scripts
  361. zfs set zoned=on ZPool-ZFS/Scripts
  362. zfs set compression=on ZPool-ZFS/Wordlists
  363.  
  364. zfs get compressratio
  365.  
  366. zfs set acltype=posixacl
  367.  
  368.  
  369.  
  370. zpool set comment="Contact Xe1phix@mail.i2p" ZPool-ZFS
  371. zpool get comment ZPool-ZFS
  372.  
  373. zfs set snapdir=visible ZPool-ZFS
  374.  
  375.  
  376. zpool list
  377.  
  378.  
  379. zpool export -f
  380. unmount -f
  381. --log-uberblocks
  382. --fuse-mount-options
  383. --enable-xattr
  384.  
  385. zfs userspace
  386. zfs userspace -n                ## Print numeric ID instead of user/group name.
  387. -t                      ## Print the type
  388. all,posixuser,smbuser,posixgroup,smbgroup
  389.  
  390. -o type,name,used,quota
  391.  
  392.  
  393. zfs groupspace -t posixgroup
  394.  
  395.  
  396.  
  397.  
  398. zfs allow perm|@setname[,...] filesystem|volume
  399. zfs allow -s @setname perm|@setname
  400.  
  401. zonecfg add fs
  402. zonecfg add dataset
  403. zonecfg add device
  404.  
  405. zfs mount
  406. zfs unmount
  407.  
  408.  
  409.  
  410.  
  411. zpool get health ZPool-ZFS
  412. zpool status -v ZPool-ZFS
  413. zpool status -x
  414. zpool status -T d 3 2
  415.  
  416. zpool history -l ZPool-ZFS
  417. zpool history -i ZPool-ZFS
  418.  
  419. zpool status ZPool-ZFS
  420. zpool get health ZPool-ZFS
  421. zpool get health,free,allocated ZPool-ZFS
  422. zpool get all ZPool-ZFS
  423. zfs list -t all -o name,used,refer,written
  424. zfs get used,available,compressratio ZPool-ZFS
  425.  
  426.  
  427. zfs create -V 1G tank/swap
  428. mkswap /dev/zvol/tank/swap
  429. swapon /dev/zvol/tank/swap
  430.  
  431. zpool create -f -m /mnt/ZPool-ZFS ZPool-ZFS /dev/sdc
  432. zfs set checksum=sha256 ZPool-ZFS                     ## Controls the checksum used to verify data integrity.
  433. zfs get checksum
  434.  
  435. zfs set xattr=on ZPool-ZFS
  436. zfs get xattr
  437.  
  438. zfs list -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild
  439. zfs list -o mountpoint,mounted,
  440. zfs list -o name,mounted
  441.  
  442.  
  443.  
  444. zfs create ZPool-ZFS/Xe1phixGitLab
  445. zfs get all ZPool-ZFS/Xe1phixGitLab
  446.  
  447. zfs set snapdir=visible ZPool-ZFS
  448.  
  449. sha256,verify
  450.  
  451.  
  452. copies=2
  453. compression=on
  454. compression=lzjb
  455.  
  456.  
  457. zfs snap ZPool-ZFS/Xe1phixGitLab@backup
  458. zfs list -t snapshot
  459.  
  460.  
  461. zfs snapshot -r ZPool-ZFS/Xe1phixGitLab@today
  462. zfs clone ZPool-ZFS/Xe1phixGitLab@today ZPool-ZFS/Xe1phixGitLabBackup
  463. zfs promote ZPool-ZFS/Xe1phixGitLabBackup
  464. zfs rename
  465.  
  466. ## reverts the contents of ZPool-ZFS/Audio
  467. ##   to the snapshot named yesterday
  468. zfs rollback -r ZPool-ZFS/Xe1phixGitLab@yesterday
  469. zfs snapshot -r ZPool-ZFS/Xe1phixGitLab@yesterday
  470.  
  471.  
  472. zfs get -r all
  473. zfs get -r -H all
  474.  
  475. name,property,value,source
  476.  
  477. echo "##-========================================================-##"
  478. echo "    [+] the corruption will be automatically be repaired,     "
  479. echo "        and noted in the status screen.                       "
  480. echo "##-========================================================-##"
  481.  
  482. echo "##-============================================================-##"
  483. echo "    [+] You can also initiate a manual scan                       "
  484. echo "        of all data on the drive to check for corruption:         "
  485. echo "##-============================================================-##"
  486. zpool scrub zfs
  487.  
  488.  
  489.  
  490. echo "##-==========================================================-##"
  491. echo "    [?] All storage is combined into a common pool              "
  492. echo "    [?] That is then used to create one or more datasets.       "
  493. echo "##-==========================================================-##"
  494.  
  495. echo "##-=====================================================================-##"
  496. echo "    [?] The zfs daemon can import and mount zfs pools automatically.       "
  497. echo "    [?] The daemon mounts the zfs pools reading the file:                  "
  498. echo "##-=====================================================================-##"
  499. /etc/zfs/zpool.cache
  500.  
  501. echo "##-====================================================-##"
  502. echo "    [+] For each pool you want automatically              "
  503. echo "        mounted by the zfs daemon execute:                "
  504. echo "##-====================================================-##"
  505. zpool set cachefile=/etc/zfs/zpool.cache ZPool-ZFS
  506.  
  507. zpool set cachefile=/var/lib/zfs/zpool.cache ZPool-ZFS
  508.  
  509. echo "##-====================================-##"
  510. echo "    [+] Adaptive Replacement Cache        "
  511. echo "##-====================================-##"
  512.  
  513. ## add an L2ARC to your existing zpool, we might do:
  514. zpool add ZPool-ZFS cache /tutorial/ssd
  515.  
  516.  
  517. echo "##-====================================================-##"
  518. echo "    [+] L2ARC is a caching "layer" between the RAM        "
  519. echo "##-====================================================-##"
  520. (very fast) and the disks (not so fast).
  521.  
  522.  
  523. zfs create -b 512 -o xattr=on -o checksum=sha256 -V 12G /dev/sdd
  524. fdisk /dev/tank/ext4
  525.  
  526. # mkfs.ext4 /dev/zd0p1
  527. # mkfs.ext4 /dev/zd0p2
  528. # mkdir /mnt/zd0p{1,2}
  529. # mount /dev/zd0p1 /mnt/zd0p1
  530. # mount /dev/zd0p2 /mnt/zd0p2
  531.  
  532. zfs mount ZPool-ZFS
  533. zfs mount -o rw ZPool-ZFS/BrowntownAlpha
  534. zfs mount -o remount,rw ZPool-ZFS/BrowntownAlpha
  535. zfs mount -o remount,ro ZPool-ZFS/Scripts
  536. zfs mount -O ZPool-ZFS/Xe1phixGitLab                   ## overlay mount
  537. zfs unmount ZPool-ZFS/Scripts
  538.  
  539. zfs get all
  540. zfs get all ZPool-ZFS
  541.  
  542. chmod -v ugo+rwx /mnt/ZPool-ZFS
  543.  
  544. zfs set compression=lzjb pool/ext4
  545. zfs snapshot tank/ext4@001
  546.  
  547. zfs create ZPool-ZFS/log
  548. zfs set exec=off ZPool-ZFS/log
  549. zfs set compression=lz4 ZPool-ZFS/log
  550. zfs get compressratio ZPool-ZFS/log
  551. zfs set dedup=on ZPool-ZFS/test
  552. zpool get dedupratio ZPool-ZFS
  553. zfs set xattr=on ZPool-ZFS
  554. zfs snapshot ZPool-ZFS/test@tuesday
  555. zfs set compression=lzjb ZPool-ZFS/dir@friday
  556.  
  557. echo "##-=============================-##"
  558. echo "    [+] Creating a bookmark:      "
  559. echo "##-=============================-##"
  560. zfs bookmark ZPool-ZFS/Xe1phixGitLab/GnuPG@snapshot zfs#bookmark
  561. zfs bookmark ZPool-ZFS/Xe1phixGitLab@snapshot zfs#bookmark
  562.  
  563. echo "##-=============================================-##"
  564. echo "    [+] list All bookmarks in the pool: "
  565. echo "##-=============================================-##"
  566. zfs list -t bookmark -r ZPool-ZFS
  567.  
  568.  
  569.  
  570.  
  571. zfs get mountpoint
  572. zfs get mounted
  573.  
  574. zfs set mountpoint=/mnt/ZPool-ZFS ZPool-ZFS/
  575.  
  576.  
  577. zfs set mountpoint=legacy ZPool-ZFS/dir/dir
  578. mount -F zfs ZPool-ZFS/dir/dir /mnt/ZPool-ZFS
  579.  
  580. zfs mount | grep ZPool-ZFS/dir
  581. zfs mount ZPool-ZFS/dir/dir
  582. mount -F zfs ZPool-ZFS/dir/dir
  583.  
  584. zfs mount -o ro ZPool-ZFS
  585. zfs mount -o remount,rw ZPool-ZFS
  586.  
  587. zfs unmount ZPool-ZFS/dir/dir
  588. zfs unmount -f ZPool-ZFS/dir/dir
  589. umount /mnt/ZPool-ZFS
  590.  
  591.  
  592.  
  593.  
  594. zfs set aclinherit=restricted
  595. zfs set aclinherit=
  596.  
  597. zfs set compression=lzjb
  598. zfs set compression=gzip
  599.  
  600. zfs set quota=50G ZPool-ZFS/$Dir
  601.  
  602. zfs set copies=2
  603.  
  604. zfs set exec=off ZPool-ZFS/Scripts
  605. zfs set readonly=on ZPool-ZFS/
  606. zfs set vscan=on ZPool-ZFS/
  607. zfs set xattr=on ZPool-ZFS
  608.  
  609.  
  610.  
  611. zfs set snapdir=visible ZPool-ZFS/
  612. zfs list -t snapshot
  613. zfs list -r -t snapshot ZPool-ZFS
  614.  
  615. zfs clone ZPool-ZFS/test@tuesday ZPool-ZFS/tuesday
  616. dd if=/dev/zero of=/tank/tuesday/random.img bs=1M count=100
  617. zfs list -r ZPool-ZFS
  618.  
  619. zpool status
  620. zpool status -v
  621. zfs get all ZPool-ZFS
  622. zfs list -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild
  623.  
  624. zfs list -t filesystem,volume,all
  625. modprobe zfs
  626.  
  627. /etc/modprobe.d/zfs.conf
  628. ## --------------------------------------------------------------------------------------------------------------- ##
  629.     options scsi_mod scan=sync
  630. ## --------------------------------------------------------------------------------------------------------------- ##
  631.  
  632. /etc/fstab
  633. ## --------------------------------------------------------------------------------------------------------------------- ##
  634.     /mnt/zfspool        /srv/nfs4/music     none    bind,defaults,nofail,x-systemd.requires=zfs-mount.service   0 0
  635. ## --------------------------------------------------------------------------------------------------------------------- ##
  636.  
  637.  
  638. systemctl enable zfs.target
  639. systemctl start zfs.target
  640.  
  641. systemctl enable zfs-import-cache
  642. systemctl enable zfs-mount
  643. systemctl enable zfs-import.target
  644.  
  645.  
  646. echo "##-============================================-##"
  647. echo "           [+] use ACL on a ZFS pool:             "
  648. echo "##-============================================-##"
  649. zfs set acltype=posixacl <nameofzpool>/<nameofdataset>
  650. zfs set xattr=sa <nameofzpool>/<nameofdataset>
  651. zfs set acltype=posixacl rpool/vztmp
  652.  
  653.  
  654. zfs set dedup=verify
  655. zfs set checksum=sha256,verify
  656.  
  657. zfs get checksum
  658. zfs set checksum=sha256 tank
  659.  
  660. zfs set xattr=on ZPool-ZFS
  661.  
  662. zfs set mountpoint=/mnt/ZPool-ZFS ZPool-ZFS
  663.  
  664. zfs create ZPool-ZFS/log
  665.  
  666.  
  667.  
  668.  
  669. zfs set compression=on ZPool-ZFS/
  670. zfs create -o compression=gzip tank/test/one
  671.  
  672. -o feature@sha512=enabled
  673. -o primarycache=metadata
  674. -o logbias=throughput
  675.  
  676. zfs set quota=20G <nameofzpool>/<nameofdataset>/<directory>
  677.  
  678. zfs set sync=disabled <pool>/tmp
  679.  
  680.  
  681. zpool add <pool> log <device-id>
  682. zpool add <pool> log mirror <device-id-1> <device-id-2>
  683.  
  684.  
  685. zfs set setuid=off <pool>/tmp
  686. zfs set devices=off <pool>/tmp
  687.  
  688.  
  689. zfs create -o setuid=off -o devices=off -o sync=disabled -o mountpoint=/tmp <pool>/tmp
  690.  
  691.  
  692.  
  693.  
  694. systemctl mask tmp.mount
  695.  
  696.  
  697. zfs create -o encryption=on -o keyformat=passphrase <nameofzpool>/<nameofdataset>
  698.  
  699. echo "##-=============================================================================-##"
  700. echo "           [+] use a key instead of using a passphrase:                           "
  701. echo "##-=============================================================================-##"
  702.  
  703. dd if=/dev/urandom of=/path/to/key bs=1 count=32
  704. zfs create -o encryption=on -o keyformat=raw -o keylocation=file:///path/to/key <nameofzpool>/<nameofdataset>
  705.  
  706. echo "##-=============================================================================-##"
  707. echo "           [+] manually load the keys and then mount the encrypted dataset:       "
  708. echo "##-=============================================================================-##"
  709.  
  710. zfs load-key <nameofzpool>/<nameofdataset>      # load key for a specific dataset
  711. zfs load-key -a                                   # load all keys
  712. zfs load-key -r zpool/dataset                   # load all keys in a dataset
  713.  
  714.  
  715. zpool import -l pool
  716.  
  717. echo "##-=============================================================================-##"
  718. echo "           [+] automate this at boot with a custom systemd unit:                  "
  719. echo "##-=============================================================================-##"
  720.  
  721. /etc/systemd/system/zfs-key@.service
  722.  
  723. [Unit]
  724. Description=Load storage encryption keys
  725. DefaultDependencies=no
  726. Before=systemd-user-sessions.service
  727. Before=zfs-mount.service
  728.  
  729. [Service]
  730. Type=oneshot
  731. RemainAfterExit=yes
  732. ExecStart=/usr/bin/bash -c 'systemd-ask-password "Encrypted storage password (%i): " | /usr/bin/zfs load-key zpool/%i'
  733.  
  734. [Install]
  735. WantedBy=zfs-mount.service
  736.  
  737.  
  738.  
  739.  
  740. echo "##-=============================================================================-##"
  741. echo "                      [+] Create an encrypted home:                               "
  742. echo "      (the two passwords, encryption and login, must be the same)                 "
  743. echo "##-=============================================================================-##"
  744.  
  745. zfs create -o compression=off -o dedup=off -o mountpoint=/home/<username> <zpool>/<username>
  746. useradd -m <username>
  747. passwd <username>
  748. ecryptfs-migrate-home -u <username>
  749.  
  750. echo "##-=============================================================================-##"
  751. echo "    [+] <log in user and complete the procedure with ecryptfs-unwrap-passphrase>    "
  752. echo "##-=============================================================================-##"
  753.  
  754.  
  755.  
  756. zfs snapshot ZPool-ZFS/project/production@today
  757.  
  758. zfs rollback -r ZPool-ZFS/home/anne@yesterday
  759.  
  760.  
  761. zfs clone ZPool-ZFS/home/bob@yesterday ZPool-ZFS/clone
  762.  
  763. zfs inherit checksum ZPool-ZFS/home/bob ZPool-ZFS/home/anne
  764.  
  765.  
  766. zfs allow cindys create,destroy,mount,snapshot
  767. zfs allow -s @pset create,destroy,snapshot,mount ZPool-ZFS/users
  768.  
  769. chmod A+user:cindys:add_subdirectory:allow /tank/cindys
  770.  
  771.  
  772. zfs allow staff create,mount ZPool-ZFS/users
  773.  
  774. zfs allow -c destroy ZPool-ZFS/users
  775.  
  776.  
  777.  
  778. echo "##-=============================================================================-##"
  779. echo "           [+] ZFS pools should be scrubbed at least once a week:                 "
  780. echo "##-=============================================================================-##"
  781.  
  782. zpool scrub ZPool-ZFS
  783.  
  784. echo "##-=============================================================================-##"
  785. echo "           [+] automatic scrubbing once a week, add this to crontab:                  "
  786. echo "##-=============================================================================-##"
  787.  
  788. crontab -e
  789.  
  790.  
  791.  
  792. 30 19 * * 5 zpool scrub ZPool-ZFS
  793.  
  794.  
  795. ## scrub every Sunday at 02:00 in the morning:
  796. 0 2 * * 0 /sbin/zpool scrub ZPool-ZFS
  797.  
  798.  
  799.  
  800. zpool get listsnapshots
  801. zpool set listsnapshots=on ZPool-ZFS
  802.  
  803.  
  804. ls /tank/home/cindy/.zfs/snapshot
  805. zfs list -t snapshot -r ZPool-ZFS/dir
  806.  
  807. zfs list -r -t snapshot -o name,creation ZPool-ZFS/Xe1phixGitLab
  808.  
  809. zfs list -o space -r ZPool-ZFS
  810.  
  811. zfs snapshot ZPool-ZFS/Xe1phixGitLab@yesterday
  812. zfs clone ZPool-ZFS/Xe1phixGitLab@yesterday
  813.  
  814. zfs snapshot ZPool-ZFS/Xe1phixGitLab@today
  815. zfs clone ZPool-ZFS/Xe1phixGitLab@today
  816.  
  817. zfs clone ZPool-ZFS/Xe1phixGitLab@yesterday zfs/Xe1phixGitLab-backup
  818.  
  819. echo "##-=============================================================================-##"
  820. echo "           [+] Create snapshots for all descendent file systems (-r ):            "
  821. echo "##-=============================================================================-##"
  822.  
  823. zfs snapshot -r ZPool-ZFS/dir@snap1
  824. zfs list -t snapshot -r ZPool-ZFS/dir
  825.  
  826. zfs set compression=on ZPool-ZFS/dir/dir@friday
  827.  
  828. zfs snapshot -r ZPool-ZFS/dir/dir@now
  829. zfs hold -r keep ZPool-ZFS/dir/dir@now
  830.  
  831. zfs holds -r ZPool-ZFS/dir/dir@now
  832. zfs release -r keep ZPool-ZFS/dir/dir@now
  833. zfs destroy -r ZPool-ZFS/dir/dir@now
  834.  
  835. zfs rename ZPool-ZFS/dir/dir@snap1 ZPool-ZFS/dir/dir@today
  836. zfs rename ZPool-ZFS/dir/dir@snap1 today
  837. zfs rename -r ZPool-ZFS/home@yesterday @2daysago
  838.  
  839. zfs list -t snapshot -r ZPool-ZFS/dir
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. echo "##-=================================-##"
  863. echo "    [+] This is a local backup:        "
  864. echo "##-=================================-##"
  865. zfs snapshot ZPool-ZFS/myfiles@backup
  866. zfs send ZPool-ZFS/myfiles@backup > /mnt/filesystem-backup
  867.  
  868.  
  869. echo "##-=============================================-##"
  870. echo "    [+] Restore the backup from the file:          "
  871. echo "##-=============================================-##"
  872. zfs receive -v ZPool-ZFS/myfiles < /mnt/filesystem-backup
  873.  
  874.  
  875.  
  876. echo "##-============================================-##"
  877. echo "    [+] Copy that snapshot to a remote server:     "
  878. echo "##-============================================-##"
  879. zfs send ZPool-ZFS/myfiles@backup | ssh you@remoteserver zfs receive -v otherpool/myfiles
  880.  
  881.  
  882. echo "##-=====================================================================-##"
  883. echo "    [+] Its also possible to do incremental data (changes to snapshot):    "
  884. echo "##-=====================================================================-##"
  885. zfs send -i ZPool-ZFS/myfiles@backup ZPool-ZFS/myfiles@laterbackup | ssh you@remoteserver zfs receive -v otherpool/myfiles
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894. zfs send ZPool-ZFS/test@tuesday | xz | openssl enc -aes-256-cbc -a -salt > /backup/test-tuesday.img.xz.asc
  895.  
  896.  
  897. zfs send ZPool-ZFS/test@tuesday | xz > /backup/test-tuesday.img.xz
  898.  
  899.  
  900. zfs receive ZPool-ZFS/test2 < /backup/test-tuesday.img
  901.  
  902.  
  903. openssl enc -d -aes-256-cbc -a -in /storage/temp/testzone.gz.ssl | unxz | zfs receive ZPool-ZFS/test2
  904.  
  905.  
  906. zfs send ZPool-ZFS/test@tuesday | zfs receive ZPool-ZFS/test
  907.  
  908.  
  909. zfs send ZPool-ZFS/test@tuesday | ssh user@server.example.com "zfs receive ZPool-ZFS/test"
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924. echo "##-=====================================================================-##"
  925. echo "    [+] rename the zfs/olddata dataset "
  926.  
  927. to reflect that its an old copy of the data
  928.  
  929. zfs rename ZPool-ZFS/newdata ZPool-ZFS/olddata
  930.  
  931. zfs rename
  932.  
  933. zfs set quota=5G
  934.  
  935.  
  936. zfs get reservation
  937. zfs set reservation=5G ZPool-ZFS/dir/dir
  938. zfs set reservation=10G ZPool-ZFS/dir/dir
  939.  
  940.  
  941. zfs set refreservation=10g ZPool-ZFS/dir/dir
  942.  
  943. zfs get reservation,refreserv
  944.  
  945.  
  946. zfs set dept:users=xe1phix ZPool-ZFS/user1
  947. zfs set dept:users=log ZPool-ZFS/user2
  948. zfs set dept:users=scripts ZPool-ZFS/user3
  949. zfs set dept:users=scripts ZPool-ZFS/user3
  950. zfs set dept:users=Pr0n ZPool-ZFS/Pr0n
  951. zfs set dept:users=webm ZPool-ZFS/BrowntownAlpha/AnonOS/4chan/webm-2.0
  952. BrowntownAlpha
  953. OS
  954. VirtualBox VMs
  955. zfs set dept:users= ZPool-ZFS/Xe1phixGitLab/GnuPG
  956. /Xe1phixGitLab/Xe1phix-Firejail
  957.  
  958. GnuPG-CryptoPartyWorkshop
  959. Xe1phixGitLabProjects
  960. ZPool-ZFS/Xe1phixGitLab/Xe1phixGitLabProjects/Stable/ParrotLinux-Public-Kios-Project
  961. echo "##-===============================================================-##"
  962. echo "           [+] clear a user property, use zfs inherit:            "
  963. echo "##-===============================================================-##"        
  964. zfs inherit -r dept:users ZPool-ZFS
  965.  
  966.  
  967.  
  968. zfs get -r dept:users ZPool-ZFS/dir
  969.  
  970.  
  971.  
  972. echo "##-=====================================================================-##"
  973. echo "    [+] Controls  whether regular files should be scanned for viruses
  974. when a file is opened and closed
  975. vscan=on
  976.  
  977.  
  978.  
  979.  
  980. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##"
  981. echo "                                                  "
  982. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##"
  983.  
  984. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=##"
  985. echo "                                                                          "
  986. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=##"
  987.          
  988.  
  989.  
  990.  
  991.  
  992. echo "##-================================================================================================-##"
  993. echo "     [?] the contents of highly-compressible blocks are stored in the $Block_Pointer itself          "
  994. echo "         (it contains the compresseed data, rather than a pointer to its location on disk).           "
  995. echo "         Thus the space of the block (one sector, typically 512 bytes or 4KB)                         "
  996. echo "         is saved, and no additional i/o is needed to read and write the data block.                  "
  997. echo "##-================================================================================================-##"
  998.  
  999.  
  1000.  
  1001. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##"
  1002. echo "                             [+]  Deduplication                                   "
  1003. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##"
  1004. echo "##-===========================================================================-##"
  1005. echo "     [?] deduplication allows you to store the same data multiple times,         "
  1006. echo "              but only take up the space of a single copy.                       "
  1007. echo "## --------------------------------------------------------------------------- ##"
  1008. echo "     [?] Data can be deduplicated on the file, block, or byte level              "
  1009. echo "##-===========================================================================-##"
  1010.  
  1011.  
  1012. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=##"
  1013. echo "                                 File deduplication                                         "
  1014. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=##"
  1015. echo "##-========================================================================================-##"
  1016. echo "      Each file is hashed with a cryptographic hashing algorithm, such as SHA-256.            "
  1017. echo "      If the hash matches for multiple files, rather than storing the new file on disk,       "
  1018. echo "      We reference the original file in the metadata.                                         "
  1019. echo "      If a single bytechanges in the file, the hashes will no longer match.                   "
  1020. echo "      This means we can no longer reference the whole file in the filesystem metadata.        "
  1021. echo "##-========================================================================================-##"
  1022.  
  1023.  
  1024.  
  1025.  
  1026. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=##"
  1027. echo "                                    byte deduplication                                         "
  1028. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=##"
  1029. echo "##-========================================================================================-##"
  1030. echo "            "
  1031. echo "            "
  1032. echo "            "
  1033. echo "            "
  1034. echo "            "
  1035. echo "##-========================================================================================-##"
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##"
  1042. echo "                                            block deduplication                                               "
  1043. echo "##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~##"
  1044. echo "##-=========================================================================================================-##"
  1045. echo "      Block deduplication shares all the same blocks in a file, minus the blocks that are different.           "
  1046. echo "      This allows us to store only the unique blocks on disk, and reference the shared blocks in RAM.          "
  1047. echo "      because filesystems read and write data in block segments,                                               "
  1048. echo "      it makes the most sense to use block deduplication for a modern filesystem.                              "
  1049. echo "      The shared blocks are stored in whats called a "deduplication table".                                    "
  1050. echo "##-=========================================================================================================-##"
  1051.  
  1052.  
  1053.  
  1054.  
  1055. zfs set dedup=on
  1056. zpool get dedupratio
  1057.  
  1058.  
  1059.  
  1060.  
  1061. echo "##-=========================================================-##"
  1062. echo "     [?] If youre paranoid about hash collisions,             "
  1063. echo "         you might want to use extra verification             "
  1064. echo "##-=========================================================-##"
  1065.  
  1066. zfs set dedup=verify ZPool-ZFS/
  1067. zfs set checksum=sha256,verify ZPool-ZFS/
  1068.  
  1069.  
  1070. parted /dev/sda mklabel gpt mkpart primary zfs 0 5G
  1071. parted /dev/sdb mklabel gpt mkpart primary zfs 0 5G
  1072. zpool add tank log mirror /dev/disk/by-id/ata-OCZ-REVODRIVE_OCZ-69ZO5475MT43KNTU-part1 /dev/disk/by-id/ata-OCZ-REVODRIVE_OCZ-9724MG8BII8G3255-part1
  1073.  
  1074.  
  1075. zpool add pool log mirror ata-OCZ-REVODRIVE_OCZ-33W9WE11E9X73Y41-part1 ata-OCZ-REVODRIVE_OCZ-X5RG0EIY7MN7676K-part
  1076. zpool add pool cache ata-OCZ-REVODRIVE_OCZ-33W9WE11E9X73Y41-part2 ata-OCZ-REVODRIVE_OCZ-X5RG0EIY7MN7676K-part2
  1077.  
  1078. zfs set secondarycache=metadata pool
  1079. zpool add -f pool cache usb-Kingston_DataTraveler_G3_0014780D8CEBEBC145E80163-0:0\
  1080.  
  1081.  
  1082. zpool add zfs cache ZPool-ZFS/
  1083. zpool add zfs log ZPool-ZFS/
  1084. zpool add zfs log mirror /tutorial/file7 /tutorial/file8
  1085.  
  1086.  
  1087. zpool set autoexpand=on
  1088.  
  1089. zfs rename ZPool-ZFS/Temp ZPool-ZFS/Pr0n
  1090. zfs destroy ZPool-ZFS/Scripts
  1091.  
  1092. zfs set copies=2 ZPool-ZFS/
  1093.  
  1094. zfs set compression=gzip
  1095.  
  1096. zfs umount ZPool-ZFS/
  1097.  
  1098. echo "##-===============================================================-##"
  1099. echo "              [+] To restore the backup from a file:                  "
  1100. echo "##-===============================================================-##"
  1101. zfs receive -v mypool/myfiles < /mnt/filesystem-backup
  1102.  
  1103.  
  1104. echo "##-===============================================================-##"
  1105. echo "           [+] copy the snapshot to a remote server (offsite backup)."
  1106. echo "##-===============================================================-##"
  1107. zfs send ZPool-ZFS/myfiles@backup | ssh you@remoteserver zfs receive -v otherpool/myfiles
  1108.  
  1109.  
  1110.  
  1111. zpool create zfs_test mirror /var/lib/zfs_img/zfs0.img /var/lib/zfs_img/zfs1.img
  1112.  
  1113. echo "##-===============================================================-##"
  1114. echo "           [+] Create a pool with RAIDZ1 and three hard drives:      "
  1115. echo "##-===============================================================-##"
  1116. zpool create zfs_test raidz1 /var/lib/zfs_img/zfs0.img /var/lib/zfs_img/zfs1.img /var/lib/zfs_img/zfs2.img
  1117.  
  1118.  
  1119. echo "##-=========================================================-##"
  1120. echo "     [+] create a pool with RAIDZ2 and four hard drives:   "
  1121. echo "##-=========================================================-##"
  1122. zpool create zfs_test raidz2 /var/lib/zfs_img/zfs0.img /var/lib/zfs_img/zfs1.img /var/lib/zfs_img/zfs2.img /var/lib/zfs_img/zfs3.img
  1123.  
  1124.  
  1125. echo "##-============================================================-##"
  1126. echo "    [+] Create a STRIPED MIRRORED pool with four hard drives:     "
  1127. echo "##-============================================================-##"
  1128. zpool create zfs_test mirror /var/lib/zfs_img/zfs0.img /var/lib/zfs_img/zfs1.img mirror /var/lib/zfs_img/zfs2.img /var/lib/zfs_img/zfs3.img
  1129.  
  1130.  
  1131. echo "##-=====================================================================-##"
  1132. echo "    [+] To grow a mirror, expansion will need to be set on the pool.      "
  1133. echo "##-=====================================================================-##"
  1134. zpool set autoexpand=on ZPool-ZFS
  1135.  
  1136.  
  1137.  
  1138.  
  1139. zfs set snapdir=visible ZPool-ZFS/
  1140.  
  1141. zfs list -t snapshot -o name,creation
  1142.  
  1143.  
  1144. echo "##-=====================================================================-##"
  1145. echo "    [+] ZFS can clone snapshots to new volumes,                           "
  1146. echo "        so you can access the files from previous states individually:    "
  1147. echo "##-=====================================================================-##"
  1148. man zfs clone zfs_test/volume1@21082011 zfs_test/volume1_restore
  1149.  
  1150.  
  1151. zpool history
  1152.  
  1153.  
  1154. echo "##-=====================================================================-##"
  1155. echo "    [+] Monitor I/O activity on all zpools (refreshes every 6 seconds):    "
  1156. echo "##-=====================================================================-##"
  1157.  
  1158. zpool iostat 6
  1159.  
  1160. zpool iostat ZPool-ZFS 2
  1161.  
  1162. zpool iostat -v
  1163.  
  1164. echo "##-=============================================-##"
  1165. echo "    [+] refreshes every 4 secs, 5 intervals:      "
  1166. echo "##-=============================================-##"
  1167. zpool iostat ZPool-ZFS -v 4 5
  1168.  
  1169.  
  1170.  
  1171.  
  1172. zfs diff -e ZPool-ZFS/cindy@yesterday ZPool-ZFS/cindy@now
  1173.  
  1174.  
  1175. zfs diff -e -o size -o name ZPool-ZFS/cindy@yesterday ZPool-ZFS/cindy@now
  1176.  
  1177.  
  1178. zpool export ZPool-ZFS
  1179.  
  1180.  
  1181. zpool import
  1182.  
  1183.  
  1184. zpool create dozer mirror /file/a /file/b
  1185. zpool export dozer
  1186. zpool import -d /file
  1187. zpool import -d /file dozer
  1188.  
  1189. echo "##-============================================-##"
  1190. echo "    [+] Importing a Pool in Read-Only Mode        "
  1191. echo "##-============================================-##"
  1192. zpool import -o readonly=on
  1193.  
  1194.  
  1195.  
  1196. zfs rollback ZPool-ZFS/home/cindy@tuesday
  1197. zfs rollback -r ZPool-ZFS/home/cindy@tuesday
  1198.  
  1199. zfs list -r -t snapshot -o name,creation tank/home/cindy
  1200.  
  1201. zfs snapshot ZPool-ZFS/Xe1phixGitLab@snap1
  1202. zfs snapshot ZPool-ZFS/Xe1phixGitLab@snap2
  1203.  
  1204. zfs diff ZPool-ZFS/Xe1phixGitLab@snap1 ZPool-ZFS/Xe1phixGitLab@snap2
  1205.  
  1206.  
  1207.  
  1208.  
  1209. echo "##-============================================================-##"
  1210. echo "    [+] Copy the partition table from /dev/sda to /dev/sdb:       "
  1211. echo "##-============================================================-##"
  1212. sgdisk --replicate=/dev/sdb /dev/sda
  1213.  
  1214.  
  1215. echo "##-==============================================================-##"
  1216. echo "    [?] Ensure the GUIDs are randomized otherwise the kernel        "
  1217. echo "        and ZFS will get really, really confused:                   "
  1218. echo "##-==============================================================-##"
  1219. sgdisk --randomize-guids /dev/sdb
  1220.  
  1221.  
  1222.  
  1223. zfs list -r ZPool-ZFS/
  1224.  
  1225.  
  1226.  
  1227. @eng (create, destroy, snapshot, mount, clone, promote, rename)
  1228. @simple (create, mount)
  1229.  
  1230.  
  1231. zfs allow staff create,mount ZPool-ZFS/home
  1232. zfs allow -c create,destroy ZPool-ZFS/home
  1233. zfs allow -c destroy,snapshot ZPool-ZFS/home
  1234.  
  1235. zfs allow -s @myset create,destroy,mount,snapshot,promote,clone,readonly ZPool-ZFS
  1236. zfs allow ZPool-ZFS
  1237. zfs allow staff @myset,rename ZPool-ZFS/home
  1238. zfs allow ZPool-ZFS/home
  1239.  
  1240. chmod A+group:staff:add_subdirectory:fd:allow ZPool-ZFS
  1241.  
  1242. zfs unallow cindy snapshot ZPool-ZFS/home/dir
  1243.  
  1244. zfs snapshot ZPool-ZFS/@today
  1245.  
  1246.  
  1247. zfs allow ZPool-ZFS
  1248. ## -------------------------------------------------------------------##
  1249. ## Permission sets:
  1250. ##      @myset clone,create,destroy,mount,promote,readonly,snapshot
  1251. ## Create time permissions:
  1252. ##      create,destroy,mount
  1253. ## Local+Descendent permissions:
  1254. ##      group staff create,mount
  1255. ## -------------------------------------------------------------------##
  1256. zfs unallow -s @myset ZPool-ZFS
  1257. zfs allow ZPool-ZFS
  1258.  
  1259.  
  1260. zfs list -o name,zoned,mountpoint -r
  1261.  
  1262. zpool get delegation ZPool-ZFS
  1263. zpool set delegation=on ZPool-ZFS
  1264.  
  1265. echo "##-=====================================================================-##"
  1266. echo "    [?] Controls whether a non-privileged user is granted access based     "
  1267. echo "        on the dataset permissions defined on the dataset.                 "
  1268. echo "##-=====================================================================-##"
  1269. delegation=on
  1270.  
  1271.  
  1272.  
  1273.  
  1274. chmod [options] A[index]{+|=}owner@ |group@
  1275. |everyone@:access-permissions/...[:inheritance-flags]:deny | allow file
  1276. chmod [options] A-owner@, group@,
  1277. everyone@:access-permissions/...[:inheritance-flags]:deny | allow file ...
  1278.  
  1279. chmod [options]
  1280. A[index]{+|=}user|group:name:access-permissions/...[:inheritance-flags]:deny | allow file
  1281. chmod [options] A-user|group:name:access-permissions/...[:inheritance-flags]:deny |
  1282. allow file ...
  1283.  
  1284.  
  1285. owner@, group@, everyone@
  1286.  
  1287. echo "##-=====================================================================-##"
  1288. echo "    [+] Identifies the ACL-entry-type for trivial ACL syntax.              "
  1289. echo "##-=====================================================================-##"
  1290.  
  1291.  
  1292. echo "##-=====================================================================-##"
  1293. echo "    [+] user or group:ACL-entry-ID=username or groupname                   "
  1294. echo "##-----------------------------------------------------------------------##"
  1295. echo "    [+] Identifies the ACL-entry-type For explicit ACL syntax.             "
  1296. echo "##-----------------------------------------------------------------------##"
  1297. echo "    [+] The user and group ACL-entry-type must also contain                "
  1298. echo "##-----------------------------------------------------------------------##"
  1299. echo "    [+] the ACL-entry-ID, username or groupname                            "
  1300. echo "##-=====================================================================-##"
  1301.  
  1302. access-permissions/.../ Identifies the access permissions that are granted or denied.
  1303.  
  1304. inheritance-flags       Identifies an optional list of ACL inheritance flags.
  1305.  
  1306. deny | allow            Identifies whether the access permissions are granted or denied
  1307.  
  1308.  
  1309.  
  1310.  
  1311. echo "#+===========+#                                                                                      "
  1312. echo " |           |-===================================================================================-##"
  1313. echo " |    owner@ |    The $Owner can $Read and $Modify the contents of the $file                         "
  1314. echo " |           |     (rw=read_data/write_data), (p=append_data)                                        "
  1315. echo " |-----------|-------------------------------------------------------------------------------------##"
  1316. echo " |           |     The $Owner can also $Modify the Files $Attributes such as                         "            
  1317. echo " |           |     [$Timestamps, Extended Attributes (xattr), and $ACLs]                             "
  1318. echo " |           |     [a=Read_Attributes, W=Write_xattr, R=Read_xattr]                                  "
  1319. echo " |           |     [A=Write_Attributes, c=Read_Acl, C=Write_Acl]                                     "
  1320. echo " |-----------|-------------------------------------------------------------------------------------##"
  1321. echo " |           |     In addition, the $owner can $modify                                               "
  1322. echo " |           |     the $ownership of the $file (o=write_owner).                                      "
  1323. echo " |-=========-|-===================================================================================-##"
  1324. echo " |    group@ |    The group is granted $Read permissions to the $File (r=read_data)                  "
  1325. echo " | =====     |     As well as the $files $attributes                                                 "
  1326. echo " |      \___ |     (a=read_attributes, R=read_xattr, c=read_acl).                                    "
  1327. echo " | ========= |-===================================================================================-##"
  1328. echo " | everyone@ |    Everyone who is not user or group is granted read permissions                      "
  1329. echo " | ====      |    to the file and the files attributes                                               "
  1330. echo " |     \_    |    (r=read_data, a=append_data, R=read_xattr, c=read_acl,and s=synchronize).          "
  1331. echo " |       \__ |-===================================================================================-##"
  1332. echo "#+===========+#                                                                                       "
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338. chmod A1=group@:read_data/write_data:allow file
  1339.  
  1340.     0:owner@:read_data/write_data/append_data/read_xattr/write_xattr/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1341.     1:group@:read_data/write_data:allow
  1342.     2:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1343.  
  1344.  
  1345. chmod 644 file
  1346.  
  1347.     0:owner@:read_data/write_data/append_data/read_xattr/write_xattr/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1348.     1:group@:read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1349.     2:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1350.  
  1351.  
  1352.  
  1353. echo "##-============================================================-##"
  1354. echo "    [+] read_data/execute permissions are added for the user      "
  1355. echo "##-============================================================-##"
  1356.  
  1357. chmod A+user:gozer:read_data/execute:allow test.dir
  1358.  
  1359.     0:user:gozer:list_directory/read_data/execute:allow
  1360.     1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1361.     2:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1362.     3:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1363.  
  1364.  
  1365.  
  1366. echo "##-============================================================-##"
  1367. echo "    [+] read_data/execute permissions are removed for user        "
  1368. echo "##-============================================================-##"
  1369.  
  1370. chmod A0- test.dir
  1371.  
  1372.     0:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1373.     1:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1374.     2:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1375.  
  1376.  
  1377.  
  1378. echo "##-============================================================-##"
  1379. echo "    [+] ACL allow permissions are removed from everyone@          "
  1380. echo "##-============================================================-##"
  1381.  
  1382. chmod A2- file
  1383.  
  1384.     0:owner@:read_data/write_data/append_data/read_xattr/write_xattr/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1385.     1:group@:read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1386.  
  1387.  
  1388.  
  1389. echo "##-============================================-##"
  1390. echo "    [+] the existing ACL is replaced with         "
  1391. echo "        read_data/write_data permissions          "
  1392. echo "              for everyone@.                      "
  1393. echo "##-============================================-##"
  1394.  
  1395. chmod A=everyone@:read_data/write_data:allow file
  1396.  
  1397.     0:everyone@:read_data/write_data:allow
  1398.  
  1399.  
  1400.  
  1401. echo "##-=====================================================================-##"
  1402. echo "    [+] the existing ACL is replaced with read permissions for user        "
  1403. echo "##-=====================================================================-##"
  1404.  
  1405. chmod A=user:gozer:read_data:allow file
  1406.  
  1407.     0:user:gozer:read_data:allow
  1408.  
  1409.  
  1410. chmod 655 file
  1411.  
  1412.     0:owner@:execute:deny
  1413.     1:owner@:read_data/write_data/append_data/read_xattr/write_xattr/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1414.     2:group@:read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1415.     3:everyone@:read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1416.  
  1417.  
  1418.  
  1419.  
  1420. echo "##-=========================================================-##"
  1421. echo "    [+] read_data/write_data permissions are added             "
  1422. echo "        to files in the test2.dir directory.                   "
  1423. echo "        This is done for user gozer so that he has             "
  1424. echo "        read access on any newly created files.                "
  1425. echo "##-=========================================================-##"
  1426.  
  1427. chmod A+user:gozer:read_data/write_data:file_inherit:allow test2.dir
  1428.  
  1429.     0:user:gozer:list_directory/read_data/add_file/write_data/execute:allow
  1430.     1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1431.     2:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1432.     3:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1433.  
  1434.  
  1435.  
  1436.  
  1437. echo "##-========================================================-##"
  1438. echo "    [+] a non-trivial ACE of read_data/write_data/execute     "
  1439. echo "        is applied for user gozer on test.dir.                "
  1440. echo "##-========================================================-##"
  1441.  
  1442. chmod A+user:gozer:read_data/write_data/execute:allow test.dir
  1443.  
  1444.     0:user:gozer:read_data/write_data:file_inherit:allow
  1445.     1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1446.     2:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1447.     3:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1448.  
  1449.  
  1450.  
  1451.  
  1452. echo "##-=====================================================================-##"
  1453. echo "    [+] user gozer is granted read, write, and execute permissions        "
  1454. echo "        that are inherited for newly created files and directories.       "
  1455. echo "##-====================================================================-##"
  1456.  
  1457. chmod A+user:gozer:read_data/write_data/execute:file_inherit/dir_inherit:allow
  1458.  
  1459.  
  1460.     0:user:gozer:list_directory/read_data/add_file/write_data/execute:file_inherit/dir_inherit:allow
  1461.     1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1462.     2:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1463.     3:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1464.  
  1465.  
  1466. echo "##-======================================================================-##"
  1467. echo "    [+] user gozer is granted read, write, and execute permissions          "
  1468. echo "        that are inherited for newly created files,                         "
  1469. echo "    [?] but are not propagated to subsequent contents of the directory.     "
  1470. echo "##-======================================================================-##"
  1471.  
  1472. chmod A+user:gozer:read_data/write_data/execute:file_inherit/no_propagate:allow test4.dir
  1473.  
  1474.     0:user:gozer:list_directory/read_data/add_file/write_data/execute:file_inherit/no_propagate:allow
  1475.     1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1476.     2:group@:list_directory/read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1477.     3:everyone@:list_directory/read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1478.  
  1479.  
  1480.  
  1481.  
  1482. echo "##-=====================================================================-##"
  1483. echo "    [+] ACL Inheritance With ACL Inherit Mode Set to Pass Through     "
  1484. echo "##-=====================================================================-##"
  1485.  
  1486. echo "##-============================================================-##"
  1487. echo "    [+] If the aclinherit property on the tank/cindy              "
  1488. echo "        file system is set to passthrough.                        "
  1489. echo "        then user gozer would inherit the ACL applied             "
  1490. echo "        on test4.dir for the newly created file                   "
  1491. echo "##-============================================================-##"
  1492.  
  1493.  
  1494.  
  1495.  
  1496. zfs set aclinherit=passthrough ZPool-ZFS/dir
  1497.  
  1498. 0:user:gozer:read_data:allow
  1499. 1:owner@:read_data/write_data/append_data/read_xattr/write_xattr/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1500. 2:group@:read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1501. 3:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize:allow
  1502.  
  1503.  
  1504.  
  1505. echo "##-=====================================================================-##"
  1506. echo "    [+] ACL Inheritance With ACL Inherit Mode Set to Discard                  "
  1507. echo "##-===============================================================-##"
  1508.  
  1509.  
  1510. zfs set aclinherit=discard tank/cindy
  1511. chmod A+user:gozer:read_data/write_data/execute:dir_inherit:allow test5.dir
  1512.  
  1513. 0:user:gozer:list_directory/read_data/add_file/write_data/execute:dir_inherit:allow
  1514. 1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1515. 2:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1516. 3:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. aclinherit=discard | noallow | restricted | passthrough | passthrough-x
  1523.  
  1524.      noallow           only inherits inheritable ACL entries that specify "deny" permissions.
  1525.  
  1526.      restricted        removes  the write_acl  and  write_owner  
  1527.       (default)         permissions when the ACL entry is inherited.
  1528.  
  1529.      passthrough       inherits all inheritable ACL entries without any modifications
  1530.                         made to the  ACL  entries  when  they  are inherited.
  1531.                    
  1532.      passthrough-x     Has the same meaning as passthrough, except that the
  1533.                         owner@, group@, and everyone@ ACEs inherit the execute permission
  1534.                         only if the file creation mode also requests the execute bit.
  1535.  
  1536.  
  1537. discard         | does not inherit any ACL entries.
  1538. noallow         | only inherits inheritable ACL entries that specify "deny" permissions.
  1539. restricted      | (the default) removes the write_acl and  write_owner  perm
  1540. passthrough     | inherits all inheritable ACL entries without any modifications made to the ACL entries
  1541. passthrough-x   | owner@, group@, and everyone@ ACEs inherit  the  execute permission only if the file creation mode also requests the execute bit.
  1542.  
  1543.  
  1544.  
  1545.  
  1546. aclmode=discard | groupmask | passthrough
  1547.  
  1548.      discard       deletes all ACL entries that do not represent the mode of the file.
  1549.            
  1550.      groupmask     reduces user or group permissions. so that the ACL permissions
  1551.       (default)     are reduced so perms arnt greater than !> owner permission bits.
  1552.  
  1553.      passthrough   indicates that no changes are made to the ACL
  1554.                     other than generating the necessary ACL entries to represent
  1555.                     the  new mode of the file or directory.
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562. zfs set aclinherit=noallow zfs/dir                  "
  1563. echo "##-===============================================================-##"
  1564.  
  1565. chmod A+user:gozer:read_data:file_inherit:deny,user:lp:read_data:file_inherit:allow test6.dir
  1566.  
  1567.  
  1568. 0:user:gozer:read_data:file_inherit:deny
  1569. 1:user:lp:read_data:file_inherit:allow
  1570. 2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/write_owner/synchronize:allow
  1571. 3:group@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1572. 4:everyone@:list_directory/read_data/read_xattr/execute/read_attributes/read_acl/synchronize:allow
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581. mlslabel=label
  1582.  
  1583.  
  1584. echo "##-============================================================================-##"
  1585. echo "     [?] The  casesensitivity,  normalization,  and  utf8only  properties         "
  1586. echo "         are also new permissions that can be assigned to non-privileged users    "
  1587. echo "         by using the ZFS delegated administration feature.                       "
  1588. echo "##-============================================================================-##"
  1589. context=SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level
  1590.  
  1591.  
  1592. echo "##-============================================================================-##"
  1593. echo "     [?] This flag sets the SELinux context for all files in the filesytem        "
  1594. echo "         under the mountpoint for that filesystem                                 "
  1595. echo "##-============================================================================-##"
  1596. fscontext=SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level
  1597.  
  1598.  
  1599. echo "##-=====================================================================================-##"
  1600. echo "     [?] This  flag  sets  the  SELinux  context  for the filesytem being mounted.         "
  1601. echo "##-=====================================================================================-##"
  1602. defntext=SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level
  1603.  
  1604.  
  1605. echo "##-====================================================================-##"
  1606. echo "     [?] This flag sets the SELinux context for unlabeled files.          "
  1607. echo "##-====================================================================-##"
  1608. rootcontext=SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level
  1609.  
  1610.  
  1611. echo "##-==================================================================================-##"
  1612. echo "     [?] This flag sets the SELinux context for the root inode of the filesystem.       "
  1613. echo "##-==================================================================================-##"
  1614. overlay=on | off
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625. echo "##-=====================================================================-##"
  1626. echo "    [+] Re-create the root pool.                   "
  1627. echo "##-============================================================-##"
  1628.                  
  1629. zpool create -f -o failmode=continue -R /a -m legacy -o cachefile= /etc/zfs/zpool.cache rpool c1t1d0s0
  1630.  
  1631.  
  1632.  
  1633. echo "##-=====================================================================-##"
  1634. echo "    [+] Restore the root pool snapshots.                   "
  1635. echo "##-============================================================-##"
  1636.                  
  1637. cat /mnt/rpool.snap1 | zfs receive -Fdu rpool
  1638.  
  1639.  
  1640. echo "##-=====================================================================-##"
  1641. echo "    [+] restore the actual root pool snapshots that are stored in a pool on a remote system                   "
  1642. echo "##-============================================================-##"
  1643.                  
  1644. ssh remote-system zfs send -Rb tank/snaps/rpool@snap1 | zfs receive -F rpool
  1645.  
  1646.  
  1647. echo "##-=====================================================================-##"
  1648. echo "    [+] Set the bootfs property on the root pool BE.                   "
  1649. echo "##-============================================================-##"
  1650.                  
  1651. zpool set bootfs=rpool/ROOT/zfsBE rpool
  1652.  
  1653.  
  1654. echo "##-=====================================================================-##"
  1655. echo "    [+] Shut down the system and boot failsafe mode.                   "
  1656. echo "##-============================================================-##"
  1657.                  
  1658. ok boot -F failsafe
  1659.  
  1660. echo "##-=====================================================================-##"
  1661. echo "    [+] Roll back each root pool snapshot.           "
  1662. echo "##-===============================================-##"
  1663.                  
  1664. zfs rollback rpool@snap1
  1665. zfs rollback rpool/ROOT@snap1
  1666. zfs rollback rpool/ROOT/s10zfsBE@snap1
  1667.  
  1668.  
  1669. ##
  1670. zfs set volsize=2G
  1671. zfs get volsize
  1672. zfs set volsize=8g rpool/swap
  1673.  
  1674.  
  1675. ##
  1676. zpool create dozer mirror /file/a /file/b
  1677. zpool export dozer
  1678. zpool import -d /file
  1679. zpool import -d /file dozer
  1680. zpool import -f dozer
  1681. zpool import -m dozer
  1682.  
  1683. zpool import -o readonly=on ZPool-ZFS
  1684. zpool scrub ZPool-ZFS
  1685. zpool status -x
  1686.  
  1687.  
  1688.  
  1689. zpool create pool mirror
  1690.  
  1691. add newpool log mirror
  1692.  
  1693. add tank mirror
  1694.  
  1695. zpool add -n zfs mirror $disk0 $disk1       ## perform a dry run
  1696. zpool add zfs mirror $disk0 $disk1
  1697.  
  1698.  
  1699. zpool create tank mirror c2t0d0 c2t1d0 c2t3d0 cache c2t5d0 c2t8d0
  1700.  
  1701.  
  1702. zpool create logz log mirror
  1703.  
  1704.  
  1705. mkfile 100m ZPool-ZFS/log/
  1706.  
  1707.  
  1708.  
  1709. echo "##-============================================================-##"
  1710. echo "       [+] You can access the ZFS Administration console          "
  1711. echo "                 through a secure web browser at:                 "
  1712. echo "##-============================================================-##"
  1713. https://system-name:6789/zfs
  1714.  
  1715. echo "##-============================================================-##"
  1716. echo "            [+] use the Solaris Management Console (smc)          "
  1717. echo "                    to manage ZFS storage pools                   "
  1718. echo "##-============================================================-##"
  1719.                  
  1720. /usr/sbin/smcwebserver start
  1721. /usr/sbin/smcwebserver enable
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730. https://forums.freenas.org/index.php?threads/ecc-vs-non-ecc-ram-and-zfs.15449
  1731. https://docs.oracle.com/cd/E18752_01/html/819-5461/gbchx.html
  1732. https://arstechnica.com/information-technology/2014/02/ars-walkthrough-using-the-zfs-next-gen-filesystem-on-linux
  1733. http://docs.oracle.com/cd/E19253-01/819-5461/gevpg/index.html
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
Add Comment
Please, Sign In to add comment