Advertisement
Guest User

grub.cfg

a guest
Apr 30th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.80 KB | None | 0 0
  1. #!/bin/sh -x
  2.  
  3. # https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE
  4.  
  5. # edit:
  6. # disk device name
  7. # parameters for your zpool type
  8. # your pool name
  9. # swap space
  10.  
  11. PARTITION=freebsd
  12. POOL=z${PARTITION}
  13. SWAP=$(echo $PARTITION | cut -b 1-1)swap
  14. DRIVE=ada0
  15. read TEST
  16.  
  17. sysctl kern.geom.debugflags=0x10
  18. # gpart destroy -F ${DRIVE}
  19. # gpart create  -s gpt ${DRIVE}
  20. gpart delete -i 5 ${DRIVE}
  21. gpart delete -i 6 ${DRIVE}
  22. gpart delete -i 7 ${DRIVE}
  23. read TEST
  24.  
  25. # leave 32k empty at the start of the drive to avoid conflicting with MBR
  26. # gpart add -s 1M   -a 4k -t bios-boot    -l bboot -b 32k ${DRIVE}
  27. # gpart add -s 512k -a 4k -t freebsd-boot -l fboot        ${DRIVE}
  28. # gpart add -s 1M   -a 4k -t bios-boot    -l bboot        -b 1M ${DRIVE}
  29. # gpart add -s  1g  -a 4k -t efi          -l efi          -b 1M ${DRIVE}
  30.  
  31. gpart add -s 512k -a 4k -t freebsd-boot -l fboot   -b 1M        ${DRIVE}
  32. gpart add -s 100g -a 4k -t freebsd-zfs  -l ${PARTITION}         ${DRIVE}
  33. gpart add         -a 4k -t freebsd-swap -l ${SWAP}              ${DRIVE}
  34. read TEST
  35. # gpart add -s 55g  -a 4k -t linux-data   -l linux              ${DRIVE}
  36. # gpart add -s 10g  -a 4k -t linux-swap   -l lswap              ${DRIVE}
  37. # gpart add -s 55g  -a 4k -t freebsd-zfs  -l pcbsd              ${DRIVE}
  38. # gpart add -s 10g  -a 4k -t freebsd-swap -l pswap              ${DRIVE}
  39.  
  40. # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${DRIVE}
  41. # gpart set -a bootme -i 5 ${DRIVE}
  42. gnop create -S 4096 /dev/gpt/${PARTITION}
  43.  
  44. kldload zfs
  45. zpool create -d -f -o altroot=/mnt -O canmount=off -m none ${POOL} /dev/gpt/${PARTITION}.nop
  46. read TEST
  47.  
  48. # set up efi boot partition after /mnt is defined
  49. # newfs_msdos -F 16 -L esp /dev/${DRIVE}p1
  50. # mkdir /mnt/efi
  51. # mount -t msdosfs /dev/${DRIVE}p1 /mnt/efi
  52. # mkdir -p /mnt/efi/freebsd/boot
  53. # ln -s /mnt/efi/freebsd/boot boot
  54.  
  55. # continue setting up the zpool
  56. FEATURES="async_destroy bookmarks embedded_data empty_bpobj hole_birth enabled_txg extensible_dataset filesystem_limits large_blocks lz4_compress multi_vdev_crash_dump sha512 skein spacemap_histogram"
  57. # exclude these 2 incompatible features
  58. # hole_birth embedded_data
  59. # "zpool create -d" defaults all zfs features to disabled. Any desired features must be enabled below.
  60. for f in $FEATURES; do
  61.    case $f in
  62.       'hole_birth')
  63.          ;;
  64.       'embedded_data')
  65.          ;;
  66.       *)
  67.          zpool set feature@${f}=enabled ${POOL}
  68.          ;;
  69.    esac
  70. done
  71. read TEST
  72. zpool get all ${POOL} | grep feature
  73. read TEST
  74.  
  75. zfs set checksum=fletcher4                                           ${POOL}
  76. zfs set atime=off                                                    ${POOL}
  77.  
  78. zfs create   -o mountpoint=none                                      ${POOL}/ROOT
  79. zfs create   -o mountpoint=/                                         ${POOL}/ROOT/default
  80. read TEST
  81.  
  82. zfs create   -o mountpoint=/tmp -o compression=lz4   -o setuid=off   ${POOL}/tmp
  83. chmod 1777 /mnt/tmp
  84.  
  85. zfs create   -o mountpoint=/home                     -o setuid=off   ${POOL}/home
  86.  
  87. zfs create   -o mountpoint=/usr                                      ${POOL}/usr
  88. read TEST
  89. zfs create                                                           ${POOL}/usr/local
  90. zfs create   -o compression=lz4                      -o setuid=off   ${POOL}/usr/ports
  91. zfs create   -o compression=off      -o exec=off     -o setuid=off   ${POOL}/usr/ports/distfiles
  92. zfs create   -o compression=off      -o exec=off     -o setuid=off   ${POOL}/usr/ports/packages
  93. read TEST
  94. zfs create   -o compression=lz4      -o exec=off     -o setuid=off   ${POOL}/usr/src
  95. zfs create                                                           ${POOL}/usr/obj
  96.  
  97. zfs create   -o mountpoint=/var                                      ${POOL}/var
  98. zfs create   -o compression=lz4      -o exec=off     -o setuid=off   ${POOL}/var/crash
  99. zfs create                           -o exec=off     -o setuid=off   ${POOL}/var/db
  100. read TEST
  101. zfs create   -o compression=lz4      -o exec=on      -o setuid=off   ${POOL}/var/db/pkg
  102. zfs create                           -o exec=off     -o setuid=off   ${POOL}/var/empty
  103. zfs create   -o compression=lz4      -o exec=off     -o setuid=off   ${POOL}/var/log
  104. read TEST
  105. zfs create   -o compression=gzip     -o exec=off     -o setuid=off   ${POOL}/var/mail
  106. zfs create                           -o exec=off     -o setuid=off   ${POOL}/var/run
  107. zfs create   -o compression=lz4      -o exec=on      -o setuid=off   ${POOL}/var/tmp
  108. chmod 1777 /mnt/var/tmp
  109. read TEST
  110.  
  111. zpool set bootfs=${POOL}/ROOT/default ${POOL}
  112. zpool set cachefile=/boot/zfs/zpool.cache ${POOL}
  113. read TEST
  114.  
  115. cat << EOF > /tmp/bsdinstall_etc/fstab
  116. # Device                       Mountpoint              FStype  Options         Dump    Pass #
  117. /dev/diskid/DISK-S2R5NX0J132791Tp7              none                    swap    sw              0       0
  118. EOF
  119.  
  120. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement