はてなブログの設定メモ

はてなブログを使い始めてしばらくしてから、「最初にやっときゃ良かった……」と思うことが幾つもあったのでメモしておきます。

  • 行間が広すぎので狭くする

web-ken.hatenablog.com

shift+enterしたら負け

そうそう!『なんでこんなに行間広いんだ……あ、Shift+Enterの改行なら狭いままだな。よし…Shift+Enter、Shift+Enter、Shift+…めんどくせぇ!』となったよ。

はてなブログの編集画面で"Enter"を押しての改行は<p>...</p>段落タグに置き換えられます。 一方でShift+Enterだと<br>改行タグに置き換えられます。

この<p>タグのCSS

.entry-content {
    margin-bottom: 24px;
}
p {
    margin: 0 0 1.6em; [上][左右][下]
}

と文字サイズの1.6倍の間隔を空ける設定となっています。 というわけで

「デザイン」→「カスタマイズ」→「サイドバー」とクリックしていって表示される「{} デザインCSS」というところだ。  そこに以下のコードをコピペすればpタグは死ぬ。

  • Markdown記法を覚える コードなどを見やすく記載するにはどうすれば良いか?→皆さん

むむむ…Markdownの記事を書くためにまずはMarkdownを覚えないといけない……。

あああ Enterで改行 あああ Enterで改行2回

あああ Shift+Enter あああ

dobonkai.hatenablog.com

dobonkai.hatenablog.com

CentOS をアップデートしたら途中で止まった。

CentOS を6.7から6.8にアップデートしたら起動途中で先に進まなくなった。プログレスバーが左から右に伸びていって、"CentOS6.8"の部分に達したところで止まる。

ブートプロセスを確認してみることにする。
再起動して "Press any key to enter the menu"と出たところで何かキーを押してGRUB画面に入る。
"e" を押した後 kernel行 にカーソルを合わせて "e" 。後方に記載されてる rhgb quiet を削除して "Enter"で戻る。"b" を押してブート。*1

起動プロセスが上から下に流れていって…

Starting atd: [OK]
Starting certmonger: [OK]

で止まった。

ググったら「この辺りで止まるなら グラフィックボードドライバを再インストールしろ」との情報があったのでその通りにしたら直った。

CentOS インストール後にしたこと - demandosigno
に記載したように、私は # sh NVIDIA-Linux-x86_64-304.131.run でインストールしていましたが、これだと カーネルアップデート毎にドライバ再インストールが必要なようです。Yumでパッケージインストールしていればいちいち再インストールしなくて良いようです。
CentOS 6.5 hangs at Start ATD [OK]

というわけで、Starting certmonger: [OK] で止まってる中 Ctrl+Alt+F2で2つ目のCUIを立ち上げる。Xのログを見てみる。確かにドライバーを認識してない。

# tail /var/log/Xorg.0.log
[ 43.335] (EE) No drivers available.
[ 43.335] (EE)
Fatal server error:
[ 43.335] no screens found (EE)
[ 43.335] (EE)
Please consult the CentOS support at https://www.redhat.com/apps/support/ for help.
[ 43.335] Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[ 43.335] (EE)

#

後は

CentOS インストール後にしたこと - demandosigno
と同様にドライバを置いてあるディレクトリに移動して

# sh NVIDIA-Linux-x86_64-304.131.run
で再インストール。再起動。無事立ち上がった。

 

★当初上記のようにRUNファイルを使ったドライバインストールを行いましたが、それだとカーネルアップデート毎に再度ドライバを入れなおさないとダメなので、Yumでのインストールに変更しました。

Yumでのドライバインストールを目指す。

ELRepo : kmod-nvidia-304xx

ELRepo(The Community Enterprise Linux Repository)リポジトリーの導入。
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm を取得中
準備しています... ################################# [100%]
更新中 / インストール中...
1:elrepo-release-7.0-2.el7.elrepo ################################# [100%]

# yum repolist enabled
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.jaist.ac.jp
* elrepo: ftp.ne.jp
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp

リポジトリー ID リポジトリー名 状態
base/7/x86_64 CentOS-7 - Base 9,007
elrepo ELRepo.org Community Enterprise Linux Repository - el7 172
extras/7/x86_64 CentOS-7 - Extras 393
updates/7/x86_64 CentOS-7 - Updates 2,560
repolist: 12,132

