Guest User

Untitled

a guest
Oct 23rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. # set up basic alpine environment (networking, kbd layout, apk repo)
  2. setup-alpine -q
  3.  
  4. # add some required packages
  5. apk add e2fsprogs mdadm parted sgdisk gptfdisk
  6.  
  7. # create partition layout on the first disk
  8. gdisk /dev/sda
  9. > o
  10. > y
  11. > n
  12. >
  13. >
  14. > +128M
  15. > fd00
  16. > n
  17. >
  18. >
  19. > +16G
  20. > fd00
  21. > w
  22. > y
  23.  
  24. # copy the partition layout to all other disks
  25. sgdisk /dev/sda -R /dev/sdb
  26. sgdisk /dev/sda -R /dev/sdc
  27. sgdisk /dev/sda -R /dev/sgd
  28.  
  29. # randomize the UUIDs on all the disks
  30. sgdisk -G /dev/sdb
  31. sgdisk -G /dev/sdc
  32. sgdisk -G /dev/sdd
  33.  
  34. # set the bootable flag on the first partition of all disks
  35. # Note: I'm not sure if this is being copied by the sgdisk -R command above,
  36. # so to be 100% sure, we set it manually on all disks
  37. sgdisk /dev/sda --attributes=1:set:2
  38. sgdisk /dev/sdb --attributes=1:set:2
  39. sgdisk /dev/sdc --attributes=1:set:2
  40. sgdisk /dev/sdd --attributes=1:set:2
  41.  
  42. # create our /boot raid1
  43. # Note: --metadata 1.0 is VERY important here, syslinux does not support anything newer!
  44. mdadm --create /dev/md0 --metadata 1.0 -l 1 -n 4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
  45.  
  46. # create our / raid1
  47. mdadm --create /dev/md1 -l 1 -n 4 /dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2
  48.  
  49. # create ext4 partitions
  50. mkfs.ext4 -m 0 /dev/md0
  51. mkfs.ext4 /dev/md1
  52.  
  53. # mount the partitions
  54. mount -t ext4 /dev/md1 /mnt
  55. mkdir /mnt/boot /mnt/etc
  56. mount -t ext4 /dev/md0 /mnt/boot
  57.  
  58. # write the mdadm config so we don't end up with md127/md126 instead of md0/md1
  59. mdadm --detail --scan > /mnt/etc/mdadm.conf
  60.  
  61. # make sure we include the raid1 module in our initrd
  62. echo raid1 >> /etc/modules
  63.  
  64. # do the actual alpine linux installation
  65. setup-disk -m sys /mnt
  66.  
  67. # cleanly unmount everything
  68. umount /mnt/boot /mnt
  69.  
  70. # write the GPT/MBR bootloader to the disk protective mbr
  71. dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sda
  72. dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sdb
  73. dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sdc
  74. dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sdd
  75.  
  76. # make sure all disks are synced before rebooting/shutting down
  77. sync
Add Comment
Please, Sign In to add comment