今度はCentOS 5.10のbox作成手順。
Vagrant 1.4.xで作成しました
[構成]
・CentOS 5.10 x86_64 CentOS-5.10-x86_64-netinstall.iso http://ftp.jaist.ac.jp/pub/Linux/CentOS/5.10/isos/x86_64/ ・CPU 1コア ・MEM 768MB ・Disk ・Disk1 40GiB 可変 ・/boot 101MiB ext3 ・/(root) 36,750MiB ext3 ・swap 4,102MiB ・ネットワーク ・NAT Intel PRO/1000 MT Desktop(8254OEM)
[設定]
・Domain localhost.localdomain ・Timezone Asia/Tokyo (System Clock UTC) ・言語 Japanese ・キーボード US ・root vagrant
[パッケージ]
・日本語サポート ・ベースシステム
[初期設定]
・iptables 無効化 ・SELinux Disabled
[OSインストール後]
1. アップデート
# yum update -y # yum clean all # shutdown -r now
2. vagrant ユーザー作成
# user add vagrant # passwd vagrant vagrant
3. sudoers
# visudo vagrant ALL=(ALL) NOPASSWD: ALL
を追加。
Defaults requiretty をコメントアウト
4. ssh keyを追加
# su - vagrant $ mkdir .ssh $ chmod 0700 .ssh $ cd .ssh $ wget https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O authorized_keys $ chmod 0600 authorized_keys
5. sshd 設定
# vi /etc/ssh/sshd_config UseDNS no # /etc/init.d/sshd restart
# vi /boot/grub/grub.conf timeout=0
7. virtual box guest addon
# yum install kernel-devel gcc # yum clean all # mount /dev/cdrom /media # /media/VBoxLinuxAdditions.run # umount /dev/cdrom
8. swapをなるべく使わない設定にする
# vi /etc/sysctl.conf vm.swappiness = 0
9. 古いKernel削除
# yum install -y yum-utils # package-cleanup --oldkernels --count=1 # package-cleanup --leaves # yum erase $(package-cleanup --leaves | tail -n +2)
10. 履歴消去
(再ログイン)
# HISTIGNORE=* # cat /dev/null > /home/vagrant/.bash_history # cat /dev/null > ~/.bash_history
11. ゼロ埋め
# dd if=/dev/zero of=/zerofile # rm -f /zerofile
12. 停止。ディスクファイル圧縮
# shutdown -h now Hostで実行 $ VBoxManage modifyhd --compact "CentOS 5.10.vdi" 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
[boxを作成]
$ VBoxManage list vms (省略) "CentOS 5.10" {d24446be-b645-4162-8426-ed57d6b0eb1d} $ vagrant package --base "CentOS 5.10" --output centos510.x86_64.20140302.box
[test]
$ vagrant box add test centos510.x86_64.20140302.box $ vagrant init test $ vagrant up
参考:
Creating a Base Box - Vagrant Documentation
vagrantでVirtualBox4.3用のbox作り方 (ubuntu13.10) - Qiita [キータ]