★すでに # sh NVIDIA-Linux-x86_64-304.131.run でインストール済みの人は、先に
sh ./NVIDIA-Linux-x86_64-304.64.run --uninstall
バイナリ版をアンインストールしてください。

# yum install kmod-nvidia あたりでTABキーを押すと候補が出るのでよく確認しましょう。
kmod-nvidia-304xx.x86_64 kmod-nvidia-340xx.x86_64 kmod-nvidia.x86_64

# yum install kmod-nvidia-304xx.x86_64
読み込んだプラグイン:fastestmirror, langpacks...

# rpm -qa | grep nvidia
kmod-nvidia-304xx-304.131-1.el7.elrepo.x86_64
nvidia-x11-drv-304xx-304.131-1.el7.elrepo.x86_64

後はランレベルを5に戻して再起動。

*1:

* CentOS - 起動時プログレスバー非表示設定! - mk-mode BLOG

rhgb: “Red Hat Graphical Boot” の略。 システムのブートプロセスをグラフィカルに表示するオプション。 カーネルを経由して init に渡され、シェルスクリプト /etc/rc.sysinit の中で実行される。
quiet: ほとんどのカーネルメッセージを抑制し、表示を行わないオプション。
rhgb を残して quiet だけ削除すると前半部分のメッセージは表示され、その後のプログレスバーも表示される。 quiet を残して rhgb だけ削除すると前半部分のメッセージは非表示になり、プログレスバー部分はプログレスバーではなくメッセージが表示される。

CentOS インストール後にしたこと

