#!/bin/bash date > /etc/vagrant_box_build_time #Based on http://www.funtoo.org/wiki/Funtoo_Linux_Installation #Partition the disk # Gentoo live CD were using doesn't have gdisk and it looks # to be interactive like fdisk. sfdisk is scritable but has issues. # # If you adjust, best to read this # http://www.spinics.net/lists/util-linux-ng/msg03406.html # # Basically, all partitioning programs are wonky, sfdisk is scriptable, but likes # to keeps things too tight skipping post-MBR spacing and "grub-install" fails later. # Take the advice of the email and partition your drive with fdisk and dump it with # # sfdisk -uS -d /dev/sda # # and plug those values into the script. The --force by sector will get # you what fdisk layed out and gets something grub-install can deal with. fun... # # #/boot -> /dev/sda1 200M, left 2Meg of space for grub-install #swap -> /dev/sda2 1.5G #root -> /dev/sda3 Rest of space and bootable sfdisk --force -uS /dev/sda < /mnt/funtoo/etc/fstab # The root filesystem should have a pass number of either 0 or 1. # All other filesystems should have a pass number of 0 or greater than 1. # # See the manpage fstab(5) for more information. # # /dev/sda1 /boot ext2 noauto,noatime 1 2 /dev/sda2 none swap sw 0 0 /dev/sda3 / ext4 noatime 0 1 #/dev/cdrom /mnt/cdrom auto noauto,ro 0 0 none /dev/shm tmpfs nodev,nosuid,noexec 0 0 FSTABEOF # dhcp chroot /mnt/funtoo rc-update add dhcpcd default # Get the kernel sources echo 'MAKEOPTS="-j9"' >> /mnt/funtoo/etc/make.conf #echo 'MAKEOPTS="-j9"' >> /mnt/funtoo/etc/genkernel.conf echo "sys-kernel/sysrescue-std-sources binary" >> /mnt/funtoo/etc/portage/package.use echo "app-emulation/virtualbox-guest-additions" >> /mnt/funtoo/etc/portage/package.keywords echo 'MAKEOPTS="-j9" emerge sysrescue-std-sources' | chroot /mnt/funtoo /bin/bash - # Make the disk bootable chroot /mnt/funtoo emerge boot-update cat < ./etc/boot.conf boot { generate grub default "Funtoo Linux genkernel" timeout 3 } "Funtoo Linux" { kernel bzImage[-v] # params += nomodeset } "Funtoo Linux genkernel" { kernel kernel[-v] initrd initramfs[-v] params += real_root=auto # params += nomodeset } GRUBCONF chroot /mnt/funtoo grub-install --no-floppy /dev/sda chroot /mnt/funtoo boot-update #Root password, needed since we're a two step installation chroot /mnt/funtoo /bin/bash < /mnt/funtoo/etc/hosts.allow echo 'ALL:ALL' > /mnt/funtoo/etc/hosts.deny #Configure Sudo chroot /mnt/funtoo emerge -u sudo echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /mnt/funtoo/etc/sudoers #Installing vagrant keys chroot /mnt/funtoo emerge -u wget echo "creating vagrant ssh keys" VAGRANTID=$(grep vagrant /mnt/funtoo/etc/passwd | cut -d ":" -f 3,4) mkdir /mnt/funtoo/home/vagrant/.ssh chmod 700 /mnt/funtoo/home/vagrant/.ssh wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /mnt/funtoo/home/vagrant/.ssh/authorized_keys chmod 600 /mnt/funtoo/home/vagrant/.ssh/authorized_keys chown -R ${VAGRANTID} /mnt/funtoo/home/vagrant/.ssh /bin/cp -f /root/.vbox_version /mnt/funtoo/home/vagrant/.vbox_version /bin/cp -f /etc/vagrant_box_build_time /mnt/funtoo/etc/vagrant_box_build_time chown -R ${VAGRANTID} /mnt/funtoo/home/vagrant/.vbox_version # veewee validate uses password authentication sed -i -e 's:PasswordAuthentication no:PasswordAuthentication yes:' /mnt/funtoo/etc/ssh/sshd_config #Get an editor going chroot /mnt/funtoo emerge -u vim echo "EDITOR=/usr/bin/vim" > /mnt/funtoo/etc/env.d/99editor chroot /mnt/funtoo env-update cd / /etc/rc.d/network stop umount /mnt/funtoo/{boot,proc,dev} umount /mnt/funtoo reboot