當前位置:才華齋>計算機>作業系統>

Linux全自動安裝操作例項及原理

作業系統 閱讀(9.5K)

手動安裝Linux系統費時費力,需要操作的步驟非常多,使用kickstart等工具就能實現Linux系統的全自動安裝,下面小編就給大家介紹下Linux全自動安裝操作例項,一起來學習下吧。

Linux全自動安裝操作例項及原理

原理:

  使用光碟安裝linux系統過程:

第一步,POST自檢

第二步,MBR引導,這裡使用的GRUB是CDROM中isolinux/資料夾中的。

第三步,啟動帶有安裝、升級、修復等選項的選擇選單,這是由啟動的。

第四步,vmlinuz(initrd)掛載根檔案系統。

第五步,啟動anaconda安裝介面。而anaconda

詳細解析

第二步中,選單中定義了第三步中的引導內容。

所以這裡的`顯示內容可以自定義

[root@CentOS6 cdrom]# cat isolinux/

#debug --graphics

default=0

splashimage=@SPLASHPATH@

timeout 5

hiddenmenu

title @PRODUCT@ @VERSION@

kernel @KERNELPATH@

initrd @INITRDPATH@

title Install system with basic video driver

kernel @KERNELPATH@ xdriver=vesa nomodeset askmethod

initrd @INITRDPATH@

title rescue

kernel @KERNELPATH@ rescue askmethod

initrd @INITRDPATH@

第三步,進入啟動介面,這裡定義了啟動介面的各種顯示內容,

由執行,由提供配置檔案。

display

引用,其配置檔案為

menu background splash.jpg

menu title Welcome to CentOS 6.4!最上面顯示的內容

menu color border 0 #ffffffff #00000000定義介面的顏色顯示

menu color sel 7 #ffffffff #ff000000

定義選項

label linux

menu label ^Install or upgrade an existing system

menu default

kernel vmlinuz

append initrd=

label vesa

menu label Install system with ^basic video driver

kernel vmlinuz

append initrd= xdriver=vesa nomodeset

label rescue

menu label ^Rescue installed system

kernel vmlinuz

append initrd= rescue

label local

menu label Boot from ^local drive

localboot 0xffff

label memtest86

menu label ^Memory test

kernel memtest

append -

第五步,真正進入安裝時,需要載入Packages/檔案

anaconda程式可以實現圖形、字元方式的安裝,而在這兩種方式下,

也可以選擇互動式安裝或自問自答的自動安裝。

anaconda安裝詳解:

其自動安裝的配置檔案是口kickstart。kickstart可以手動編寫,可以文字方式生成,也可以

圖形方式生成。(檔案在安裝完成後會在root家目錄下生成詳細配置)

下面是圖形生成的步驟:

1,安裝system-config-kickstart

yum install system-config-kickstart

2,啟動system-config-kickstart

system-config-kickstart &

3,配置kickstart

Basic Configuration:

Encrypt root password表示加密root的密碼串

Target Architecture:表示平臺

Reboot system after installation安裝後的動作是重啟,需要勾上。

Perform installation in text text mode (grphical is default)

安裝介面預設使用圖形介面,所以這個需要勾上。

Perform installlation in interactive mode使用互動式模式,不勾。

Install Method:安裝源

HTTP Server:安裝源的IP

HTTP Directory:目錄

Boot Loader Options:引導選項

Install new boot loader安裝新的bootloader,下面是使用舊的。

Use GRUB password:GRUB要不要加密。

Install boot loader on Master Boot Record(MBR)

將bootloader裝入MBR中

Install boot loasder on first sector of the boot partition

將bootloader裝入某一個分割槽中引導。

kernel parameters:crashkernel=auto rhgb quiet使用靜默模式。

Partition Information定義分割槽

Network Configuration網路配置

Authentication認證,預設sha512就可以

pre

post這裡不用指定#!/bin/bash

4,儲存kickstart配置檔案。

檔案預設儲存名字為

5,檢查配置檔案的錯誤。

# ksvalidator

kscfg配置檔案詳解:

命令段:

#platform=x86, AMD64, 或 Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled禁用防火牆

# Install OS instead of upgrade

install預設動作是安裝

# Use network installation

url --url=“”使用FTP安裝源

repo --name=“CentOS” --baseurl=“”

# Root password

rootpw --iscrypted $1$dpCtQEn6$pC3UGFPZEJJ5nVftiaScq0

# System authorization information

auth --useshadow --passalgo=sha512

# Use text mode install

text使用文字安裝方式

# System keyboard

keyboard us使用美式英語鍵盤

# System language

lang zh_CN設定預設語言

# SELinux configuration

selinux --disabled禁用SELINUX

# Do not configure the X Window System

skipx

# Installation logging level

logging --level=info

# Reboot after installation

reboot安裝完成時的動作

# System timezone

timezone Asia/Shanghai

# Network information

network --bootproto=static --device=eth0 --ip= --netmask= --onboot=on

# System bootloader configuration

bootloader --append=“crashkernel=auto rhgb quiet” --location=mbr --driveorder=“sda”

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel清空磁碟分割槽

# Disk partitioning information磁碟分割槽

part /boot --asprimary --fstype=“ext4” --ondisk=sda --size=100

part / --asprimary --fstype=“ext4” --ondisk=sda --size=20480

part swap --asprimary --fstype=“swap” --ondisk=sda --size=500

指令碼段:

%post

touch /tmp/

%end

軟體包段:

%packages

@base

@basic-desktop

@chinese-support

@core

@debugging

@desktop-debugging

@desktop-platform

@desktop-platform-devel

@development

@directory-client

@fonts

使用引導光碟引導後的選擇:

點選兩次“ESC”鍵,進入命令列模式,然後

linux ip= netmask= ks=

ftp安裝源自動安裝linux詳細步驟:

1,製作引導光碟:

# mount /dev/cdrom /media/cdrom/

# mkdir /root/myboot

# cp /media/cdrom/isolinux/ /root/myboot/isolinux

# cd /root/myboot/isolinux

# chmod +w 。/*

# chmod +x vmlinuz

# mkisofs -R -J -T -v -no-emul-boot -boot-load-size 4 -boot-info-table -V “MageEdu Testing Image” (-V跟光碟標籤) -b isolinux/ (明確指定的存放位置) -c isolinux/ (指定的位置) -o /tmp/ (指定輸出位置) /root/myboot/ (指定輸入源)

2,製作ftp安裝源

# yum install vsfptd

# service vsftpd start

# mkdir /var/ftp/CentOS

# mount /media/cdrom /var/ftp/CentOS,

3,將製作好的檔案放到ftp目錄

# cp /root/ /var/ftp/pub

4,將前面的掛載到目標主機的光碟機,啟動後兩次“ESC”鍵,然後就輸入:

linux ip= netmask= ks=

5,自動安裝啟動

上面就是Linux全自動安裝的方法介紹了,本文通過編譯指令碼實現Linux系統全自動化安裝,需要安裝anaconda,編譯完anaconda後啟動即可。