AMD製のCPUではCentOS7.2が動かないということなのでCentOS7.1をインストールしました。
(現在は解決してるぽい? https://bugs.centos.org/view.php?id=9860

 

・ソフトウェアの更新

残りの細かいパッケージをアップデートしたら[システムツール]から[Software]や[Software Updata]が消えた。

  1. アプリケーションインストーラーのインストール
    #yum install gnome-software.x86_64
  2. アプリケーションインストーラーを使ってgnome パッケージアップデータをインストール
    [アプリケーションインストーラー]→[システム]→[その他]→[gnome パッケージ],[gnome パッケージアップデータ]

でだいたい戻る。

 

・ミラーサーバーの設定。

ftp-adminの憂鬱: yumで速いミラーサーバーを指定する方法

#rpm -qa | grep fastestmirror

yum-plugin-fastestmirror-1.1.31-34.el7.noarch

/etc/yum/pluginconf.d/fastestmirror.confに以下の preferオプションでサーバーを一つ指定。

prefer=ftp.jaist.ac.jp

/var/cache/yum以下にあるtimedhosts.txtをいったん削除。

・グラフィックボードのドライバーをインストールする。

刺さっているグラボの確認。

$ lspci | grep VGA
07:00.0 VGA compatible controller: NVIDIA Corporation G73 [GeForce 7300 GT] (rev a1)

# lsmod | grep nouveau

で、現在使用されている nouveauモジュールが幾つか表示される。

Nouveau(ヌーボー)はNVIDIAビデオカード用にオープンソースで開発されている無料のドライバーですが、競合するので止めます。

NVIDIA Accelerated Linux Graphics Driver README and Installation Guide

Chapter 4. Installing the NVIDIA Driver

Before you Begin

If you're installing on a system that is set up to use the Nouveau driver, then you should first disable it before attempting to install the NVIDIA driver. See Q & A 8.1, “Interaction with the Nouveau Driver” for details. 

8.1. Interaction with the Nouveau Driver

What is Nouveau, and why do I need to disable it?

Smiling Life : CentOS7におけるNVIDIAドライバのインストール方法

を参照しました。

 

nouveauをロードしない起動イメージファイルを作成。
デフォルトのイメージファイルをバックアップとして残しておく。
# mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img

次のコマンドでnouveauドライバをロードしない起動イメージファイルを作成。
#dracut --omit-drivers nouveau /boot/initramfs-$(uname -r).img $(uname -r)

# vi /etc/modprobe.d/blacklist.conf に
blacklist nouveau
の1行を加える。

デフォルトランレベルを3に変更する。

CentOS7の場合。
# systemctl get-default
graphical.target

# systemctl set-default multi-user.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

# systemctl get-default
multi-user.target

CentOS6の場合。
# vi /etc/inittab
id:3:initdefault:

NVIDIAのページから該当のLinux用ドライバをダウンロードして、後で見つけやすい場所に保存する。カタカナの「ダウンロード」フォルダとかだと後ほどrunlevel:3でインストールするときに面倒なので一つ上の /home/ あたりに置いておく。

その後再起動。

rootでログイン。runファイルの実行。

# sh NVIDIA-Linux-x86_64-304.131.run

設問を進めてインストール

インストールが完了したら

CentOS7の場合
# systemctl get-default
multi-user.target

># systemctl set-default graphical.target

># systemctl get-default
graphical.target

># reboot

CentOS6の場合

# vi /etc/inittab

ランレベルを5に戻して再起動。

(注:当初上記のようにrunファイルを使ったドライバインストールを行いましたが、それだとカーネルアップデート毎に再度ドライバを入れなおさないとダメなので、Yumでのインストール(後述)に変更しました)

CentOS をアップデートしたら途中で止まった - demandosigno

 

Yumでのドライバインストールを目指す。

ELRepo : kmod-nvidia-304xx

ELRepo(The Community Enterprise Linux Repository)リポジトリーの導入。
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm を取得中
準備しています... ################################# [100%]
更新中 / インストール中...
1:elrepo-release-7.0-2.el7.elrepo ################################# [100%]

# yum repolist enabled
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.jaist.ac.jp
* elrepo: ftp.ne.jp
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp

リポジトリー ID リポジトリー名 状態
base/7/x86_64 CentOS-7 - Base 9,007
elrepo ELRepo.org Community Enterprise Linux Repository - el7 172
extras/7/x86_64 CentOS-7 - Extras 393
updates/7/x86_64 CentOS-7 - Updates 2,560
repolist: 12,132

★すでに # sh NVIDIA-Linux-x86_64-304.131.run でインストール済みの人は、先に
sh ./NVIDIA-Linux-x86_64-304.64.run --uninstall
でバイナリ版をアンインストールしてください。

# yum install kmod-nvidia あたりでTABキーを押すと候補が出るのでよく確認しましょう。
kmod-nvidia-304xx.x86_64 kmod-nvidia-340xx.x86_64 kmod-nvidia.x86_64

# yum install kmod-nvidia-304xx.x86_64
読み込んだプラグイン:fastestmirror, langpacks...

# rpm -qa | grep nvidia
kmod-nvidia-304xx-304.131-1.el7.elrepo.x86_64
nvidia-x11-drv-304xx-304.131-1.el7.elrepo.x86_64

ランレベルを5に戻して再起動。

無事インストールされ、1920*1200 二枚のFullHDにできた。

gnomeのパネルが右側のモニターに出ていたので左側のモニターに移す。

パネルを右クリック→プロパティ→[向き]の中から左側モニターの[上](下のパネルは[下])を選択する。

Google Chrome のインストール

GoogleYumリポジトリをCentOS7に追加。
#vi /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

#yum update

Chromeパッケージの確認。

#yum search google chrome

読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.jaist.ac.jp
* elrepo: ftp.ne.jp
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp
=========== N/S matched: google, chrome ==================
google-chrome-beta.x86_64 : Google Chrome (beta)
google-chrome-stable.x86_64 : Google Chrome
google-chrome-unstable.x86_64 : Google Chrome (unstable)

Full name and summary matches only, use "search all" for everything.

#yum info google-chrome-unstable
バージョン : 56.0.2902.0

#yum info google-chrome-beta
バージョン : 55.0.2883.28

#yum info google-chrome-stable
バージョン : 54.0.2840.71

stableで十分だと思います。

#yum install google-chrome-stable

依存関係から他にもいろいろインストールされます。

# rpm -qa | grep chrome
google-chrome-stable-54.0.2840.71-1.x86_64

 

Flash pluginをFirefoxにインストール

https://get.adobe.com/flashplayer/ から Linux YUM版をダウンロード。
そのままパッケージインストーラーで開けたのでOKを押す。
「このファイルをインストールしたいですか。」でインストール

ブラウザ再起動、がFlashページが見られないまま。さっき入ったのは Adobe Repository Configuration らしい。で、「ソフトウェアの追加/削除」から、"adobe"で検索して flash-plugin-11.2 があったのでインストール。ブラウザ再起動。入った。

demandosigno.hatenablog.jp

CentOS7をネットワークインストールする。その4

CentOS7 をネットワークインストールする。その1 VMware
で、VMwareにCentOS7を入れてPXEサーバーをたて、そこから別のマシンにCentOSをネットワークインストールすることにしました。
CentOS7 をネットワークインストールする。その2 PXEサーバ
CentOS7 をネットワークインストールする。その3 xinetd ではなく systemd を

初めは Xinetd を使ったのですがうまくインストールすることができなかったのでSystemd を使うことにしました。ほぼ下記の記事の通りに進めています。

nothen.com.ar

VMwareに入れたCentOS7のターミナルを開きます。

1. Install the necessary packages:

    # yum install syslinux tftp-server
    インストール:
    syslinux.x86_64 0:4.05-12.el7 tftp-server.x86_64 0:5.2-12.el7
    完了しました!

Note that even though Xinetd will be installed as a dependency, both the Xinetd “super-service” and the tftp Xinetd “sub-service” will be disabled:

# systemctl disable xinetd.service
rm '/etc/systemd/system/multi-user.target.wants/xinetd.service'

Xinetdが既にインストールされてしまっている環境の方は、上記のようにXinetdを「無効」にしてください。
私は今回すっからかんのVmware上のCentOS7からスタートしてますのでXinetdは入っていません。Xinetd がちゃんと無効になっているかだけ調べます。
# grep disable /etc/xinetd.d/tftp
disable = yes

2. On the other hand, the tftp socket on Systemd will be enabled and listening.

    # systemctl status tftp.socket
    ● tftp.socket - Tftp Server Activation Socket
    Loaded: loaded (/usr/lib/systemd/system/tftp.socket; disabled; vendor preset: disabled)
    Active: inactive (dead)
    Listen: [::]:69 (Datagram)

    # systemctl start tftp.socket
    # systemctl status tftp.socket
    tftp.socket - Tftp Server Activation Socket
    Loaded: loaded (/usr/lib/systemd/system/tftp.socket; disabled; vendor preset: disabled)
    Active: active (listening) since 日 2016-04-16 16:16:24 JST; 2s ago
    Listen: [::]:69 (Datagram)
    4月 16 16:16:24 tako systemd[1]: Listening on Tftp Server Activation Socket.
    4月 16 16:16:24 tako systemd[1]: Starting Tftp Server Activation Socket.

    # systemctl enable tftp.socket
    Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
    # systemctl status tftp.socket
    tftp.socket - Tftp Server Activation Socket
    Loaded: loaded (/usr/lib/systemd/system/tftp.socket; enabled; vendor preset: disabled)
    Active: active (listening) since 日 2016-04-16 16:16:24 JST; 39s ago
    Listen: [::]:69 (Datagram)
    4月 16 16:16:24 tako systemd[1]: Listening on Tftp Server Activation Socket.
    4月 16 16:16:24 tako systemd[1]: Starting Tftp Server Activation Socket.

次にFireWallを止めます。CentOS6までは iptables を使っていましたが、CentOS7からは firewalld になりました。

Since firewalld is active, I’ll add the tftp port on the appropriate zone: 
# firewall-cmd --add-service=tftp --zone=internal --permanent
success
# firewall-cmd --reload
success 

参考ページでは上記の通り、FireWall有効のまま設定していたのですが私はこの通りにしてもうまくいかず、PXEからのブート時に
PXE-32: TFTP open timeout
と表示されその先に進めませんでした。

http://itdoc.hitachi.co.jp/manuals/3020/30203L5360/SCDM0220.HTM

Q8
ネットワークブート中,クライアント画面に以下のメッセージが表示され,シナリオ実行エラーとなる。
PXE-E32: TFTP open timeout
A8
Windowsファイアウォールやセキュリティ対策ソフトウェアなどのポートブロック機能によって,TFTPポート(ポート番号:69)がブロックされている可能性があります。

そこでfirewallは「停止」することにしました。PXEサーバは一時的な利用でお役御免ですので、まあいいかなと。

# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 日 2016-04-16 16:12:32 JST; 16min ago
Main PID: 900 (firewalld)
CGroup: /system.slice/firewalld.service
└─900 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
4月 16 16:12:24 tako systemd[1]: Starting firewalld - dynamic firewall daemon...
4月 16 16:12:32 tako systemd[1]: Started firewalld - dynamic firewall daemon.

# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since 日 2016-04-16 16:12:32 JST; 17min ago
Main PID: 900 (firewalld)
CGroup: /system.slice/firewalld.service
└─900 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
4月 16 16:12:24 tako systemd[1]: Starting firewalld - dynamic firewall daemon...
4月 16 16:12:32 tako systemd[1]: Started firewalld - dynamic firewall daemon.

# systemctl stop firewalld
# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
4月 16 16:12:24 tako systemd[1]: Starting firewalld - dynamic firewall daemon...
4月 16 16:12:32 tako systemd[1]: Started firewalld - dynamic firewall daemon.
4月 16 16:30:33 tako systemd[1]: Stopping firewalld - dynamic firewall daemon...
4月 16 16:30:35 tako systemd[1]: Stopped firewalld - dynamic firewall daemon

# vi /etc/sysconfig/selinux
SELINUX=enforcing から SELINUX=disabled に変更。

3. When PXE booting, the server needs to send the client some basic files, which are provided by the syslinux package that I installed on the first step. Then needs to send the kernel and the initial ramdisk matching the target operating system, (just CentOS7 in this case), which I can get from the OS iso, or manually getting the files from the public repository:

現在 /var/lib/tftpboot/ は空です。
# ls /var/lib/tftpboot/

ここに /usr/share/syslinux/ より必要なファイルをコピーします。

# cd /var/lib/tftpboot
[root@tako tftpboot]# cp /usr/share/syslinux/{pxelinux.0,vesamenu.c32} .
[root@tako tftpboot]# ls
pxelinux.0 vesamenu.c32

wget -q
http://mirror.centos.org/centos/7.1.1503/os/x86_64/isolinux/{vmlinuz,initrd.img,splash.png}
(このディレクトリは現在使われていません)

(注:今回は下記の通り北陸先端大JAIST)を使いました。また私のインストール先PCのCPUが古いAMD製(Opteron)のためか、CentOS7.2がインストールできなかった(rest_init+0x80/0x80で止まる)のでCentOS7.1をインストールしました。
0009860: 3.10.0-327.el7 crashes on boot - CentOS Bug Tracker
『Steps To Reproduce Reboot an affected AMD System』

CentOS7.1 http://vault.centos.org/7.1.1503/os/x86_64/
ブート画面で文字がずらずら流れていき、dracut-intqueue うんぬんで数分以上ほぼ同じ文言を繰り替えしてるからちゃんと動いてるのか心配だったけどなんとか「CentOS7へようこそ」へ進めた。ただ、7.2にバージョンアップすると私の環境では止まります…。

適宜自分の欲しいバージョンに変更してください。数字だけ変えてもディレクトリがない場合や、splash.jpg が splash.png だったりと差異がありますので実際に見に行って確認してからアドレスを設定しましょう。)

以下 CentOS7.2を例にとって進めます。

[root@tako tftpboot]# wget http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.2.1511/os/x86_64/isolinux/{vmlinuz,initrd.img,splash.png}

[root@tako tftpboot]# ls

initrd.img pxelinux.0 splash.png vesamenu.c32 vmlinuz

4. I will now create a menu for my PXE service, that will have entries for two different deployment methods: an automated one using a kickstart, and a manual one using a public repository (assuming of course that the client has access to internet). Then I’ll add a third entry for booting from hard drive:

Kickstartファイルを作って自動インストールする方がスマートですが、私はまだ知識がないので手動でいきます。
[root@tako tftpboot]# mkdir pxelinux.cfg
[root@tako tftpboot]# ls
initrd.img pxelinux.0 pxelinux.cfg splash.jpg vesamenu.c32 vmlinuz
[root@tako tftpboot]# cd pxelinux.cfg/
[root@tako pxelinux.cfg]# pwd
/var/lib/tftpboot/pxelinux.cfg

[root@tako pxelinux.cfg]# vi default
default vesamenu.c32
timeout 200
menu background splash.jpg ←pngの場合は変更を。
ontimeout local
label repo
  menu label ^Install CentOS without Kickstart
  kernel vmlinuz
  append initrd=initrd.img ip=dhcp ksdevice=link repo=http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.2.1511/os/x86_64/

