zoukankan      html  css  js  c++  java
  • CentOS 6 命令行下安装 VirtualBox 虚拟机步骤

    CentOS 6 命令行下安装 VirtualBox 虚拟机步骤

    1、 准备工作

    安装内核更新

    yum install kernel-devel
    yum update kernel*
    如果内核有更新,则需要重新启动操作系统。

    2、 安装VirtualBox

    wget http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
    rpm --import oracle_vbox.asc
    wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
    yum install VirtualBox-4.3
    3、 安装扩展包,以便使用RDP协议3389远程登录安装操作系统

    wget http://download.virtualbox.org/virtualbox/4.3.2/Oracle_VM_VirtualBox_Extension_Pack-4.3.2-90405.vbox-extpack
    VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.2-90405.vbox-extpack
    4、 创建虚拟机

    创建一个2.6或者3.0内核的操作系统虚拟机,名称为centos6,虚拟机文件存放路径在/opt/virtualbox/

    VBoxManage createvm --name centos6 --ostype Linux26_64 --register --basefolder /opt/virtualbox/
    在创建之前可以查看下支持的客户操作系统类型:

    VBoxManage list vms
    5、 创建虚拟磁盘

    创建一个150G的虚拟磁盘

    VBoxManage createvdi --filename /opt/virtualbox/centos6.vdi --size 150000
    6、 创建虚拟机的硬盘控制器

    VBoxManage storagectl centos6 --name storage_controller_1 --add ide
    7、 挂在虚拟硬盘和虚拟光驱

    VBoxManage storageattach centos6 --storagectl storage_controller_1 --type hdd --port 0 --device 0  --medium /opt/virtualbox/centos6.vdi
    VBoxManage storageattach centos6 --storagectl storage_controller_1 --type dvddrive --port 1 --device 0 --medium /opt/setup/CentOS-6.3-x86_64-LiveCD.iso
    这里将5创建好的虚拟磁盘挂载在虚拟机上,同时挂在一个虚拟光驱,加载ISO镜像文件。

    8、 设置启动顺序

    将光驱设置为第一启动顺序,以便安装操作系统。

    VBoxManage modifyvm centos6 --boot1 dvd
    VBoxManage modifyvm centos6 --boot2 disk
    9、 创建桥接的网络

    VBoxManage modifyvm centos6 --nic1 bridged --cableconnected1 on --nictype1 82540EM --bridgeadapter1 em1 --intnet1 brigh1 --macaddress1 auto
    在创建之前查看下当前宿主机器的网卡名称,例如此处是 em1

    10、 启动vrde模块

    VRDE模块用于启动RDP协议,使用微软的3389客户端即可连接。

    VBoxManage modifyvm centos6 --vrde on
    最后操作系统安装、设置完成后可以考虑关闭此屏幕输出。

    VBoxManage modifyvm centos6 --vrde off
    11、 调整系统参数

    可以此时调整虚拟机的CPU、内存等参数

    VBoxManage modifyvm centos6 --memory 4096
    VBoxManage modifyvm centos6 --cpus 2
    12、 启动虚拟机

    VBoxHeadless -startvm centos6
    13、 3389远程连接安装操作系统

    安装完操作系统即可正常使用。

    一些常见问题

    遇到问题 ‘WARNING: The vboxdrv kernel module is not loaded.’

    确认当前使用的内核和内核头文件版本完全一致:

    yum list installed|grep kernel
    然后使用vboxdrv进行配置

    /etc/init.d/vboxdrv setup
    启动、关闭虚拟机

    可以使用下列方式启动虚拟机 https://www.virtualbox.org/manual/ch08.html#vboxmanage-startvm

    VBoxManage startvm centos6 --type headless
    VBoxHeadless -startvm centos6
    关闭虚拟机,如果是前台运行的VBoxHeadless,直接CTRL+C即可。 如果是后台运行的VBoxHeadless或者VBoxManage startvm,使用

    VBoxManage controlvm centos6 poweroff
    无法使用3389端口连接?

    检查端口是否存活:

    netstat -nap|grep 3389
    ss -nap|grep 3389
    检查防火墙是否允许通过。

    虚拟机控制常用操作

    常用操作地址https://www.virtualbox.org/manual/ch08.html#vboxmanage-controlvm

    VBoxManage controlvm pause|resume|poweroff|savestate centos6
    无法使用rsa publickey登录?

    检查是否selinux禁止登录。

  • 相关阅读:
    Windows Azure Storage (17) Azure Storage读取访问地域冗余(Read Access – Geo Redundant Storage, RA-GRS)
    SQL Azure (15) SQL Azure 新的规格
    Azure China (5) 管理Azure China Powershell
    Azure China (4) 管理Azure China Storage Account
    Azure China (3) 使用Visual Studio 2013证书发布Cloud Service至Azure China
    Azure China (2) Azure China管理界面初探
    Azure China (1) Azure公有云落地中国
    SQL Azure (14) 将云端SQL Azure中的数据库备份到本地SQL Server
    [New Portal]Windows Azure Virtual Machine (23) 使用Storage Space,提高Virtual Machine磁盘的IOPS
    Android数据库升级、降级、创建(onCreate() onUpgrade() onDowngrade())的注意点
  • 原文地址:https://www.cnblogs.com/liuyansheng/p/6122961.html
Copyright © 2011-2022 走看看