next up previous contents
Next: 虛擬機 Up: Linux 安裝 Previous: 認識硬體   Contents

安裝

  1. 產生自動安裝檔kickstart
    [root@deyu ~]# vi anaconda-ks.cfg
    #version=Certification CentOS 6
    install
    lang en_US.UTF-8
    keyboard us
    #network --device eth0 --mtu=1500 --bootproto dhcp --hostname deyu.wang
    rootpw  123123
    timezone --utc Asia/Taipei
    
    %include /tmp/partitioning
    #reboot
    
    %packages --nobase 
    NetworkManager
    ....
    -libgcj
    -sinjdoc
    -java-1.5.0-gcj
    %end
    
    %pre --log=/tmp/kickpre
    #!/bin/bash
    ...
    echo "bootloader --location=mbr --driveorder=${idisk}" > /tmp/partitioning
    cat >> /tmp/partitioning << END
    zerombr
    clearpart --all --drives=${idisk}
    ignoredisk --only-use=${idisk} ${sdpart}
    part /boot --size=96 --fstype=ext4 
    part pv.01 --size=4800
    volgroup vg_crt --pesize=4096 pv.01
    logvol / --fstype=ext4 --name=root --vgname=vg_crt --size=4200
    logvol swap --name=swap --vgname=vg_crt --size=48
    END
    %end
    
    %post --log=/tmp/kickpost
    #!/bin/bash
    useradd dywang
    echo "123" | passwd --stdin dywang
    %end
    
    \end{enumerate}
    \end{enumerate}
    
    \section{安裝}
    \begin{enumerate}
    \item 產生自動安裝檔kickstart
    \\\begin{myverbatim}
    [root@deyu ~]# vi anaconda-ks.cfg
    #version=Certification CentOS 6
    install
    lang en_US.UTF-8
    keyboard us
    #network --device eth0 --mtu=1500 --bootproto dhcp --hostname deyu.wang
    rootpw  123123
    timezone --utc Asia/Taipei
    
    %include /tmp/partitioning
    #reboot
    
    %packages --nobase 
    NetworkManager
    ....
    -libgcj
    -sinjdoc
    -java-1.5.0-gcj
    %end
    
    %pre --log=/tmp/kickpre
    #!/bin/bash
    ...
    echo "bootloader --location=mbr --driveorder=${idisk}" > /tmp/partitioning
    cat >> /tmp/partitioning << END
    zerombr
    clearpart --all --drives=${idisk}
    ignoredisk --only-use=${idisk} ${sdpart}
    part /boot --size=96 --fstype=ext4 
    part pv.01 --size=4800
    volgroup vg_crt --pesize=4096 pv.01
    logvol / --fstype=ext4 --name=root --vgname=vg_crt --size=4200
    logvol swap --name=swap --vgname=vg_crt --size=48
    END
    %end
    
    %post --log=/tmp/kickpost
    #!/bin/bash
    useradd dywang
    echo "123" | passwd --stdin dywang
    %end
    

  2. 光碟安裝:
    1. 下載安裝光碟iso檔: ftp://ftp.isu.edu.tw/Linux
    2. 製作安裝光碟
      [root@deyu ~]# mount -o loop CentOS-6.0-x86_64.iso /mnt/iso
      [root@deyu ~]# cp -a /mnt/iso /mnt/cdtmp
      [root@deyu ~]# vi /mnt/cd/isolinux/isolinux.cfg
      default vesamenu.c32 
      prompt 0
      timeout 60
      display boot.msg
      menu background splash.jpg
      menu title Welcome to CentOS 6.0!
      
      label crt
        menu label Install ^Certification system
        menu default
        kernel vmlinuz
        append load_ramdisk=1 initrd=initrd.img ks=cdrom:/isolinux/crt-ks.cfg repo=cdrom:/
      [root@deyu ~]# cd /mnt/cdtmp
      [root@deyu cdtmp]# mkisofs -o crt.iso -b isolinux/isolinux.bin -c \
      isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
      -boot-info-table -R -J -v -T . 
      [root@deyu cdtmp]# cdrecord -eject -v -data -nopad -dao crt.iso
      
    3. 以燒好的光碟開機,即可依自動安裝檔crt-ks.cfg設定安裝。
    4. 缺點:必須燒光碟,造成資源浪費。
  3. 製作隨身碟安裝系統:
    1. 格式化隨身碟,必須設定開機分割區可安開機旗標。
      [root@deyu ~]# fdisk /dev/sde
      # delete existing partition - repeat as necessary
      n # new partition
      p # primary
      1 # partition number
      <enter> # take the default
      +1G # add 1 GB
      a # toggle bootable flag
      1 # partition number
      w # write to disk
      [root@deyu ~]# mkfs.ext2 /dev/sde1
      
    2. 複製檔案至隨身碟。
      [root@deyu ~]# mkdir /mnt/{iso,usb}
      [root@deyu ~]# mount /dev/sde1 /mnt/usb
      [root@deyu ~]# mount -o loop CentOS-6.0-x86_64.iso /mnt/iso
      [root@deyu ~]# cp -a /mnt/iso/{isolinux,image} /mnt/usb
      [root@deyu ~]# cd /mnt/usb
      [root@deyu usb]# mv isolinux extlinux
      [root@deyu usb]# mv extlinux/isolinux.cfg extlinux.conf
      [root@deyu usb]# vi extlinux/extlinux.conf
      default vesamenu.c32 
      prompt 0
      timeout 600
      menu background splash.jpg
      label crt
        menu label Install ^Certification system
        menu default
        kernel vmlinuz
        append load_ramdisk=1 initrd=initrd.img ks=hd:UUID="b3de84f3-2fa6-45e5-a01d-3adbe348b6cf":/extlinux/crt-ks.cfg repo=hd:UUID="b3de84f3-2fa6-45e5-a01d-3adbe348b6cf":/centos6/crt/
      
      [root@deyu usb]# extlinux --install /mnt/usb/extlinux; sync
      
    3. 選擇隨身碟開機。
  4. PXE網路安裝
    1. 架設PXE主機
      ##dhcp server
      [root@deyu ~]# vi /etc/dhcp/dhcpd.conf
      ddns-update-style none;
      option space PXE;
      subnet 192.168.111.0 netmask 255.255.255.0 {
      class "PXE" {
      	match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
      		option vendor-encapsulated-options 01:04:00:00:00:00:ff;
      			option boot-size 0x1;
                              filename "pxelinux.0";
                              option tftp-server-name "deyu.wang";
                              option vendor-class-identifier "PXEClient";
                              vendor-option-space PXE;
      }
              option routers 192.168.111.254;
              option subnet-mask 255.255.255.0;
              option domain-name "deyu.wang";
              option domain-name-servers 168.95.1.1,139.175.10.20;
              default-lease-time 21600;
              max-lease-time 43200;
      
              # Assign IPs 101-100 to PXE clients
              pool {
                  allow members of "PXE";
                  default-lease-time 120;
                  max-lease-time 180;
                  range 192.168.111.101 192.168.111.200;
              }
              pool {
                  deny members of "PXE";
                  range 192.168.111.1 192.168.111.70;
              }
      	next-server 192.168.111.254;
      	filename "ftp://192.168.111.254/pub/centos6/dag/dyw-ks.cfg";
      }
      
      [root@deyu ~]# /etc/init.d/dhcpd restart
      
      ## tflt server
      [root@deyu ~]# vi /etc/xinetd.d/tftp
      service tftp
      {
      	socket_type		= dgram
      	protocol		= udp
      	wait			= yes
      	user			= root
      	server			= /usr/sbin/in.tftpd
      	server_args		= -s /var/ftp/pub/centos6/usb/isolinux <= for boot
      	disable			= no
      	per_source		= 11
      	cps			= 100 2
      	flags			= IPv4
      }
      
      [root@deyu ~]# /etc/init.d/xinetd restart 
      [root@deyu ~]# /etc/init.d/vsftpd restart
      
    2. 選擇網路開機。
  5. 安裝步驟重要設定:
    1. 選擇安裝到硬碟或隨身碟。
    2. 磁碟的分割,若安裝至隨身碟建議自行分割,以有效使用隨身碟。
    3. 安裝套件的選擇。



2015-04-13