Skip to content


Subversion checkout URL

You can clone with
Download ZIP


add adaptable template for funtoo x86_64 with rbenv #412

merged 4 commits into from

2 participants


This is another template for a 64 bit Funtoo system.
It produces a fully validating Vagrant box, includes the current ruby version 1.9.3-p286 installed under a global rbenv installation and is geared towards extension - a lot of variables are set at the top and it would be easy to derive a 32 bit system or switch from Funtoo to Gentoo.
Building and packaging it results in a box 1GB in size, but including the full Kernel sources and a recent snapshot of the package tree.
I included the build date in the specification as Gentoo and Funtoo use rolling releases, but it's easily adaptable in the top of

Arne Hormann added some commits

@ahormann thanks for creating that.

@jedi4ever jedi4ever merged commit 2d162d5 into jedi4ever:master
@petecheslock petecheslock referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 17, 2012
  1. added alternative funtoo box (1 cpu, low memory, rbenv with global ru…

    Arne Hormann committed
    …by support and onle one postinstall stage, requires manual reboot for now)
  2. Merge branches 'patch-1', 'patch-2' and 'patch-3'

    Arne Hormann committed
Commits on Oct 22, 2012
  1. Merge remote-tracking branch 'upstream/master'

    Arne Hormann committed
Commits on Oct 24, 2012
  1. added simpler funtoo x86_64

    Arne Hormann committed
