Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade FreeBSD box to 9.2 #127

Merged
merged 1 commit into from
Dec 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions packer/freebsd-9.1-amd64.json → packer/freebsd-9.2-amd64.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@
"<wait10><wait10>",
"/bin/sh<enter><wait>",
"mdmfs -s 100m md1 /tmp<enter><wait>",
"mdmfs -s 100m md2 /mnt<enter><wait>",
"dhclient -l /tmp/dhclient.lease.em0 em0<enter><wait>",
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 10140,
"guest_os_type": "FreeBSD_64",
"http_directory": "http",
"iso_checksum": "f0a320fd52383c42649d48ea545915a9",
"iso_checksum_type": "md5",
"iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.1/FreeBSD-9.1-RELEASE-amd64-disc1.iso",
"iso_checksum": "a8c1751b83646530148766618a89a97009e7500e7057a5cbe3afd74ef480c915",
"iso_checksum_type": "sha256",
"iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.2/FreeBSD-9.2-RELEASE-amd64-disc1.iso",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"virtualbox_version_file": ".vbox_version",
"vm_name": "packer-freebsd-9.1-amd64",
"output_directory": "packer-freebsd-9.1-amd64",
"vm_name": "packer-freebsd-9.2-amd64",
"output_directory": "packer-freebsd-9.2-amd64",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--memory", "768" ],
[ "modifyvm", "{{.Name}}", "--memory", "512" ],
[ "modifyvm", "{{.Name}}", "--cpus", "1" ]
]
},
Expand All @@ -66,34 +67,35 @@
"<wait10><wait10>",
"/bin/sh<enter><wait>",
"mdmfs -s 100m md1 /tmp<enter><wait>",
"mdmfs -s 100m md2 /mnt<enter><wait>",
"dhclient -l /tmp/dhclient.lease.em0 em0<enter><wait>",
"<wait5>",
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 10140,
"guest_os_type": "freebsd-64",
"http_directory": "http",
"iso_checksum": "f0a320fd52383c42649d48ea545915a9",
"iso_checksum_type": "md5",
"iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.1/FreeBSD-9.1-RELEASE-amd64-disc1.iso",
"iso_checksum": "a8c1751b83646530148766618a89a97009e7500e7057a5cbe3afd74ef480c915",
"iso_checksum_type": "sha256",
"iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.2/FreeBSD-9.2-RELEASE-amd64-disc1.iso",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -",
"vm_name": "packer-freebsd-9.1-amd64",
"output_directory": "packer-freebsd-9.1-amd64",
"vm_name": "packer-freebsd-9.2-amd64",
"output_directory": "packer-freebsd-9.2-amd64",
"vmx_data": {
"memsize": "768",
"memsize": "512",
"numvcpus": "1",
"cpuid.coresPerSocket": "1"
}
}
],
"post-processors": [
{
"output": "../builds/{{.Provider}}/opscode_freebsd-9.1_chef-{{user `chef_version`}}.box",
"output": "../builds/{{.Provider}}/opscode_freebsd-9.2_chef-{{user `chef_version`}}.box",
"type": "vagrant"
}
]
Expand Down
28 changes: 15 additions & 13 deletions packer/freebsd-9.1-i386.json → packer/freebsd-9.2-i386.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@
"<wait10><wait10>",
"/bin/sh<enter><wait>",
"mdmfs -s 100m md1 /tmp<enter><wait>",
"mdmfs -s 100m md2 /mnt<enter><wait>",
"dhclient -l /tmp/dhclient.lease.em0 em0<enter><wait>",
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 10140,
"guest_os_type": "FreeBSD",
"http_directory": "http",
"iso_checksum": "e37d86ce83908bf4b667fdae7298bca5",
"iso_checksum_type": "md5",
"iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/9.1/FreeBSD-9.1-RELEASE-i386-disc1.iso",
"iso_checksum": "76093c27288f0ab939a5de14b621ec8eb1420d96343132c2b7c382747d35b67c",
"iso_checksum_type": "sha256",
"iso_url": "{{user `mirror`}}/releases/i386/ISO-IMAGES/9.2/FreeBSD-9.2-RELEASE-i386-disc1.iso",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"virtualbox_version_file": ".vbox_version",
"vm_name": "packer-freebsd-9.1-i386",
"output_directory": "packer-freebsd-9.1-i386",
"vm_name": "packer-freebsd-9.2-i386",
"output_directory": "packer-freebsd-9.2-i386",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--memory", "768" ],
[ "modifyvm", "{{.Name}}", "--cpus", "1" ]
Expand All @@ -65,24 +66,25 @@
"<wait10><wait10>",
"/bin/sh<enter><wait>",
"mdmfs -s 100m md1 /tmp<enter><wait>",
"mdmfs -s 100m md2 /mnt<enter><wait>",
"dhclient -l /tmp/dhclient.lease.em0 em0<enter><wait>",
"<wait5>",
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
"fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 10140,
"guest_os_type": "freebsd",
"http_directory": "http",
"iso_checksum": "e37d86ce83908bf4b667fdae7298bca5",
"iso_checksum_type": "md5",
"iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/9.1/FreeBSD-9.1-RELEASE-i386-disc1.iso",
"iso_checksum": "76093c27288f0ab939a5de14b621ec8eb1420d96343132c2b7c382747d35b67c",
"iso_checksum_type": "sha256",
"iso_url": "{{user `mirror`}}/releases/i386/ISO-IMAGES/9.2/FreeBSD-9.2-RELEASE-i386-disc1.iso",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -",
"vm_name": "packer-freebsd-9.1-i386",
"output_directory": "packer-freebsd-9.1-i386",
"vm_name": "packer-freebsd-9.2-i386",
"output_directory": "packer-freebsd-9.2-i386",
"vmx_data": {
"memsize": "768",
"numvcpus": "1",
Expand All @@ -92,7 +94,7 @@
],
"post-processors": [
{
"output": "../builds/{{.Provider}}/opscode_freebsd-9.1-i386_chef-{{user `chef_version`}}.box",
"output": "../builds/{{.Provider}}/opscode_freebsd-9.2-i386_chef-{{user `chef_version`}}.box",
"type": "vagrant"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh -x

# Credit: http://www.aisecure.net/2011/05/01/root-on-zfs-freebsd-current/
#
# Heavily re-adapted from https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot
# by Julian Dunn (jdunn@opscode.com) to remove legacy junk

NAME=$1

Expand All @@ -17,14 +20,9 @@ gpart add -b 34 -s 94 -t freebsd-boot $DISKSLICE
gpart add -t freebsd-zfs -l disk0 $DISKSLICE
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISKSLICE

# align disks
gnop create -S 4096 /dev/gpt/disk0
zpool create -o altroot=/mnt -o cachefile=/tmp/zpool.cache zroot /dev/gpt/disk0.nop
zpool export zroot
gnop destroy /dev/gpt/disk0.nop
zpool import -o altroot=/mnt -o cachefile=/tmp/zpool.cache zroot

zpool create -o altroot=/mnt -o cachefile=/tmp/zpool.cache zroot /dev/gpt/disk0
zpool set bootfs=zroot zroot

zfs set checksum=fletcher4 zroot

# set up zfs pools
Expand All @@ -46,36 +44,37 @@ zfs create -o exec=off -o setuid=off zroot/var/run
zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/tmp

# fixup
chmod 1777 /mnt/tmp
cd /mnt ; ln -s usr/home home
sleep 10
chmod 1777 /mnt/var/tmp
chmod 1777 /mnt/zroot/tmp
cd /mnt/zroot ; ln -s usr/home home
chmod 1777 /mnt/zroot/var/tmp

# set up swap
zfs create -V 2G zroot/swap
zfs set org.freebsd:swap=on zroot/swap
zfs set checksum=off zroot/swap
swapon /dev/zvol/zroot/swap

# Install the OS
cd /usr/freebsd-dist
cat base.txz | tar --unlink -xpJf - -C /mnt
cat lib32.txz | tar --unlink -xpJf - -C /mnt
cat kernel.txz | tar --unlink -xpJf - -C /mnt
cat src.txz | tar --unlink -xpJf - -C /mnt
cat base.txz | tar --unlink -xpJf - -C /mnt/zroot
cat lib32.txz | tar --unlink -xpJf - -C /mnt/zroot
cat kernel.txz | tar --unlink -xpJf - -C /mnt/zroot
cat src.txz | tar --unlink -xpJf - -C /mnt/zroot

cp /tmp/zpool.cache /mnt/zroot/boot/zfs/zpool.cache

cp /tmp/zpool.cache /mnt/boot/zfs/zpool.cache
zfs set readonly=on zroot/var/empty

sleep 10
# Enable required services
cat >> /mnt/etc/rc.conf << EOT
cat >> /mnt/zroot/etc/rc.conf << EOT
zfs_enable="YES"
hostname="${NAME}"
ifconfig_em0="dhcp"
sshd_enable="YES"
EOT

# Tune and boot from zfs
cat >> /mnt/boot/loader.conf << EOT
cat >> /mnt/zroot/boot/loader.conf << EOT
zfs_load="YES"
vfs.root.mountfrom="zfs:zroot"
vm.kmem_size="200M"
Expand All @@ -84,16 +83,21 @@ vfs.zfs.arc_max="40M"
vfs.zfs.vdev.cache.size="5M"
EOT

# Enable swap
echo '/dev/gpt/swap0 none swap sw 0 0' > /mnt/etc/fstab
# zfs doesn't use an fstab, but some rc scripts expect one
touch /mnt/zroot/etc/fstab

# Set up user accounts
zfs create zroot/usr/home/vagrant
echo "vagrant" | pw -V /mnt/etc useradd vagrant -h 0 -s csh -G wheel -d /home/vagrant -c "Vagrant User"
echo "vagrant" | pw -V /mnt/etc usermod root
echo "vagrant" | pw -V /mnt/zroot/etc useradd vagrant -h 0 -s csh -G wheel -d /home/vagrant -c "Vagrant User"
echo "vagrant" | pw -V /mnt/zroot/etc usermod root

chown 1001:1001 /mnt/home/vagrant
chown 1001:1001 /mnt/zroot/home/vagrant

zfs unmount -a
zfs set mountpoint=legacy zroot
zfs set mountpoint=/tmp zroot/tmp
zfs set mountpoint=/usr zroot/usr
zfs set mountpoint=/var zroot/var

# Reboot
reboot