系统之家 - 系统光盘下载网站!

当前位置:系统之家 > 系统教程 > Linux利用PXE安装虚拟机

Linux利用PXE安装虚拟机的方法

时间:2015-05-12 13:42:42 作者:shuqing 来源:系统之家 1. 扫描二维码随时看资讯 2. 请使用手机浏览器访问: https://m.xitongzhijia.net/xtjc/20150512/48082.html 手机查看 评论

  之前和友人聊天,知道可以利用PXE安装虚拟机,相信很多用户都和小编一样还不是很清楚,在这小编就把学习到的方法分享给大家。

Linux利用PXE安装虚拟机的方法

  方法如下:

  1.1 dnsmasq

  apt-get install dnsmasq

  vim /etc/dnsmasq.conf

  bogus-priv

  filterwin2k

  interface=eth0

  dhcp-range=192.168.100.172,192.168.100.180,12h

  dhcp-host=52:54:00:ed:00:f7,192.168.100.178

  dhcp-boot=pxelinux.0

  enable-tftp

  tftp-root=/var/ftpd

  dhcp-authoritative

  /etc/init.d/dnsmasq restart

  注意:如果想要为pxe client分配固定IP,可使用dhcp-host参数.采用这种方式的好处是可以避免将已经网络的IP搞乱。

  如果使用KVM提供的虚机作为pxe client来测试时, 应该每测试一次新建一个虚机(千万不能重复测试)。

  1.2 PXE

  mkdir /var/www/ubuntu

  mount -o loop/bak//kvmimages/ubuntu-11.10-server-amd64.iso /mnt

  cp /mnt/preseed/ubuntu-server.seed /var/www/ubuntu

  cp -a /mnt/* /var/www/ubuntu

  cp -r /mnt/install/netboot/* /var/ftpd/

  vim /var/ftpd/pxelinux.cfg/default

  default linux

  label linux

  kernel ubuntu-installer/amd64/linux

  append ks=https://192.168.100.171/ubuntu/ks.cfg preseed/url=https://192.168.100.171/ubuntu/ubuntu-server.seed vga=normal initrd=ubuntu-installer/amd64/initrd.gz --

  注意:上述ks,与preseed应该配置一个Web服务器指向/var/www/ubuntu目录。

  1.3 Apache

  apt-get install apache2

  vi /etc/apache2/sites-available/default

  ServerName ubuntu

  DocumentRoot /var/www/ubuntu

  Options ExecCGI FollowSymLinks

  AllowOverride all

  allow from all

  Order allow,deny

  ErrorLog/var/log/apache2/error-ubuntu.log

  sudo ln -s /etc/apache2/sites-available/default/etc/apache2/sites-enabled/ubuntu

  /etc/init.d/apache2restart

  1.4KickStart

  vi /var/www/Ubuntu/ks.cfg#System language

  lang en_US

  #Language modules to install

  langsupport en_US

  #System keyboard

  keyboard us

  #System mouse

  mouse

  #System timezone

  timezone Asia/Chongqing

  #Root password

  rootpw --disabled

  #Initial user gaojinbo/gaojinbo.com

  user hua --fullname hua --passwordpassword

  #Reboot after installation

  reboot

  #Use text mode install

  text

  #Install OS instead of upgrade

  install

  #Use Web installation

  url --urlhttps://192.168.100.171/ubuntu

  #System bootloader configuration

  bootloader --location=mbr

  #Clear the Master Boot Record

  zerombr yes

  #Partition clearing information

  clearpart --all --initlabel

  #Disk partitioning information

  part / --fstype ext4 --size 10000

  part swap --size 5000

  auth --useshadow --enablemd5

  network --bootproto=dhcp --device=eth0

  #network --bootproto=static--ip=192.168.5.168 --netmask=255.255.255.0 --gateway=192.168.100.1--nameserver=221.5.88.88 --device=eth0

  firewall --disabled

  skipx

  %packages

  @openssh-server

  1.5ubuntu-server.seed

  vi /var/www/ubuntu/ubuntu-server.seed# Suggest LVM by default.

  d-i partman-auto/init_automatically_partition stringsome_device_lvm

  d-i partman-auto/init_automatically_partition seen false

  # Always install the server kernel.

  d-i base-installer/kernel/override-image string linux-server

  # Install the Ubuntu Server seed.

  tasksel tasksel/force-tasks string server

  # Only install basic language packs.

  d-i pkgsel/language-pack-patterns string

  # No language support packages.

  d-i pkgsel/install-language-support boolean false

  # Only ask the UTC question if there are

  d-i clock-setup/utc boolean false

  d-i clock-setup/ntp boolean false

  d-i apt-setup/use_mirror boolean false

  d-i netcfg/get_ipaddress string 127.0.0.1

  d-i mirror/https://hostname string 127.0.0.1

  d-i apt-setup/restricted boolean false

  # No boot splash screen.

  d-i debian-installer/splash boolean false

  # Install the debconf oem-config frontend (if in OEM mode).

  d-i oem-config-udeb/frontend string debconf

  # Add the network and tasks oem-config steps by default.

  oem-config oem-config/steps multiselect language, \

  timezone, keyboard, user, network, tasks

  以上就是利用PXE安装虚拟机的方法了。值得注意的一点是我们如果要用虚机为pxeclient测试的话,应每测试一次新建一个虚机。

标签 PXE

发表评论

0

没有更多评论了

评论就这些咯,让大家也知道你的独特见解

立即评论

以上留言仅代表用户个人观点,不代表系统之家立场

其他版本软件

热门教程

人气教程排行

Linux系统推荐

官方交流群 软件收录