Skip to content

Instantly share code, notes, and snippets.

@funzoneq
Last active March 14, 2017 10:37
Show Gist options
  • Save funzoneq/840a3099afee9625d8f8 to your computer and use it in GitHub Desktop.
Save funzoneq/840a3099afee9625d8f8 to your computer and use it in GitHub Desktop.
FreeBSD gmirror setup sata drives
gpart destroy -F ada0
gpart destroy -F ada1
gpart create -s gpt ada0
gpart create -s gpt ada1
gpart add -s 64k -t freebsd-boot -l boot0 ada0
gpart add -s 64k -t freebsd-boot -l boot1 ada1
gpart add -s 8G -t freebsd-swap -l swap0 ada0
gpart add -s 8G -t freebsd-swap -l swap1 ada1
gpart add -s 10G -t freebsd-ufs -l root0 ada0
gpart add -s 10G -t freebsd-ufs -l root1 ada1
gpart add -s 50G -t freebsd-ufs -l var0 ada0
gpart add -s 50G -t freebsd-ufs -l var1 ada1
gpart add -s 4G -t freebsd-ufs -l tmp0 ada0
gpart add -s 4G -t freebsd-ufs -l tmp1 ada1
gpart add -t freebsd-ufs -l usr0 ada0
gpart add -t freebsd-ufs -l usr1 ada1
# install bootcode to disk
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
gmirror label -h boot /dev/gpt/boot0 /dev/gpt/boot1
gmirror label -h swap /dev/gpt/swap0 /dev/gpt/swap1
gmirror label -h root /dev/gpt/root0 /dev/gpt/root1
gmirror label -h var /dev/gpt/var0 /dev/gpt/var1
gmirror label -h tmp /dev/gpt/tmp0 /dev/gpt/tmp1
gmirror label -h usr /dev/gpt/usr0 /dev/gpt/usr1
kldload geom_mirror
newfs -U -L root /dev/mirror/root
mount /dev/mirror/root /mnt
newfs -U -L var /dev/mirror/var
newfs -U -L tmp /dev/mirror/tmp
newfs -U -L usr /dev/mirror/usr
mkdir /mnt/var /mnt/tmp /mnt/usr
chmod 0000 /mnt/var /mnt/tmp /mnt/usr
mount /dev/mirror/var /mnt/var
mount /dev/mirror/tmp /mnt/tmp
mount /dev/mirror/usr /mnt/usr
chmod 1777 /mnt/tmp
cat > /tmp/bsdinstall_etc/fstab <<EOF
# Device Mountpoint FStype Options Dump Pass#
/dev/mirror/swap none swap sw 0 0
/dev/mirror/root / ufs rw 1 1
/dev/mirror/var /var ufs rw 2 2
/dev/mirror/tmp /tmp ufs rw 2 2
/dev/mirror/usr /usr ufs rw 2 2
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment