远程重装系统 linux centos7 , pxe局域网安装centos7 配置文件类似

作者:csuper 发表于:2016-12-19

 

远程重装系统 linux centos7 , pxe局域网安装centos7  配置文件类似

A、首先登录到服务器,下载如下2个文件到服务器的/boot目录中:


http://mirrors.163.com/centos/7.3.1611/os/x86_64/images/pxeboot/initrd.img
http://mirrors.163.com/centos/7.3.1611/os/x86_64/images/pxeboot/vmlinuz
 
这2个文件是64位CentOS 的内核文件,这2个文件将会启动新Linux系统的安装。如果新Linux系统是其他版本的Linux,则需要下载相应版本的内核

文件。

 

B、安装grub   (centos7已经有了 grub2)
 
 
     yum install grub -y


C、修改Grub配置文件   如果原来系统是centos6 或者centos5

vi /boot/grub/grub.conf

修改服务器的/boot/grub/grub.conf文件,在这个配置文件中,添加如下启动项:
 


title CentOS Remote Install
root (hd0,0)
kernel /boot/vmlinuz.7  vnc vncpassword=12345678 headless ip=10.233.233.80 netmask=255.255.255.0 gateway=10.233.233.251 dns=114.114.114.114 hostname=m.csuper.cn  ksdevice=ens32   inst.repo=http://mirrors.163.com/centos/7.3.1611/os/x86_64/  inst.stage2=ftp://10.233.233.239/centos/centos7 LANG=zh_CN.UTF-8 keymap=us
initrd /boot/boot/initrd.7.img 

#这两个文件名就是刚才下载的时候的文件名,可以自己定义

 ksdevice=ens32 实体机需要根据具体情况 事先查找默认命名 如(我的台式机就是p4p1)   虚拟机中,VMware E1000 Ethernet Controller对应的网卡名称为ens32 必须根据具体情况 查看当前网卡的名字填写  不修改此处可以在安装的时候 按TAB键  然后修改后回车执行安装也行

因为centos7中 网卡默认名字不叫eth

===============================================================================

然后需要把这个启动项配置为grub的默认启动项,可以通过修改grub.conf中的default参数来实现,或者把该启动项放到配置文件中的default指定的位置也可以。

需要非常注意的是以上启动项里面的参数,要根据实际情况作调整。比如root参数,要和grub.conf中的其他root参数一致;kernel参数和initrd参数后面的路径(是否/boot/开头)也要和grub.conf中的其他项一致;ip地址,子网掩码和网关地址一定要和服务器一致;ksdevice是主网卡method后面的地址是新Linux系统的安装文件地址。如果这些配置有一项出错,就会导致远程安装失败。

仔细检查前面您做的工作,确保万无一失,然后在服务器上执行reboot重启服务器。大概几分钟后,通过VNC连接到10.233.233.80:1,VNC密码是12345678,就可以开始安装Linux了。

 


如果原来系统是centos7 

vi /boot/grub2/grub.conf


# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)' --class centos --class gnu-linux

--class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64

-advanced-f3b31480-6aa8-45c2-8f97-30fa71e998b7' {
 load_video
 set gfxpayload=keep
 insmod gzio
 insmod part_msdos
 insmod xfs
 set root='hd0,msdos1'
 if [ x$feature_platform_search_hint = xy ]; then
   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-

efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  f7453d3b-51f2-49bc-80bd-

a2bd99cbe2fb
 else
   search --no-floppy --fs-uuid --set=root f7453d3b-51f2-49bc-80bd-a2bd99cbe2fb
 fi
 linux16 /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto

rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet.UTF-8
 initrd16 /initramfs-3.10.0-514.el7.x86_64.img
}
menuentry 'CentOS Linux install' --class centos --class gnu-linux --class gnu --class os

--unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-f3b31480-6aa8

-45c2-8f97-30fa71e998b7' {
 load_video
 set gfxpayload=keep
 insmod gzio
 insmod part_msdos
 insmod xfs
 set root='hd0,msdos1'
 if [ x$feature_platform_search_hint = xy ]; then
   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-

efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  f7453d3b-51f2-49bc-80bd-

a2bd99cbe2fb
 else
   search --no-floppy --fs-uuid --set=root f7453d3b-51f2-49bc-80bd-a2bd99cbe2fb
 fi
 linux16 /vmlinuz  vnc vncpassword=12345678 headless ip=10.233.233.81

netmask=255.255.255.0 gateway=10.233.233.251 dns=10.233.233.253 hostname=m.csuper.cn

ksdevice=ens32  inst.repo=http://mirrors.163.com/centos/7.3.1611/os/x86_64/  inst.stage2=ftp://10.233.233.239/centos/centos7 LANG=zh_CN.UTF-8  #此处地址还可以为 镜像地址  inst.repo必须为镜像地址

initrd16 /initrd.img 
}
 


### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

 

版权声明

本文仅代表作者观点,不代表Csuper立场。
本文系作者授权百度百家发表,未经许可,不得转载。