1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

キックスタートファイルを使ってOSをインストールしてみる

Last updated at Posted at 2020-11-24

勉強前イメージ

量産出来るってイメージ
結構楽そう

キックスタートファイルとは?

こちらで少し書いていますが、
キックスタートファイルを使えば同じ方法でOSインストールを行えるようになる。
OSインストールの設定ファイルみたいなやつですかね?
それを使ってインストールしてみます。

概要

やり方はいろいろあるのですが、以下の方法で進めます。
今回はCentOS7を稼働中のサーバ、インストールするサーバとします。

  1. 稼働中のサーバを元にキックスタートファイルを編集
  2. キックスタートファイルを使ってOSインストールを行う

稼働中のサーバを元にキックスタートファイルを編集

  • configを作成したりするツールのインストール
yum install system-config-kickstart
  • httpdのインストール
yum install httpd
  • httpdのサービスを起動
service httpd start
service httpd status
==========
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since 火 2020-11-24 21:38:16 JST; 4s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 15450 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─15450 /usr/sbin/httpd -DFOREGROUND
           ├─15451 /usr/sbin/httpd -DFOREGROUND
           ├─15452 /usr/sbin/httpd -DFOREGROUND
           ├─15453 /usr/sbin/httpd -DFOREGROUND
           ├─15454 /usr/sbin/httpd -DFOREGROUND
           └─15455 /usr/sbin/httpd -DFOREGROUND

11月 24 21:38:16 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
11月 24 21:38:16 localhost.localdomain httpd[15450]: AH00558: httpd: Could not reliably determine ...ge
11月 24 21:38:16 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
==========
  • キックスタートファイルを確認
cat /root/anaconda-ks.cfg
==========
# version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=jp --xlayouts='jp'
# System language
lang ja_JP.UTF-8

# Network information
network  --bootproto=dhcp --device=enp0s3 --ipv6=auto --activate
network  --bootproto=static --device=enp0s8 --ip=192.168.XXX.XXX --netmask=255.255.0.0 --onboot=off --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted [暗号化済みのパスワード]
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Tokyo --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

%packages
@^minimal
@core
chrony
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end
==========
  • rootのパスワードを生成します
openssl passwd -1
Password: [パスワード]
Verifying - Password: [パスワード]
$1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  • anaconda-ks.cfgをコピー
cp /root/anaconda-ks.cfg /var/www/html/ks.cfg
  • 権限変更
chmod 755 /var/www/html/ks.cfg
  • rootのパスワードを修正
vi /var/www/html/ks.cfg
==========
変更
rootpw --iscrypted $1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
==========
  • 記述の間違いがないことを確認
ksvalidator /var/www/html/ks.cfg
> 間違いがなければ、何も表示されません

キックスタートファイルを使ってOSインストールを行う

  • サーバにOSのDVDをいれてインストールまで進む(今回はVM)

  • インストール画面になったら編集

以下の画面になったら、tabキー を押すと入力画面が出てくるので、
inst.ks=http://[anaconda-ks.cfgを置いているサーバのIP]/ks.cfg を入力

キックスタート先サーバ(192.168.119.51) [実行中] - Oracle VM Virt.png

  • 読み込みログが流れる

2キックスタート先サーバ(192.168.119.51) [実行中] - Oracle VM Virt.png

  • OSの設定が開きました

中はIPアドレスとか見たらちゃんと設定されてるようです。

innsuto-uキックスタート先サーバ(192.168.119.51) [実行中] - Oracle VM Virt.png

  • rootのパスワードも設定されてました

pasuキックスタート先サーバ(192.168.119.51) [実行中] - Oracle VM Virt.png

勉強後イメージ

中身きちんと書いたらOSインストールまでやってくれるのかな?
あんまり出来てるイメージなかったけど....
VMの設定にすごい惑わされた。

参考

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?