label local
  menu label Boot from Hard Drive
  localboot 0xffff

[root@tako pxelinux.cfg]# cd ~
[root@tako ~]#

5. And finally, for a server to be able to use the PXE service, the DHCP server (which could be on the same PXE server or on a different one) needs to know which is the “next-server”, and what file to provide to get the environment started. Something like “go to this guy and get this”. You do that by adding these two lines in red on dhcpd.conf: 

このあと cat /etc/dhcp/dhcpd.conf とDHCPの設定に入るのですが、私はまだDHCPをインストールしていませんのでここで入れます。
[root@tako ~]# rpm -qa | grep dhcp
dhcp-libs-4.2.5-42.el7.centos.x86_64
dhcp-common-4.2.5-42.el7.centos.x86_64
[root@tako pxelinux.cfg]# ls /etc/dhcp/
dhclient.d

[root@tako ~]# yum install dhcp
インストール:
dhcp.x86_64 12:4.2.5-42.el7.centos
完了しました!

[root@tako pxelinux.cfg]# rpm -qa | grep dhcp
dhcp-libs-4.2.5-42.el7.centos.x86_64
dhcp-4.2.5-42.el7.centos.x86_64
dhcp-common-4.2.5-42.el7.centos.x86_64

[root@tako ~]# ls /etc/dhcp/
dhclient.d dhcpd.conf dhcpd6.conf

