如何制作一个vagrant的base box

最新完整版制作流程,请参考:

https://blog.csdn.net/ghostyusheng/article/details/90265422

----

步骤如下:(环境 OS:ubuntu12.04_Desktop  virtualbox:4.1.12)

1.在物理机安装好ubuntu系统,在此系统上安装virtualbox

2.下载一个需要的ubuntu版本的iso镜像

3.创建一个新的虚拟机

  • 给虚拟机起个名字为"vagrant-precise32"

  • 确保您分配足够的磁盘空间,40GB足够了。

  • 确保默认的内存分配也不用太高,建议360M。

  • 如果不需要,禁用音频,USB控制器等。大多数应用程序都不需要播放音乐!因此,节约资源,禁用这些功能。

  • 确保网络控制器设置为NAT,为了端口转发正常工作。

4.启动虚拟机,安装ubuntu,确保配置如下(非强制,如打算分发此box,建议遵循如下约定)

  • Hostname:vagrant-[os-name],例:vagrant-ubuntu-Steve

  • Domain: vagrantup.com

  • Root Password: vagrant

  • Main account login: vagrant

  • Main account password: vagrant

5.安装完毕后,进入虚拟机

6.根据自己需要,安装一些常用软件

 sudo apt-get -y install vim

7.创建admin组

 sudo groupadd admin

8.添加vagrant用户到admin组

 sudo usermod -G admin vagrant

9.修改sudoers文件

 sudo vim /etc/sudoers      #添加或修改如下行(有些发行版还需Disable requiretty):

   Defaults env_keep="SSH_AUTH_SOCK"

   %admin ALL=NOPASSWD: ALL

10.安装puppet(chef没有计划装进去,如需要可安装ruby,rubygems,chef)

 sudo apt-get install puppet puppetmaster

11.安装ssh

 sudo apt-get install openssh-server

12.安装vagrant的public keys

 mkdir ~/.ssh/

 cd ~/.ssh

 wget http://github.com/mitchellh/vagrant/raw/master/keys/vagrant

 wget http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub

 mv vagrant.pub authorized_keys

13.Install virtual box guest additions(为了共享文件夹,端口转发等) (参考https://my.oschina.net/jsk/blog/289275)

 (1) First, build the necessary packages. You may have to look these up for your system, but they should be fairly similar. On Ubuntu and Debian based systems they are as follows:

  $ sudo apt-get install linux-headers-$(uname -r) build-essential

 (2) Next, make sure to insert the guest additions image by using the GUI and clicking on “Devices” followed by “Install Guest Additions.”. Then run the following to mount the CD Rom:

  $ sudo mount /dev/cdrom /media/cdrom

 (3) And finally, run the shell script which matches your system. For linux on x86, it is the following:

  $ sudo sh /media/cdrom/VBoxLinuxAdditions.run

     If you didn’t install a Desktop environment when you installed the operating system, as recommended to reduce size, the install of the VirtualBox additions should warn you about the lack of OpenGL or Window System Drivers, but you can safely ignore this.

14.清除缓存

  sudo apt-get clean

15.关闭虚拟机,进入virtual box directory(~/VirtualBox VM/vagrant-precise32)

  vagrant package --output ubuntu_32.box --base vagrant-precise32

 

----vagrantfile 参考  (https://blog.csdn.net/ghostyusheng/article/details/64923272  config.ssh.username = "vagrant"  )要配

 

 

---相关报错参考

The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the

https://blog.csdn.net/angel22xu/article/details/44117991

 

报错2 一定会碰到

原因: vagrant 要满足 sudo  不输入密码可以执行命令

1.su  - root

2.chmod 777 /etc/sudoers

3. vim /etc/sudoers

4.添加红色框内容

5.chmod 555 /etc/sudoers

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值