This page is out of date. Refresh to see the latest.
37 templates/funtoo-latest-x86_64/definition.rb
@@ -0,0 +1,37 @@
+password = 'vagrant'
+ :hostiocache => 'off',
+ :cpu_count => '1',
+ :memory_size=> '384',
+ :disk_size => '10140',
+ :disk_format => 'VDI',
+ :os_type_id => 'Gentoo_64', # for 32bit, change to 'Gentoo'
+ :iso_file => "systemrescuecd-x86-3.0.0.iso",
+ :iso_src => "",
+ :iso_md5 => "6bb6241af752b1d6dab6ae9e6e3e770e",
+ :iso_download_timeout => "1000",
+ :boot_wait => "4",
+ :boot_cmd_sequence => [
+ '<Wait>'*1,
+ '<Enter>',
+ '<Wait>'*9,
+ '<Enter>',
+ '<Wait>'*12,
+ '<Enter><Wait>', # just in case we are out of sync
+ 'net-setup eth0<Enter><Wait><Enter>2<Enter>1<Enter><Wait><Wait>',
+ 'passwd<Enter><Wait><Wait>',
+ password + '<Enter><Wait>',
+ password + '<Enter><Wait><Wait>'
+ ],
+ :ssh_login_timeout => "10000",
+ :ssh_user => "root",
+ :ssh_password => password,
+ :ssh_key => "",
+ :ssh_host_port => "7222",
+ :ssh_guest_port => "22",
+ :sudo_cmd => "cat '%f'|su -",
+ :shutdown_cmd => "shutdown -p now",
+ :postinstall_files => [""],
+ :postinstall_timeout => "15000"
401 templates/funtoo-latest-x86_64/
@@ -0,0 +1,401 @@
+# based on
+### SETTINGS ###
+# user passwords for password based ssh logins
+# static versions of programs we install
+# ...these are for rbenv and its plugins ruby-builder and rbenv-bundler
+# these two (configuring the compiler) and the stage3 url can be changed to build a 32 bit system
+# stage 3 filename and full url
+# the public key for vagrants ssh
+# timezone (as a subdirectory of /usr/share/zoneinfo)
+# number of cpus in the host system (to speed up make andfor kernel config)
+nr_cpus=$(</proc/cpuinfo grep processor|wc -l)
+# for sgdisk (scripted gdisk) see:
+sgdisk -n 1:0:+128M -t 1:8300 -c 1:"linux-boot" \
+ -n 2:0:+32M -t 2:ef02 -c 2:"bios-boot" \
+ -n 3:0:+1G -t 3:8200 -c 3:"swap" \
+ -n 4:0:0 -t 4:8300 -c 4:"linux-root" \
+ -p /dev/sda
+sleep 1
+# format partitions, mount swap
+mkswap /dev/sda3
+swapon /dev/sda3
+mkfs.ext2 /dev/sda1
+mkfs.ext4 /dev/sda4
+# this is our chroot directory for the installation
+# mount other partitions
+mount /dev/sda4 "$chroot" && cd "$chroot" && mkdir boot && mount /dev/sda1 boot
+# load stage 3, unpack it, delete the stage3 archive file
+wget -nv --tries=5 "$stage3url"
+tar xpf "$stage3file" && rm "$stage3file"
+# prepeare chroot, update env
+mount --bind /proc "$chroot/proc"
+mount --bind /dev "$chroot/dev"
+# copy nameserver information, save build timestamp
+cp /etc/resolv.conf "$chroot/etc/"
+date -u > "$chroot/etc/vagrant_box_build_time"
+chroot "$chroot" env-update
+#" activate client side dhcp and ssh by default
+chroot "$chroot" /bin/bash <<DATAEOF
+rc-update add dhcpcd default
+rc-update add sshd default
+# set fstab
+cat <<DATAEOF > "$chroot/etc/fstab"
+# <fs> <mountpoint> <type> <opts> <dump/pass>
+/dev/sda1 /boot ext2 noauto,noatime 1 2
+/dev/sda3 none swap sw 0 0
+/dev/sda4 / ext4 noatime 0 1
+none /dev/shm tmpfs nodev,nosuid,noexec 0 0
+# set make options
+cat <<DATAEOF > "$chroot/etc/portage/make.conf"
+CFLAGS="-mtune=generic -O2 -pipe"
+MAKEOPTS="-j$((1 + $nr_cpus)) -l$nr_cpus.5"
+EMERGE_DEFAULT_OPTS="-j$nr_cpus --quiet-build=y"
+FEATURES="\${FEATURES} parallel-fetch"
+# english only
+# for X support if needed
+# add package use flags
+cat <<DATAEOF >> "$chroot/etc/portage/package.use"
+sys-kernel/gentoo-sources symlink
+sys-kernel/genkernel -cryptsetup
+# add package keywords
+cat <<DATAEOF >> "$chroot/etc/portage/package.keywords"
+# update portage tree to most current state
+chroot "$chroot" emerge --sync
+# set localtime
+chroot "$chroot" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime
+# get, configure, compile and install the kernel and modules
+chroot "$chroot" /bin/bash <<DATAEOF
+emerge sys-kernel/gentoo-sources sys-kernel/genkernel sys-boot/boot-update
+# specialize for VirtualBox - use loaded modules in livecd
+cd /usr/src/linux
+# use a default configuration as a starting point, then disable all currently unused modules
+make defconfig
+#make localyesconfig
+# add settings for VirtualBox kernels to end of .config
+cat <<EOF >>/usr/src/linux/.config
+# dependencies
+# for VirtualBox
+# see
+# for net fs
+# reduce size
+# propbably nice but not in defaults
+# IPSec (I want to run tests with IPSec andSamba 4)
+# and some more crypto support...
+# build and install kernel, using the config created above
+genkernel --install --symlink --oldconfig all
+# install the virtualbox guest additions, add vagrant and root to group vboxguest
+# PREREQUISITE: kernel - we install a module, so we use the kernel sources
+chroot "$chroot" /bin/bash <<DATAEOF
+emerge app-emulation/virtualbox-guest-additions
+# we need this as gentoo doesn't do it on its own
+groupadd -r vboxsf
+mkdir /media && chgrp vboxsf /media
+rc-update add virtualbox-guest-additions default
+# add default users and groups, setpasswords, configure privileges and install sudo
+mkdir -p "$chroot/home/vagrant/.ssh"
+chmod 700 "$chroot/home/vagrant/.ssh"
+wget --no-check-certificate "$vagrant_ssh_key_url" -O "$chroot/home/vagrant/.ssh/authorized_keys"
+chmod 600 "$chroot/home/vagrant/.ssh/authorized_keys"
+cp -f /root/.vbox_version "$chroot/home/vagrant/.vbox_version"
+# for passwordless logins
+mkdir -p "$chroot/root/.ssh" 2> /dev/null
+cat /tmp/ >> "$chroot/root/.ssh/authorized_keys"
+# PREREQUISITE: virtualbox-guest-additions - the groups created on installation have to exist
+chroot $chroot /bin/bash <<DATAEOF
+groupadd -r vagrant
+groupadd -r rbenv
+useradd -m -r vagrant -g vagrant -G wheel,rbenv,vboxsf,vboxguest -c 'added by vagrant, veewee basebox creation'
+# set passwords (for after reboot)
+passwd vagrant<<EOF
+# to each its own... home
+chown -R vagrant /home/vagrant
+emerge app-admin/sudo
+echo 'sshd:ALL' > /etc/hosts.allow
+echo 'ALL:ALL' > /etc/hosts.deny
+echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
+# configure ssh daemon
+# veewee validate uses password authentication (according to the other Funtoo-template), so we have to enable it
+cat <<DATAEOF > "$chroot/etc/ssh/sshd_config"
+HostBasedAuthentication no
+IgnoreUserKnownHosts yes
+PasswordAuthentication yes
+PermitRootLogin yes
+#PermitRootLogin without-password
+PermitUserEnvironment no
+PrintLastLog no
+PrintMotd no
+PubKeyAuthentication yes
+Subsystem sftp internal-sftp
+UseDNS no
+UsePAM yes
+UsePrivilegeSeparation sandbox
+# install rbenv, ruby and bundler. Configure rbenv for global usage so it's usable without home directory
+chroot "$chroot" /bin/bash <<DATAEOF
+cd /usr/local/lib
+git clone git://
+cd rbenv
+git checkout -b "$rbenv_version" "$rbenv_version"
+mkdir -p env/plugins
+cd env/plugins
+git clone git://
+cd ruby-build
+git checkout -b "$ruby_builder_version" "$ruby_builder_version"
+cd ..
+git clone git://
+cd rbenv-bundler
+git checkout -b "$rbenv_bundler_version" "$rbenv_bundler_version"
+chgrp -R rbenv /usr/local/lib/rbenv
+libtool --finish /usr/lib64
+# add rbenv to profile
+cat <<DATAEOF >> "$chroot/etc/profile.d/"
+# add rbenv support
+export PATH=\$PATH:\$rbenv_base/bin
+[ -n \$RBENV_ROOT ] && export RBENV_ROOT=\$rbenv_base/env
+eval "\$(rbenv init -)"
+# install ruby, bundler, chef and puppet
+chroot "$chroot" /bin/bash <<DATAEOF
+env-update && source /etc/profile
+# install ruby, use it as global version
+emerge dev-libs/libyaml
+rbenv install "$ruby_version"
+rbenv global "$ruby_version"
+# disable rdoc and ri
+mkdir -p "/usr/local/lib/rbenv/env/versions/$ruby_version/etc"
+cat <<EOF > "/usr/local/lib/rbenv/env/versions/$ruby_version/etc/gemrc"
+# disable rdoc and ri
+install: --no-rdoc --no-ri
+update: --no-rdoc --no-ri
+# install required and desired gems
+gem install bundler chef puppet
+# install logger and cron
+chroot "$chroot" /bin/bash <<DATAEOF
+emerge app-admin/rsyslog sys-process/vixie-cron
+rc-update add rsyslog default
+rc-update add vixie-cron default
+# install nfs and automount support
+# chroot "$chroot" emerge net-fs/nfs-utils net-fs/autofs
+# make the disk bootable
+chroot "$chroot" /bin/bash <<DATAEOF
+source /etc/profile && \
+env-update && \
+grub-install --no-floppy /dev/sda && \
+# a fresh install probably shouldn't nag about news
+chroot "$chroot" /usr/bin/eselect news read all
+# cleanup time...
+chroot "$chroot" /bin/bash <<DATAEOF
+# delete temp, cached and build artifact data - some low hanging fruit...
+eclean -d distfiles
+rm /tmp/*
+rm -rf /var/log/*
+rm -rf /var/tmp/*
+# there's some leftover junk by gem installation in the root folder
+# don't know where this is from (/root/.gem/specs/, but it should go...
+# we use a global ruby by default
+# ...probably hard coded path by mistake, report to upstream? Which upstream?!?
+rm -rf /root/.gem
+# here's some savings crippling the usage of this box (sorted descending by damage)
+#rm -rf /usr/local/lib/rbenv/.git
+#rm -rf /usr/local/lib/rbenv/env/plugins/*/.git
+#rm -rf /usr/src/linux*
+#rm -rf /usr/portage/.git
+# fill all free hdd space with zeros
+dd if=/dev/zero of="$chroot/boot/EMPTY" bs=1M
+rm "$chroot/boot/EMPTY"
+dd if=/dev/zero of="$chroot/EMPTY" bs=1M
+rm "$chroot/EMPTY"
+# fill all swap space with zeros and recreate swap
+swapoff /dev/sda3
+shred -n 0 -z /dev/sda3
+mkswap /dev/sda3
Something went wrong with that request. Please try again.