DHCPの設定。
[root@tako ~]# vi /etc/dhcp/dhcpd.conf
allow unknown-clients;
option domain-name-servers 192.168.10.1;
authoritative;(←これの記載を忘れて途中で止まったことがあります。しかし再現できず)
subnet 192.168.10.0 netmask 255.255.255.0 {
   option routers 192.168.10.1;
   range 192.168.10.2 192.168.10.20;
   next-server 192.168.10.2; (←VMWare上のipアドレス)
   filename "pxelinux.0";
}

CentOS7から ifconfig が非推奨となりました。よって ip コマンドで。
[root@tako ~]# ip addr (または ip a)

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
fifo_fast state UP qlen 1000
link/ether 00:0c:29:24:0b:d1 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.2/24 brd 192.168.10.255 scope global eth0
~ 

DHCPを起動。

 [root@tako ~]# systemctl status dhcpd.service
● dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:dhcpd(8)
man:dhcpd.conf(5)

[root@tako ~]# systemctl enable dhcpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
[root@tako ~]# systemctl start dhcpd.service

[root@tako ~]# systemctl status dhcpd.service
dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2016-04-16 15:42:25 JST; 4s ago
Docs: man:dhcpd(8)
man:dhcpd.conf(5)
Main PID: 5680 (dhcpd)
Status: "Dispatching packets..."
CGroup: /system.slice/dhcpd.service
└─5680 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -gr...

4月 16 15:42:25 tako dhcpd[5680]: No subnet declaration for virbr0 (192.1...).
4月 16 15:42:25 tako dhcpd[5680]: ** Ignoring requests on virbr0. If thi...at
4月 16 15:42:25 tako dhcpd[5680]: you want, please write a subnet decl...on
4月 16 15:42:25 tako dhcpd[5680]: in your dhcpd.conf file for the netw...nt
4月 16 15:42:25 tako dhcpd[5680]: to which interface virbr0 is attached. **
4月 16 15:42:25 tako dhcpd[5680]:
(何か出たけど仮想ネットワークのNICの話なので今回は無視する↑)
4月 16 15:42:25 tako dhcpd[5680]: Listening on LPF/eth0/00:0c:29:58:ca:32...24
4月 16 15:42:25 tako dhcpd[5680]: Sending on LPF/eth0/00:0c:29:58:ca:32...24
4月 16 15:42:25 tako dhcpd[5680]: Sending on Socket/fallback/fallback-net
4月 16 15:42:25 tako systemd[1]: Started DHCPv4 Server Daemon.
Hint: Some lines were ellipsized, use -l to show in full.

