Advertisement
konzty

Untitled

Sep 22nd, 2021 (edited)
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.18 KB | None | 0 0
  1. ##########################################
  2. #PREPARE files:
  3. #Creating 5 files representing the disks, then expanding the files to 1G in size.
  4.  
  5. konstantin@majestix:/tmp/zpool-experiment$ touch disk1 disk2 disk3 disk4 disk5
  6. konstantin@majestix:/tmp/zpool-experiment$ dd if=/dev/zero bs=1G count=1 of=disk1
  7. 1+0 records in
  8. 1+0 records out
  9. 1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,36143 s, 455 MB/s
  10. konstantin@majestix:/tmp/zpool-experiment$ dd if=/dev/zero bs=1G count=1 of=disk2
  11. 1+0 records in
  12. 1+0 records out
  13. 1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,35572 s, 456 MB/s
  14. konstantin@majestix:/tmp/zpool-experiment$ dd if=/dev/zero bs=1G count=1 of=disk3
  15. 1+0 records in
  16. 1+0 records out
  17. 1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,36414 s, 454 MB/s
  18. konstantin@majestix:/tmp/zpool-experiment$ dd if=/dev/zero bs=1G count=1 of=disk4
  19. 1+0 records in
  20. 1+0 records out
  21. 1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,36307 s, 454 MB/s
  22. konstantin@majestix:/tmp/zpool-experiment$ dd if=/dev/zero bs=1G count=1 of=disk5
  23. 1+0 records in
  24. 1+0 records out
  25. 1073741824 bytes (1,1 GB, 1,0 GiB) copied, 2,39869 s, 448 MB/s
  26. konstantin@majestix:/tmp/zpool-experiment$
  27.  
  28.  
  29. ##########################################
  30. #CREATE zpool:
  31. #Create a zpool as a raidz1 from the files. NOTE: I'm working with files instead of actual disk devices, this is why I have to use the "-d /path/to/file" option.
  32.  
  33. konstantin@majestix:/tmp/zpool-experiment$ sudo zpool create EXPERIMENTAL raidz /tmp/zpool-experiment/disk1 /tmp/zpool-experiment/disk2 /tmp/zpool-experiment/disk3 /tmp/zpool-experiment/disk4 /tmp/zpool-experiment/disk5
  34. konstantin@majestix:/tmp/zpool-experiment$
  35. konstantin@majestix:/tmp/zpool-experiment$ zpool status EXPERIMENTAL
  36.   pool: EXPERIMENTAL
  37.  state: ONLINE
  38.   scan: none requested
  39. config:
  40.  
  41.     NAME                             STATE     READ WRITE CKSUM
  42.     EXPERIMENTAL                     ONLINE       0     0     0
  43.       raidz1-0                       ONLINE       0     0     0
  44.         /tmp/zpool-experiment/disk1  ONLINE       0     0     0
  45.         /tmp/zpool-experiment/disk2  ONLINE       0     0     0
  46.         /tmp/zpool-experiment/disk3  ONLINE       0     0     0
  47.         /tmp/zpool-experiment/disk4  ONLINE       0     0     0
  48.         /tmp/zpool-experiment/disk5  ONLINE       0     0     0
  49.  
  50. errors: No known data errors
  51. konstantin@majestix:/tmp/zpool-experiment$
  52.  
  53.  
  54. ##########################################
  55. #OFFLINE one disk:
  56. #The disk (disk1) with the SMART errors was offlined manually
  57.  
  58. konstantin@majestix:/tmp/zpool-experiment$ sudo zpool offline EXPERIMENTAL /tmp/zpool-experiment/disk1
  59. konstantin@majestix:/tmp/zpool-experiment$
  60. konstantin@majestix:/tmp/zpool-experiment$ zpool status EXPERIMENTAL
  61.   pool: EXPERIMENTAL
  62.  state: DEGRADED
  63. status: One or more devices has been taken offline by the administrator.
  64.     Sufficient replicas exist for the pool to continue functioning in a
  65.     degraded state.
  66. action: Online the device using 'zpool online' or replace the device with
  67.     'zpool replace'.
  68.   scan: none requested
  69. config:
  70.  
  71.     NAME                             STATE     READ WRITE CKSUM
  72.     EXPERIMENTAL                     DEGRADED     0     0     0
  73.       raidz1-0                       DEGRADED     0     0     0
  74.         /tmp/zpool-experiment/disk1  OFFLINE      0     0     0
  75.         /tmp/zpool-experiment/disk2  ONLINE       0     0     0
  76.         /tmp/zpool-experiment/disk3  ONLINE       0     0     0
  77.         /tmp/zpool-experiment/disk4  ONLINE       0     0     0
  78.         /tmp/zpool-experiment/disk5  ONLINE       0     0     0
  79.  
  80. errors: No known data errors
  81. konstantin@majestix:/tmp/zpool-experiment$
  82.  
  83. ##########################################
  84. #EXPORT zpool and disconnect another disk:
  85. #The system was powered off (a zpool export usually happens) and the wrong disk (disk2) was physically disconnected. On the next reboot a zpool import is attempted but too many disks are missing in the zpool and the poo can't be imported.
  86.  
  87. konstantin@majestix:/tmp/zpool-experiment$ sudo zpool export EXPERIMENTAL
  88. konstantin@majestix:/tmp/zpool-experiment$
  89. konstantin@majestix:/tmp/zpool-experiment$ mv disk2 disk2_unplugged
  90. konstantin@majestix:/tmp/zpool-experiment$
  91. konstantin@majestix:/tmp/zpool-experiment$ sudo zpool import -d /tmp/zpool-experiment/disk3
  92.    pool: EXPERIMENTAL
  93.      id: 17039649167381576158
  94.   state: UNAVAIL
  95.  status: One or more devices are missing from the system.
  96.  action: The pool cannot be imported. Attach the missing
  97.     devices and try again.
  98.    see: http://zfsonlinux.org/msg/ZFS-8000-3C
  99.  config:
  100.  
  101.     EXPERIMENTAL                     UNAVAIL  insufficient replicas
  102.       raidz1-0                       UNAVAIL  insufficient replicas
  103.         /tmp/zpool-experiment/disk1  OFFLINE
  104.         /tmp/zpool-experiment/disk2  UNAVAIL  cannot open
  105.         /tmp/zpool-experiment/disk3  ONLINE
  106.         /tmp/zpool-experiment/disk4  ONLINE
  107.         /tmp/zpool-experiment/disk5  ONLINE
  108. konstantin@majestix:/tmp/zpool-experiment$
  109.  
  110. ##########################################
  111. #RECONNECT disk2 and try import again:
  112. #Power off the system, reconnect the accidentally pulled disk (disk2) and power on the system. It could be that the zpool is automatically imported, it could be that a manual import is necessary. NOTE: my zpool import command is missing the zpool name. This is why the import is not importing but only looking for the pool on the given disk/file.
  113.  
  114. konstantin@majestix:/tmp/zpool-experiment$ sudo mv disk2_unplugged disk2
  115. konstantin@majestix:/tmp/zpool-experiment$
  116. konstantin@majestix:/tmp/zpool-experiment$ sudo zpool import -d /tmp/zpool-experiment/disk3
  117.    pool: EXPERIMENTAL
  118.      id: 17039649167381576158
  119.   state: DEGRADED
  120.  status: One or more devices are offlined.
  121.  action: The pool can be imported despite missing or damaged devices.  The
  122.     fault tolerance of the pool may be compromised if imported.
  123.  config:
  124.  
  125.     EXPERIMENTAL                     DEGRADED
  126.       raidz1-0                       DEGRADED
  127.         /tmp/zpool-experiment/disk1  OFFLINE
  128.         /tmp/zpool-experiment/disk2  ONLINE
  129.         /tmp/zpool-experiment/disk3  ONLINE
  130.         /tmp/zpool-experiment/disk4  ONLINE
  131.         /tmp/zpool-experiment/disk5  ONLINE
  132. konstantin@majestix:/tmp/zpool-experiment$
  133. konstantin@majestix:/tmp/zpool-experiment$ sudo zpool import -d /tmp/zpool-experiment/disk3 EXPERIMENTAL
  134. konstantin@majestix:/tmp/zpool-experiment$
  135. konstantin@majestix:/tmp/zpool-experiment$ zpool status EXPERIMENTAL
  136.   pool: EXPERIMENTAL
  137.  state: DEGRADED
  138. status: One or more devices has been taken offline by the administrator.
  139.     Sufficient replicas exist for the pool to continue functioning in a
  140.     degraded state.
  141. action: Online the device using 'zpool online' or replace the device with
  142.     'zpool replace'.
  143.   scan: none requested
  144. config:
  145.  
  146.     NAME                             STATE     READ WRITE CKSUM
  147.     EXPERIMENTAL                     DEGRADED     0     0     0
  148.       raidz1-0                       DEGRADED     0     0     0
  149.         /tmp/zpool-experiment/disk1  OFFLINE      0     0     0
  150.         /tmp/zpool-experiment/disk2  ONLINE       0     0     0
  151.         /tmp/zpool-experiment/disk3  ONLINE       0     0     0
  152.         /tmp/zpool-experiment/disk4  ONLINE       0     0     0
  153.         /tmp/zpool-experiment/disk5  ONLINE       0     0     0
  154.  
  155. errors: No known data errors
  156. konstantin@majestix:/tmp/zpool-experiment$
  157.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement