자동화된 설치란 간단하게 말하면 운영체제 설치에 필요한 정보들을 특정 파일에 지정된 형식으로 작성하여 설치 과정에서 작업자의 일련의 입력 과정을 최소화한 방법이라고 할 수 있을 것이다. 운영체제 설치를 자동화하는 방법에는 윈도우에서는 무인 설치, 레드햇의 Kickstart, 우분투의 Preseed 등을 들 수 있다. 본 포스트에서는 우분투 10.04 LTS를 사용하여 자동화된 설치에 대해 알아보도록 한다.
1. 준비
- DHCP 서버 // 대상 컴퓨터의 IP 주소를 자동으로 할당한다
- TFTP 서버 // 부팅에 필요한 커널을 내려준다
- HTTP 서버 // 응답 파일(preseed.cfg)을 내려준다
#apt-get install dhcp3-server
option domain-name-servers 8.8.8.8, 8.8.4.4 ; // 자신이 사용하는 DNS 서버주소를 사용한다. 본인은 외우기 쉬워 구글의 DNS를 선택하였다
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.111.0 netmask 255.255.255.0 { // vmware의 nat의 기본 IP 대역
range 192.168.111.200 192.168.111.253;
filename "pxelinux.0"; // 우분투 설치 부팅 이미지
next-server 192.168.111.128; // TFTP 서버 주소
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.111.255;
option routers 192.168.111.2;
}
설정을 저장한 후 dhcp 서버를 가동시키자.
# service dhcp3-server start
# apt-get install tftpd-hpa
TFTP_USERNAME="nobody"
TFTP_DIRECTORY="/var/lib/tftpboot" // 중요 : 반드시 해당 디렉토리를 생성해주여야 한다
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
위 tftpboot 디렉토리가 없으면 nobody 권한으로 생성하도록 한다. tftp는 기본적으로 활성 상태가 아니기 때문에 아래 명령으로 활성화시킨다.
# service tftpd-hpa start
명령어 'ss -ua'를 실행하면 tftp 서버가 실행되고 있는지 확인할 수 있다.
# ss -ua
State Recv-Q Send-Q Local Address:Port Peer Address:Port
UNCONN 0 0 *:bootps *:*
UNCONN 0 0 *:tftp *:*
UNCONN 0 0 *:mdns *:*
UNCONN 0 0 *:41714 *:*
preseeding 과정에서 웹서버는 설치 대상 컴퓨터에 응답 파일(preseed.cfg)을 전달하기 위해 반드시 필요하다. 따라서 자신이 사용하기 편한 웹서버를 선택하도록 하자.
# apt-get install apache2
아파치 서버를 설치하면 자동으로 데몬이 구동되어 따로 설정할 것이 없다. 자동화된 설치를 위해서 응답파일(preseed.cfg)를 웹서버 루트 디렉토리(/var/www/)아래에 복사하면 끝이다. 응답 파일 작성은 아래에서 설명하도록 한다.
우분투 부팅에 필요한 파일들을 우분투 사이트에서 내려 받아 tftp 루트디렉토리에 복사하도록 한다.
# wget http://ftp.ubuntu.com/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/netboot.tar.gz
# cp netboot.tar.gz /var/lib/tftpboot/
tftp 루트디렉토리로 이동하여 내려 받은 파일의 압축을 푼다.
# cd /var/lib/tftpboot/
# tar zxvf netboot.tar.gz

label automated
menu label ^Automated Install
menu default // 부팅 화면이 나타나면 커서가 이 메뉴에 위치하도록 한다
kernel ubuntu-installer/i386/linux
append auto=true priority=critical vga=normal initrd=ubuntu-installer/i386/initrd.gz url=http://192.168.111.128/preseed.cfg --quiet

이제 응답파일을 HTTP 루트디렉토리(/var/www/)에 복사한다. 이제 설치 대상 컴퓨터를 부팅하면 tftp로부터 부팅 이미지를 받고 응답 파일을 읽어 자동으로 패키지를 내려받아 설치할 것이다.#### Contents of the preconfiguration file
### Localization
# Locale sets language and country.
d-i debian-installer/locale string ko_KR
# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
#d-i console-setup/modelcode string pc105
d-i console-setup/layoutcode string us
### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
# Suite to install.
d-i mirror/suite string lucid;
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string Asia/Seoul
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
### Partitioning
# Alternatively, you can specify a disk to partition. The device name must
# be given in traditional non-devfs format.
# Note: A disk must be specified, unless the system has only one disk.
# For example, to use the first SCSI/SATA hard disk:
#d-i partman-auto/disk string /dev/sda
# In addition, you'll need to specify the method to use.
# The presently available methods are: "regular", "lvm" and "crypto"
d-i partman-auto/method string lvm
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select multi
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
### Account setup
# To create a normal user account.
d-i passwd/user-fullname string Desktop User
d-i passwd/username string secmaster
# Normal user's password, either in clear text
d-i passwd/user-password password Password1
d-i passwd/user-password-again password Password1
### Package selection
tasksel tasksel/first multiselect ubuntu-desktop
# Individual additional packages to install
d-i pkgsel/include string openssh-server build-essential
### Boot loader installation
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
### X configuration
# X can detect the right driver for some cards, but if you're preseeding,
# you override whatever it chooses. Still, vesa will work most places.
#xserver-xorg xserver-xorg/config/device/driver select vesa
# A caveat with mouse autodetection is that if it fails, X will retry it
# over and over. So if it's preseeded to be done, there is a possibility of
# an infinite loop if the mouse is not autodetected.
#xserver-xorg xserver-xorg/autodetect_mouse boolean true
# Monitor autodetection is recommended.
xserver-xorg xserver-xorg/autodetect_monitor boolean true
# Uncomment if you have an LCD display.
#xserver-xorg xserver-xorg/config/monitor/lcd boolean true
# X has three configuration paths for the monitor. Here's how to preseed
# the "medium" path, which is always available. The "simple" path may not
# be available, and the "advanced" path asks too many questions.
xserver-xorg xserver-xorg/config/monitor/selection-method \
select medium
xserver-xorg xserver-xorg/config/monitor/mode-list \
select 1024x768 @ 60 Hz
설치 후 추가 패키지를 설치하고자 한다면 preseed/late_command를 이용하자.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
우분투를 이용하여 설치를 진행할 때 'Installing Base System' 단계에서 83%까지 진행하다 멈추는 현상이 계속 발생한다. Vmware 내에서만 발생하는 현상인지 파악이 안되고 있다. 혹시나 해서 데비안에서 비슷한 설정으로 설치 자동화 과정을 진행하니 무리없이 진행되었다. 무슨 문제인지. 실제 PC를 가지고 테스트해봐야하나..
답글삭제Maybe the best read I read in my life?
답글삭제