That’s all in regards to configuring PXE. When I complete the steps above, the file structure will look like this:

ここまでがPXEの設定です。上記手順を終えると、ファイル構成は下記の8個になります。
root@tako ~]# find /var/lib/tftpboot/
/var/lib/tftpboot/
/var/lib/tftpboot/pxelinux.0
/var/lib/tftpboot/vesamenu.c32
/var/lib/tftpboot/vmlinuz
/var/lib/tftpboot/initrd.img
/var/lib/tftpboot/splash.jpg
/var/lib/tftpboot/pxelinux.cfg
/var/lib/tftpboot/pxelinux.cfg/default

Additionally, since I’m not using Xinetd now, if I wanted to modify the service startup parameters, I no longer modify /etc/xinetd.d/tftp, but the corresponding Systemd file instead. I recommend making a copy of the original file to /etc/systemd/system (takes precedence over /usr/lib/systemd/system) so that future updates don’t overwrite the customized file.

Xinetdは使っていないので、サービスのスタートアップパラメーターを設定する際も、もう /etc/xinetd.d/tftp は使いません。Systemdファイルが代わりを務めます。

設定ファイルは、/usr/lib/systemd/system/以下と/etc/systemd/system/以下にあります。両方のディレクトリに同名の設定ファイルがある場合は、後者(/etc/systemd/system/)のファイルが優先されます。前者(/usr/lib/systemd/system/)には、RPMパッケージが提供するシステム標準の設定を配置しておき、システム管理者が設定変更する場合は、後者にファイルをコピーした上で修正を加えます。
Systemd入門(4) - serviceタイプUnitの設定ファイル - めもめも

設定ファイルの確認・コピー。
[root@tako ~]# ls /usr/lib/systemd/system/

teamd@.service
tftp.service
tftp.socket

[root@tako ~]# ls /etc/systemd/system

sysinit.target.wants
system-update.target.wants

[root@tako ~]# cp /usr/lib/systemd/system/tftp.service /etc/systemd/system
[root@tako ~]# ls /etc/systemd/system

sysinit.target.wants
system-update.target.wants
tftp.service

For example, to increase verbosity for this service, I add “-vvv” on the line that indicates the executable command (ExecStart):

設定の例として、サービスの冗長性を上げます。-vvv をサービス起動コマンドを示すExecStartライン上に付け加えました。
[root@tako ~]# vi /etc/systemd/system/tftp.service
[Unit]
Description=Tftp Server
[Service]
ExecStart=/usr/sbin/in.tftpd -vvv -s /var/lib/tftpboot
StandardInput=socket

/etc/systemd/system/以下の「systemdとしてのservice設定ファイル」を変更した場合、この変更をsystemdに反映させるには、次のdaemon-reloadオプションを使用します。
Systemd入門(2) - Serviceの操作方法 - めもめも 

 [root@tako ~]# systemctl daemon-reload

Then, watching journalctl while a client boots on PXE, it shows detailed information of the process:

[root@tako ~]# journalctl -f -n0

この後、インストール先のPCを立ち上げ、途中でF12キーなどを押しPXEブートに入る。

f:id:demandosigno:20160530003223j:plain

CentOS7のスプラッシュ画面まで行ったが、その先に進もうとするとアンダーバー一本で止まってしまった。確かにログも
4月 16 16:41:50 tako in.tftpd[6388]: RRQ from ::ffff:192.168.10.3 filename splash.jpg
で止まっており、その先に進めていない。

毎度引っかかるグラフィックボードが悪いんだろうなと予想し検索したら実際そのようでした。

スプラッシュ画面で[Tab]を押してオプションを追加。
vmlinux initrd.img initrd=initrd.img ip=dhcp ksdevice=link repo=http://ftp.jaist.ac.jp/pub/Linux/CentOS/6.7/os/x86_64/ に続けて
xdriver=vesa nomodeset と記載することでその先に進めた。

追記:DHCPの設定を間違っても(next-server の値を間違ったり)上記のDHCPACKあたりで止まります。修正してDHCPを再起動してもう一度試してください。

