linux | bash - mount zfs (pools+datasets)
Bash[Edit]
+
0
-
0
Linux | Bash - mount ZFS (pools+datasets)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145# Notes: # - the solution is dedicated for Debian/Ubuntu based Linuxes, # - the solution was tested on Debian 12 (bookworm). # ------------------------------------------------------------------------- # Simple steps: # ------------------------------------------------------------------------- # 1. add missing dependencies: # # 1.1. edit '/etc/apt/sources.list' file using: # sudo nano /etc/apt/sources.list # # 1.2. append new sources: # deb http://deb.debian.org/debian bookworm main contrib deb-src http://deb.debian.org/debian bookworm main contrib # # Note: save changes using Ctrl+O and exit editor using Ctrl+X # # 1.3. update dependencies using: # sudo apt update # 2. install ZFS utils using: # sudo apt install zfsutils-linux # Note: if the ZFS module is not loaded into the kernel after installation, execute the command `sudo modprobe zfs`. # 3. check available ZFS pools using: # sudo zpool import # Example output: # # pool: zroot # id: 13531194572260260348 # state: ONLINE # status: The pool was last accessed by another system. # action: The pool can be imported using its name or numeric identifier and the '-f' flag. # see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-EY # config: # # zroot ONLINE # sda2 ONLINE # 4. import specific ZFS pool using: # sudo zpool import -N -f PUT_POOL_NAME_HERE # OR just: sudo zpool import -N PUT_POOL_NAME_HERE # e.g. sudo zpool import -N -f zroot # Note: to import pool using read-only mode use `sudo zpool import -N -f -o readonly=on PUT_POOL_NAME_HERE` command or `sudo zpool import -N -o readonly=on PUT_POOL_NAME_HERE` command. # 5. list imported ZFS pools using: # sudo zpool list # Example output: # # NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT # zroot 39G 972K 39.0G - - 0% 0% 1.00x ONLINE - # 6. list available ZFS datasets using: # sudo zfs list # Example output: # # NAME USED AVAIL REFER MOUNTPOINT # zroot 972K 37.8G 96K none # zroot/ROOT 192K 37.8G 96K none # zroot/ROOT/debian 96K 37.8G 96K / # zroot/home 96K 37.8G 96K /home # 7. optionally to change mount point of specific ZFS dataset use: # sudo zfs set mountpoint=/path/to/mount-directory PUT_DATASET_NAME_HERE # Note: you can ommit this step if you accept existing mount points, e.g. `/` and `/home` like in the above are. # Warning: it will update the current ZFS dataset configuration! # e.g. # sudo zfs set mountpoint=/mnt zroot/ROOT/debian # sudo zfs set mountpoint=/mnt/home zroot/home # 8. mount specific ZFS dataset using: # sudo zfs mount PUT_DATASET_NAME_HERE # e.g. We want to mount 2 datasets, so we execute 2 commands: # sudo zfs mount zroot/ROOT/debian # sudo zfs mount zroot/home # 9. Done! # # From now you can browse `/mnt` and `/mnt/home` directories. # ------------------------------------------------------------------------- # Hint: to unmount specific ZFS dataset use: # sudo zfs unmount PUT_DATASET_NAME_HERE # e.g. # sudo zfs unmount zroot/ROOT/debian # sudo zfs unmount zroot/home # Hint: after all work you can unmount all ZFS datasets and export/release pools using: # sudo zfs unmount -a sudo zpool export PUT_POOL_NAME_HERE # e.g. # sudo zfs unmount -a # sudo zpool export zroot