DyeHardman

HOWTO: TrueNAS Scale: from 32gb USB to booting from mirrored larger enterprise SSD's, create add'l

May 15th, 2022 (edited)
1,230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.19 KB | None | 0 0
  1. # determine the drives you want to work on ie /dev/<drive>
  2. # you could also remove your HDD's to shorten the list
  3. lsblk -l
  4.  
  5. # set vars
  6. # omit the /dev/ as the script below accounts for that.
  7. bootdisk=sds
  8. ssd1=sdl
  9. ssd2=sdm
  10. # optional: 4th partition
  11. partitionpool=vm-pool
  12.  
  13. # we're dumping the current bootdrive partition data
  14. # to a file, in the event you want to change sectors e.g. 512->4096
  15. sfdisk --dump /dev/${bootdisk} > original.boot.disk.part.dump
  16.  
  17. ###########################
  18. # OPTIONAL if going to 4k sector size and/or want to use remaining free space as an additional pool
  19. # USB sectors sizee 512 -> enterprise SSD sector size 4096
  20. #
  21. # 1. Dump current ssd partition table to grab last-lba for SSD
  22. #
  23. # sfdisk --dump /dev/${ssd1} > ssd.reference.dump
  24. # cat ssd.reference.dump
  25. #
  26. #
  27. # 2. edit the working dump with the SSD last-lba
  28. #    divide all sector start/size by 4, rounding up to whole numbers
  29. #    make sure the 'start' + 'size' does not exceed 'start' of the next partition
  30. #
  31. # nano original.boot.disk.part.dump
  32. #
  33. # 3. save
  34. #
  35. # /OPTIONAL
  36. ###########################
  37. # edit sectors if you'd like, otherwise, move on
  38. sfdisk --force /dev/${ssd1} < original.boot.disk.part.dump
  39. sfdisk --force /dev/${ssd2} < original.boot.disk.part.dump
  40.  
  41. # attaching the 3rd partition to the boot-pool
  42. zpool attach boot-pool ${bootdisk}3 ${ssd1}3
  43. zpool attach boot-pool ${bootdisk}3 ${ssd2}3
  44.  
  45. # copy files from bootdisk,1 to drive1,1 & drive2,1
  46. dd if=/dev/${bootdisk}1 of=/dev/${ssd1}1 status=progress
  47. dd if=/dev/${bootdisk}1 of=/dev/${ssd2}1 status=progress
  48.  
  49. # copy files from bootdisk,1 to drive1,2 & drive2,2
  50. # these 2 lines may be unnecessary, as I still had to copy efi files further down
  51. dd if=/dev/${bootdisk}2 of=/dev/${ssd1}2 status=progress
  52. dd if=/dev/${bootdisk}2 of=/dev/${ssd2}2 status=progress
  53.  
  54. # prep dirs needed for copying EFI partition
  55. mkdir -p /mnt/${bootdisk}2/
  56. mkdir -p /mnt/${ssd1}2/
  57. mkdir -p /mnt/${ssd2}2/
  58.  
  59. # grub can have issues with installing here
  60. # set the filesystem to fat32 for drive1,2 & drive2,2
  61. mkfs.vfat /dev/${ssd1}2
  62. mkfs.vfat /dev/${ssd2}2
  63.  
  64. # mount necessary dirs
  65. mount /dev/${bootdisk}2 /mnt/${bootdisk}2/
  66. mount /dev/${ssd1}2 /mnt/${ssd1}2/
  67. mount /dev/${ssd2}2 /mnt/${ssd2}2/
  68.  
  69. # copy contents
  70. cp -r /mnt/${bootdisk}2/ /mnt/{ssd1}2/
  71. cp -r /mnt/${bootdisk}2/ /mnt/{ssd2}2/
  72.  
  73. # confirm resilvering is complete before detaching USB from boot-pool
  74. watch -n 5 -d zpool status boot-pool
  75.  
  76. # offline and remove original bootdisk from the pool
  77. zpool offline boot-pool ${bootdisk}3
  78. zpool detach boot-pool ${bootdisk}3
  79.  
  80. ###########################
  81. # OPTIONAL: create a new SSD partitions and mirrored pool#
  82. # 1. create partition on SSD1
  83. # fdisk /dev/${ssd1}
  84. # <input> n <press enter>
  85. # <press enter to input defaults and create 4th partition>
  86. # <input> w <press enter>
  87. #
  88. # 2. create partition on SSD2
  89. # fdisk /dev/${ssd2}
  90. # <input> n <press enter>
  91. # <press enter to input defaults and create 4th partition>
  92. # <input> w <press enter>
  93. #
  94. # 3. create mirrored pool from 4th partition and export to see in TrueNAS CLI/GUI
  95. # zpool create ${partitionpool} /dev/${ssd1}4 /dev/${ssd2}4
  96. # zpool export ${partitionpool}
  97. #
  98. # /OPTIONAL
  99. ###########################
  100.  
Add Comment
Please, Sign In to add comment