Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # set up basic alpine environment (networking, kbd layout, apk repo)
- setup-alpine -q
- # add some required packages
- apk add e2fsprogs mdadm parted sgdisk gptfdisk
- # create partition layout on the first disk
- gdisk /dev/sda
- > o
- > y
- > n
- >
- >
- > +128M
- > fd00
- > n
- >
- >
- > +16G
- > fd00
- > w
- > y
- # copy the partition layout to all other disks
- sgdisk /dev/sda -R /dev/sdb
- sgdisk /dev/sda -R /dev/sdc
- sgdisk /dev/sda -R /dev/sgd
- # randomize the UUIDs on all the disks
- sgdisk -G /dev/sdb
- sgdisk -G /dev/sdc
- sgdisk -G /dev/sdd
- # set the bootable flag on the first partition of all disks
- # Note: I'm not sure if this is being copied by the sgdisk -R command above,
- # so to be 100% sure, we set it manually on all disks
- sgdisk /dev/sda --attributes=1:set:2
- sgdisk /dev/sdb --attributes=1:set:2
- sgdisk /dev/sdc --attributes=1:set:2
- sgdisk /dev/sdd --attributes=1:set:2
- # create our /boot raid1
- # Note: --metadata 1.0 is VERY important here, syslinux does not support anything newer!
- mdadm --create /dev/md0 --metadata 1.0 -l 1 -n 4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
- # create our / raid1
- mdadm --create /dev/md1 -l 1 -n 4 /dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2
- # create ext4 partitions
- mkfs.ext4 -m 0 /dev/md0
- mkfs.ext4 /dev/md1
- # mount the partitions
- mount -t ext4 /dev/md1 /mnt
- mkdir /mnt/boot /mnt/etc
- mount -t ext4 /dev/md0 /mnt/boot
- # write the mdadm config so we don't end up with md127/md126 instead of md0/md1
- mdadm --detail --scan > /mnt/etc/mdadm.conf
- # make sure we include the raid1 module in our initrd
- echo raid1 >> /etc/modules
- # do the actual alpine linux installation
- setup-disk -m sys /mnt
- # cleanly unmount everything
- umount /mnt/boot /mnt
- # write the GPT/MBR bootloader to the disk protective mbr
- dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sda
- dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sdb
- dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sdc
- dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sdd
- # make sure all disks are synced before rebooting/shutting down
- sync
Add Comment
Please, Sign In to add comment