SHARE
TWEET

Untitled

a guest Mar 18th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #####################
  4. ## Prepare overlay ##
  5. #####################
  6.  
  7. echo "Create Upper, Lower, and Overlay Directory"
  8. mkdir lower upper overlay work
  9.  
  10. echo "Create test files; onlyUpper, both, onlyLower"
  11. echo "Lower" > lower/onlyLower
  12. echo "Lower" > lower/both
  13. echo "Upper" > upper/both
  14. echo "Upper" > upper/onlyUpper
  15.  
  16. echo "Mount as a OverlayFS"
  17. mount -t overlay -o lowerdir=lower,upperdir=upper,workdir=work overlay overlay
  18.  
  19. echo "Check mount status"
  20. mount -l | grep overlay
  21. ls -lF overlay/
  22. #=> total 12
  23. #=> -rw-r--r-- 1 root root 6 Mar 14 07:24 both
  24. #=> -rw-r--r-- 1 root root 6 Mar 14 07:24 onlyLower
  25. #=> -rw-r--r-- 1 root root 6 Mar 14 07:24 onlyUpper
  26.  
  27. #####################
  28. ##  Read / Write   ##
  29. #####################
  30.  
  31. echo "Read File"
  32. cat overlay/onlyUpper
  33. #=> Upper
  34. cat overlay/both
  35. #=> Upper
  36. cat overlay/onlyLower
  37. #=> Lower
  38.  
  39. echo "Write into File"
  40. echo "Add" >> overlay/onlyUpper
  41. echo "Add" >> overlay/both
  42. echo "Add" >> overlay/onlyLower
  43.  
  44. echo "Read File again"
  45. cat overlay/onlyUpper
  46. #=> Upper
  47. #=> Add
  48. cat overlay/both
  49. #=> Upper
  50. #=> Add
  51. cat overlay/onlyLower
  52. #=> Lower
  53. #=> Add
  54.  
  55. echo "Check new file is created on Upper"
  56. ls -lF upper/
  57. #=> total 12
  58. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 both
  59. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 onlyLower
  60. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 onlyUpper
  61.  
  62.  
  63. #####################
  64. ##     Delete      ##
  65. #####################
  66.  
  67. echo "Remove File only exist Upper"
  68. rm overlay/onlyUpper
  69.  
  70. echo "Check File is deleted"
  71. ls -lF overlay/
  72. #=> total 8
  73. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 both
  74. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 onlyLower
  75. ls -lF upper/
  76. #=> total 8
  77. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 both
  78. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 onlyLower
  79.  
  80. echo "Remove File exist both Lower and Upper"
  81. rm overlay/both
  82.  
  83. echo "Check File is deleted"
  84. ls -lF overlay/
  85. #=> total 4
  86. #=> -rw-r--r-- 1 root root 10 Mar 14 07:25 onlyLower
  87.  
  88. echo "Check whitefile is created"
  89. ls -lF upper/
  90. #=> total 4
  91. #=> c--------- 1 root root 0, 0 Mar 14 07:30 both
  92. #=> -rw-r--r-- 1 root root   10 Mar 14 07:25 onlyLower
  93.  
  94. echo "Check Lower file exist"
  95. ls -lF lower/
  96. #=> total 8
  97. #=> -rw-r--r-- 1 root root 6 Mar 14 07:24 both
  98. #=> -rw-r--r-- 1 root root 6 Mar 14 07:24 onlyLower
  99.  
  100. cat lower/both
  101. #=> Lower
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top