追記:後日  VMware vSphere Hypervisor で仮想化してみました。こっちの方が後で楽そうでいいですね。

ML115 G1 に VMware vSphere Hypervisor をインストール - demandosigno

ただ、vSphereはGeforceグラボがパススルー対応外のようで、結局生インストールに戻しました。

CentOS をネットワークインストールする。その3 xinetd ではなく systemd を

CentOS7 をネットワークインストールする。その2 PXEサーバ

で色々やってみたのですがうまくインストールできませんでした。

そこで疑問に思ったことが一つあります。当初ネットを検索してPXEでのインストール方法を探したところ皆 xinetd を使ってるんです。

www.unixmen.com

tapira.hatenablog.com

HowTos/PXE/PXE Setup - CentOS Wiki ←公式のWikiですら xinetd。

CentOS7 をネットワークインストールする。その2 でも言及したんですが、xinetdはCentOS7ではレガシー行きになって、替わりにSystemdになったんじゃないの?と。

そこであらためて検索したところ、次のブログを見つけました。

nothen.com.ar

欲しかった内容そのままの記事ですね。

4 May, 2015 in Linux by Eric Nothen
There are tons of articles on the internet about configuring a PXE server, most of them unnecessary long and complex. Moreover, they all focus on using Xinetd. As you know, Xinetd is a daemon that LET’S JUST LEAVE WIKIPEDIA EXPLAIN IT:
インターネット上にはPXEサーバ設定に関する沢山の記事がありますが、そのほとんどが不必要に長くて複雑です。その上、それらはすべて Xinetd を使用することに焦点を置いています。ご存じの通り、Xinetd はデーモンです--ウィキペディアにそのまま説明してもらいましょう:

 xinetd - Wikipedia この場では日本語Wikipdeia から引用
 >xinetdは、Unixオペレーティングシステムで動作するオープンソースのスーパーサーバ型デーモンで、インターネットベースの接続性を管理する。inetdをよりセキュアに拡張したバージョンである。<

Well, at least the English version of this article includes a brief explanation of how Xinetd allows for on-demand services. That is, avoid running services while they are not receiving connections. So all cool with Xinetd, but truth is that because of its limitations, it’s being used less and less these days.
まあ、少なくともこの記事(Wikipedia)の英語版は、xinetd がオンデマンドサービス(ftpサーバ、telnetサーバ等の代わりに接続要求を待ちうけ、要求があれば各サービスを起動する。接続要求を受信していない間はサービスを起動しない)を可能にする方法の簡単な説明が含まれています。だから、すべて xinetd でもかまわないのですが、その機能の限界を理由として、近頃では次第に利用されなくなっています。

In modern operating systems, like CentOS/RHEL7, and since Fedora 15 (released almost 4 years ago!), Systemd can not only replace Xinetd’s functionality, but also add some features of its own, like centralization of logs and status monitoring. Systemd deserves a whole article on its own (or several), but before I write about that, I need to do proper research (?), so I’ll leave that for another time.
CentOS / RHEL7 などの最新のオペレーティングシステムFedora 15 以降(ほぼ4年前にリリース!)では、Systemd は Xinetd の機能を置き換えるだけでなく、ログの集約やステータス監視のように、独自のいくつかの機能を追加します。"Systemd" だけで丸ごと一つの(または複数の)記事を書くに値しますが、それには事前に相応の研究を行う必要があります(?)ので、またの機会に。

Back to PXE, I was surprised to see that even Red Hat, on their official RHEL7 documentation (here), uses Xinetd to run tftp and provide PXE service, something completely unnecessary, as I’m about to display, ladies and gentlemen (?).
PXEに戻りましょう。私は Red Hat の公式 RHEL7 ドキュメント(こちら)でさえ、TFTPを実行し PXE サーバを準備するのに Xinetd を使用していることに驚きました。完全に不必要なものです。今から私がお見せしましょう。皆様?(用意はいいですか?)

翻訳に自信はありません。が、この上記記事に沿って行ったらインストールできました。数点変更した部分がありますが、とりあえず今日はここまで。詳細はまた来週記載します。 

CentOS7 をネットワークインストールする。その4

/* -----codeの行番号----- */