diff --git a/packer/freebsd-9.1-amd64.json b/packer/freebsd-9.2-amd64.json similarity index 74% rename from packer/freebsd-9.1-amd64.json rename to packer/freebsd-9.2-amd64.json index 1549d45de..adfa8e2d3 100644 --- a/packer/freebsd-9.1-amd64.json +++ b/packer/freebsd-9.2-amd64.json @@ -29,16 +29,17 @@ "", "/bin/sh", "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "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, @@ -46,10 +47,10 @@ "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" ] ] }, @@ -66,26 +67,27 @@ "", "/bin/sh", "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", "", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "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" } @@ -93,7 +95,7 @@ ], "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" } ] diff --git a/packer/freebsd-9.1-i386.json b/packer/freebsd-9.2-i386.json similarity index 73% rename from packer/freebsd-9.1-i386.json rename to packer/freebsd-9.2-i386.json index e7a0387cf..32340d89a 100644 --- a/packer/freebsd-9.1-i386.json +++ b/packer/freebsd-9.2-i386.json @@ -28,16 +28,17 @@ "", "/bin/sh", "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "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, @@ -45,8 +46,8 @@ "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" ] @@ -65,24 +66,25 @@ "", "/bin/sh", "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", "", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.2/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "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", @@ -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" } ] diff --git a/packer/http/freebsd-9.1/install.sh b/packer/http/freebsd-9.2/install.sh similarity index 66% rename from packer/http/freebsd-9.1/install.sh rename to packer/http/freebsd-9.2/install.sh index 1126e39ed..5922b434a 100644 --- a/packer/http/freebsd-9.1/install.sh +++ b/packer/http/freebsd-9.2/install.sh @@ -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 @@ -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 @@ -46,28 +44,29 @@ 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" @@ -75,7 +74,7 @@ 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" @@ -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 -