maehachi08 Anything Blog

2012年04月20日
CobblerでScientificLinux6.2インストール環境構築

CobblerでScientific Linux6.2を入れる

勤務先の大先輩であるtnmtさんmaedaさんの記事を参考にさせて頂きつつ、今日はScientific Linux6.2をCobblerでインストール可能な環境を構築してみようと思います。
Scientific LinuxとはRHELクローンのOSです。CentOSより早くRHEL6クローンをリリースしたことから一躍有名になりました。

Distribution/Profile登録

サブタイトルに”Distribution/Profile”と入れたのはcobbler importコマンドによってこの2つの定義が自動的に作成されるからです。
cobbler importコマンドでOSインストールに必要なファイルのあるURLを指定し、名前を指定してやるだけでファイルがrsyncで/var/www/cobbler/ks_mirror/[name]ディレクトリに同期され、[name]名のdistro定義とprofile定義が作成されます。

# cobbler import --path=rsync://ftp.jaist.ac.jp/pub/Linux/scientific/6.2/x86_64/os/ --name=SL6.2-x86_64
task started: 2012-04-19_201455_import
task started (id=Media import, time=Thu Apr 19 20:14:55 2012)
running: rsync -a  'rsync://ftp.jaist.ac.jp/pub/Linux/scientific/6.2/x86_64/os/' /var/www/cobbler/ks_mirror/SL6.2-x86_64 --exclude-from=/etc/cobbler/rsync.exclude --progress
 ・
 ・
 ・
adding distros
avoiding symlink loop
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot for distro signature
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64/images for distro signature
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64 for distro signature
found content (breed=redhat) at /v
creating new distro: SL6.2-x86_64
creating new profile: SL6.2-x86_64
associating repos
traversing distro SL6.2-x86_64
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot for distro signature
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64/images for distro signature
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64 for distro signature
found content (breed=redhat) at /v
descent into /var/www/cobbler/ks_mirror/SL6.2-x86_64
processing repo at : /var/www/cobbler/ks_mirror/SL6.2-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/SL6.2-x86_64
looking for /var/www/cobbler/ks_mirror/SL6.2-x86_64/repodata/*comps*.xml
running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/SL6.2-x86_64/repodata/comps-sl6-x86_64.xml /var/www/cobbler/ks_mirror/SL6.2-x86_64

6200/6200 - Packages/jakarta-commons-logging-javadoc-1.0.4-10.el6.noarch.rpm    pmh.rpmarch.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata

associating kickstarts
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot for distro signature
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64/images for distro signature
scanning /var/www/cobbler/ks_mirror/SL6.2-x86_64 for distro signature
found content (breed=redhat) at /v
*** TASK COMPLETE ***


# cobbler distro report --name=SL6.2-x86_64
Name                           : SL6.2-x86_64
Architecture                   : x86_64
Breed                          : redhat
Comment                        :
Initrd                         : /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/SL6.2-x86_64'}
Management Classes             : []
OS Version                     : generic26
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}


# cobbler profile report --name=SL6.2-x86_64
Name                           : SL6.2-x86_64
Comment                        :
DHCP Tag                       : default
Distribution                   : SL6.2-x86_64
Enable PXE Menu?               : 1
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/default.ks
Kickstart Metadata             : {}
Management Classes             : []
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 0
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : qemu

ksファイル変更

デフォルトのksファイルである/var/lib/cobbler/kickstarts/default.ksは何も設定は入っていないので、CentOS6.2用に作成したksファイルに変更します。

# cobbler profile report --name=SL6.2-x86_64 | grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/default.ks

# cobbler profile edit --kickstart="/var/lib/cobbler/kickstarts/Basci_Server_CLI.cfg" --name=SL6.2-x86_64

# cobbler profile report --name=SL6.2-x86_64 | grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/Basci_Server_CLI.cfg

設定を反映します。
# cobbler sync
task started: 2012-04-20_005129_sync
task started (id=Sync, time=Fri Apr 20 00:51:29 2012)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CEMTOS62-x86_64
removing: /var/www/cobbler/images/SL6.2-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/01-00-0c-29-d1-96-21
removing: /var/lib/tftpboot/pxelinux.cfg/01-10-1f-74-3b-82-64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/01-10-1F-74-3B-82-64
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/01-00-0C-29-D1-96-21
removing: /var/lib/tftpboot/images/CEMTOS62-x86_64
removing: /var/lib/tftpboot/images/SL6.2-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros
copying files for distro: SL6.2-x86_64
trying hardlink /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/SL6.2-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/SL6.2-x86_64/initrd.img
trying hardlink /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/SL6.2-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/SL6.2-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/SL6.2-x86_64/initrd.img
copying files for distro: CEMTOS62-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CEMTOS62-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CEMTOS62-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CEMTOS62-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CEMTOS62-x86_64/initrd.img
trying hardlink /var/www/cobbler/ks_mirror/CEMTOS62-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CEMTOS62-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CEMTOS62-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CEMTOS62-x86_64/initrd.img
copying images
generating PXE configuration files
generating: /var/lib/tftpboot/pxelinux.cfg/01-10-1f-74-3b-82-64
generating: /var/lib/tftpboot/grub/01-10-1F-74-3B-82-64
generating: /var/lib/tftpboot/pxelinux.cfg/01-00-0c-29-d1-96-21
generating: /var/lib/tftpboot/grub/01-00-0C-29-D1-96-21
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
cleaning link caches
generating PXE menu structure
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: /etc/rc.d/init.d/dhcpd restart
received on stdout: Shutting down dhcpd:                   [  OK  ]
Starting dhcpd:                                            [  OK  ]

received on stderr:
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

system登録

# cobbler system add --name=sl62 \
--hostname=sl62 \
--profile=SL6.2-x86_64 \
--interface=eth0 \
--mac=00:0C:29:D1:96:21 \
--static=1 \
--ip=192.168.100.50 \
--subnet=255.255.255.0 \
--gateway=192.168.100.1 \
--name-servers=8.8.8.8

これで上記MACアドレスのインターフェースを持つマシンを起動してPXEブートさせればScientific Linux6.2が自動インストールされます。