- bootonly.iso イメージから作成した CD などで起動する
- Shell を選択する
- 以下のコマンドを順番に実行する
- dhclient em0
- fetch --no-verify-peer -o /tmp/setup https://goo.gl/32tS1C
- sh /tmp/setup
- OSインストール完了後に自動的に再起動される
Last active
January 6, 2017 03:44
-
-
Save libero18/6eb47a129fddcecb29ed to your computer and use it in GitHub Desktop.
bsdinstall のメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
## FreeBSD install script | |
## See. https://www.freebsd.org/cgi/man.cgi?bsdinstall(8) | |
################################################################################ | |
################################################################################ | |
## set environment variables | |
################################################################################ | |
: ${OS_RELEASE_VERSION="11.0-RELEASE"} | |
: ${OS_CPU_ARCHITECTURE="amd64"} | |
: ${BSDINSTALL_DISTSITE="http://ftp.jaist.ac.jp/pub/FreeBSD/releases/$OS_CPU_ARCHITECTURE/$OS_RELEASE_VERSION"} | |
export BSDINSTALL_DISTSITE | |
: ${PRIMARY_HDD="ada0"} | |
: ${SECONDARY_HDD="ada1"} | |
: ${MILLER_DEVICE="gm0"} | |
: ${PARTITION_SCHEME="GPT"} | |
#: ${PARTITION_SCHEME="MBR"} | |
: ${BOOT_PARTITION_SIZE="512k"} | |
: ${SWAP_PARTITION_SIZE="4GB"} | |
: ${PARTITIONS="$PRIMARY_HDD $PARTITION_SCHEME { $BOOT_PARTITION_SIZE freebsd-boot, $SWAP_PARTITION_SIZE freebsd-swap, auto freebsd-ufs / }"} | |
export PARTITIONS | |
: ${DISTRIBUTIONS="base.txz kernel.txz"} | |
: ${BSDINSTALL_DISTDIR="/mnt/freebsd-dist"} | |
export DISTRIBUTIONS | |
export BSDINSTALL_DISTDIR | |
: ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"} | |
: ${BSDINSTALL_TMPBOOT="/tmp/bsdinstall_boot"} | |
: ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"} | |
: ${BSDINSTALL_CHROOT="/mnt"} | |
export BSDINSTALL_TMPETC | |
export BSDINSTALL_TMPBOOT | |
export PATH_FSTAB | |
export BSDINSTALL_CHROOT | |
################################################################################ | |
## create partition & file system with bsdinstall | |
################################################################################ | |
( kldstat | grep geom_mirror >/dev/null 2>&1 ) || kldload geom_mirror | |
( gmirror list "$MILLER_DEVICE"p1 >/dev/null 2>&1 ) && gmirror destroy -f "$MILLER_DEVICE"p1 | |
( gmirror list "$MILLER_DEVICE"p2 >/dev/null 2>&1 ) && gmirror destroy -f "$MILLER_DEVICE"p2 | |
( gmirror list "$MILLER_DEVICE"p3 >/dev/null 2>&1 ) && gmirror destroy -f "$MILLER_DEVICE"p3 | |
( gpart show "$PRIMARY_HDD" >/dev/null 2>&1 ) && gpart destroy -F "$PRIMARY_HDD" | |
( gpart show "$SECONDARY_HDD" >/dev/null 2>&1 ) && gpart destroy -F "$SECONDARY_HDD" | |
( gpart show ${PRIMARY_HDD} >/dev/null 2>&1 ) || bsdinstall scriptedpart ${PARTITIONS} | |
( gpart show "$PRIMARY_HDD" >/dev/null 2>&1 ) && gpart backup "$PRIMARY_HDD" | gpart restore -F /dev/"$SECONDARY_HDD" | |
( gpart show "$PRIMARY_HDD" >/dev/null 2>&1 ) && gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 "$PRIMARY_HDD" | |
( gpart show "$SECONDARY_HDD" >/dev/null 2>&1 ) && gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 "$SECONDARY_HDD" | |
gmirror label -vb round-robin "$MILLER_DEVICE"p1 /dev/"$PRIMARY_HDD"p1 /dev/"$SECONDARY_HDD"p1 | |
gmirror label -vb round-robin "$MILLER_DEVICE"p2 /dev/"$PRIMARY_HDD"p2 /dev/"$SECONDARY_HDD"p2 | |
gmirror label -vb round-robin "$MILLER_DEVICE"p3 /dev/"$PRIMARY_HDD"p3 /dev/"$SECONDARY_HDD"p3 | |
gpart modify -i 1 -l boot /dev/"$PRIMARY_HDD" | |
gpart modify -i 1 -l boot /dev/"$SECONDARY_HDD" | |
gpart modify -i 2 -l swap /dev/"$PRIMARY_HDD" | |
gpart modify -i 2 -l swap /dev/"$SECONDARY_HDD" | |
gpart modify -i 3 -l rootfs /dev/"$PRIMARY_HDD" | |
gpart modify -i 3 -l rootfs /dev/"$SECONDARY_HDD" | |
newfs -U /dev/mirror/"$MILLER_DEVICE"p3 | |
glabel label swap /dev/mirror/"$MILLER_DEVICE"p2 | |
tunefs -L boot /dev/mirror/"$MILLER_DEVICE"p1 | |
tunefs -L rootfs /dev/mirror/"$MILLER_DEVICE"p3 | |
################################################################################ | |
## setup gmirror with bsdinstall | |
################################################################################ | |
echo "geom_mirror_load=YES" >> "$BSDINSTALL_TMPBOOT"/loader.conf | |
sed -i -e "s/${PRIMARY_HDD}/mirror\/${MILLER_DEVICE}/g" "$PATH_FSTAB" | |
################################################################################ | |
## setup network with bsdinstall | |
################################################################################ | |
: ${PRIMARY_NIC="em0"} | |
: ${SECONDARY_NIC="em1"} | |
: ${LAGG_NIC="lagg0"} | |
: ${LAGG_NETWORK="DHCP"} | |
#: ${LAGG_NETWORK="192.168.0.10/24"} | |
: ${LAGG_CONF="ifconfig_$LAGG_NIC=\"laggproto roundrobin laggport $PRIMARY_NIC laggport $SECONDARY_NIC $LAGG_NETWORK\""} | |
echo "if_lagg_load=YES" >> "$BSDINSTALL_TMPBOOT"/loader.conf | |
echo "ifconfig_$PRIMARY_NIC=up" >> "$BSDINSTALL_TMPETC"/rc.conf | |
echo "ifconfig_$SECONDARY_NIC=up" >> "$BSDINSTALL_TMPETC"/rc.conf | |
echo "cloned_interfaces=$LAGG_NIC" >> "$BSDINSTALL_TMPETC"/rc.conf | |
echo "$LAGG_CONF" >> "$BSDINSTALL_TMPETC"/rc.conf | |
# ToDo?: lagg alias | |
# ifconfig_lagg0_alias0="inet 192.168.100.10/24" | |
# ifconfig_lagg0_alias1="inet 192.168.200.10/24" | |
################################################################################ | |
## setup system with bsdinstall | |
################################################################################ | |
echo "keymap=jp.106.kbd" >> "$BSDINSTALL_TMPETC"/rc.conf.keymap | |
echo "sshd_enable=YES" >> "$BSDINSTALL_TMPETC"/rc.conf | |
bsdinstall mount | |
################################################################################ | |
## fetch distributions with bsdinstall | |
################################################################################ | |
mkdir -p "$BSDINSTALL_DISTDIR" | |
bsdinstall distfetch | |
################################################################################ | |
## Unpack distributions with bsdinstall | |
################################################################################ | |
bsdinstall checksum | |
bsdinstall distextract | |
################################################################################ | |
## Finalize bsdinstall | |
################################################################################ | |
bsdinstall config | |
################################################################################ | |
## Run post-install script | |
################################################################################ | |
N/A | |
################################################################################ | |
## reboot | |
################################################################################ | |
cdcontrol -f /dev/cd0 eject | |
/mnt/sbin/reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment