美文网首页
通过网络安装Debian

通过网络安装Debian

作者: aneirin | 来源:发表于2020-03-23 20:41 被阅读0次

    环境说明:
    1,配置tftp服务
    在服务器上安装tftp服务(软件为tftpd-hpa),假如服务器的IP是10.0.0.1上。
    服务器上(路径相对于tftp的根路径)
    tftpd的根目录为/var/lib/tftpboot
    下载debian的pxe安装镜像:netboot.tar.gz(https://www.debian.org/distrib/netinst#netboot),
    解压到目录/var/lib/tftpboot下
    2,配置DHCP服务
    DHCP服务运行在交换机(型号为Huawei S5720-32X-EI-AC)上,
    交换机的配置:

    ip pool vlan16
     gateway-list 10.1.16.1
     network 10.1.16.0 mask 255.255.255.0
     lease day 5 hour 0 minute 0              
     dns-list 10.0.0.2 10.0.0.180
     next-server 10.0.0.1                                                 #指定tftp服务器的ip地址
     bootfile debian-installer/amd64/bootnetx64.efi        #指定网络启动的bootloader文件,UEFI启动,保存在tftp
    

    启动客户端的安装过程,安装不是无人值守的,PXE安装镜像会从网络上下载所需的包。
    无人值守安装
    如果要实现无人值守安装,需要依赖preseed配置文件。preseed文件可以保存到initrd文件里面,本文中通过web服务提供preseed文件。
    用nginx搭建web服务器,web根目录是/var/www/html,在该目录下放preseed.cfg文件,内容如下:

    d-i debian-installer/locale string en_US.UTF-8
    d-i keyboard-configuration/xkb-keymap select us  
    d-i netcfg/choose_interface select auto
    d-i netcfg/get_hostname string unassigned-hostname
    d-i netcfg/get_domain string unassigned-domain
    d-i mirror/country string manual
    
    d-i mirror/http/hostname string mirrors.163.com
    d-i mirror/http/directory string /debian
    d-i mirror/http/proxy string
    d-i passwd/make-user boolean false
    d-i passwd/root-password password admin
    d-i passwd/root-password-again password admin
    d-i clock-setup/utc boolean true
    d-i time/zone string US/Eastern
    d-i clock-setup/ntp boolean true
    d-i partman-auto/method string lvm
    d-i partman-lvm/device_remove_lvm boolean true
    d-i partman-md/device_remove_md boolean true
    d-i partman-lvm/confirm boolean true
    d-i partman-lvm/confirm_nooverwrite boolean true
    d-i partman-auto/choose_recipe select atomic
    d-i partman-partitioning/confirm_write_new_label boolean true
    d-i partman/choose_partition select finish
    d-i partman/confirm boolean true
    d-i partman/confirm_nooverwrite boolean true
    d-i partman-md/confirm boolean true
    d-i partman-partitioning/confirm_write_new_label boolean true
    d-i partman/choose_partition select finish
    d-i partman/confirm boolean true
    d-i partman/confirm_nooverwrite boolean true
    d-i debian-installer/allow_unauthenticated boolean true
    
    tasksel tasksel/first multiselect  standard
    d-i finish-install/reboot_in_progress note
    

    最后修改tftp里面的文件,/var/lib/tftpboot/debian-installer/amd64/grub/grub.cfg

    menuentry 'Install' {
    set background_color=black
    linux    /debian-installer/amd64/linux vga=788 auto=true priority=critical debian-installer/allow_unauthenticated=true  interface=auto netcfg/dhcp_timeout=60 netcfg/choose_interface=auto url=http://web-server-ip/preseed.cfg --- quiet
    initrd   /debian-installer/amd64/initrd.gz
    }
    

    这样就可以实现无人值守安装操作系统。

    相关文章

      网友评论

          本文标题:通过网络安装Debian

          本文链接:https://www.haomeiwen.com/subject/qddgyhtx.html