tech_memo / linux / cobbler / dualBoot / appendix


tech_memo/linux/cobbler/dualBoot

デュアルブートサーバに新規OSをインストールする前に設定すること

  • インストールした後でも作業可能だが、インストールしたOSを起動するための設定。
  • プライマリOSの、/etc/grub.confに、新規インストールしたOSのエントリを追加する
    • 下記は、RHEL7.2を2番目のDisk(hd1)新規インストールした場合の追記分。Disk番号(0オリジン)と、ルートパーティションを含むパーティション番号(0オリジン)を記入すること
      title Red Hat Enterprise Linux 6.3 (2.6.32-279.el6.x86_64)
              root (hd0,0)
              kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/VolGroup00-LogVol00 rhgb quiet vnc rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=la
              initrd /initramfs-2.6.32-279.el6.x86_64.img
      title Red Hat Enterprise Linux 6.5 (2.6.32-431.el6.x86_64)
              root (hd1,0)
              kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VG_rhel65-LV_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=VG_rhel65/LV_root rd_NO_MD
              initrd /initramfs-2.6.32-431.el6.x86_64.img
      title Red Hat Enterprise Linux 7.1 (3.10.0-229.el7.x86_64)
             root (hd1,2)
             kernel /vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/VG_rhel71-LV_root ro crashkernel=auto rd.lvm.lv=VG_rhel71/LV_swap rd.lvm.lv=VG_rhel71
             initrd /initramfs-3.10.0-229.el7.x86_64.img
      title Red Hat Enterprise Linux 7.2 (3.10.0-327.el7.x86_64) # ★ここから下が追記分
              root (hd1,5) # ★ 2番目のDiskの6番目のパーティション
              kernel /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/VG_rhel72-LV_root ro crashkernel=auto rd.lvm.lv=VG_rhel72/LV_root rd.lvm.lv=VG_rhel72        initrd /initramfs-3.10.0-327.el7.x86_64.img

デュアルブートサーバに新規OSをインストールした後設定すること

1. 新規OSのホストキーを旧OSのホストキーで上書く~

  • 新規OSをインストールすると、旧OSと異なるホストキーが作成されているので、他サーバからログインする際にキー認証エラーになる。
  • これを解消するため、新OSのホストキーを旧OSと同じものに置き換える
  1. 新OSサーバにrootでログイン
    • 下記のように接続エラーになった場合は、旧OSのホスト公開キーがログイン実行元に登録されているので削除すること
      shishimaru@myserver% ssh root@testserver12
      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
      Someone could be eavesdropping on you right now (man-in-the-middle attack)!
      It is also possible that the RSA host key has just been changed.
      The fingerprint for the RSA key sent by the remote host is
      ed:7a:82:4a:83:2f:c4:21:e5:55:71:e2:b3:58:44:ae.
      Please contact your system administrator.
      Add correct host key in /home/shishimaru/.ssh/known_hosts to get rid of this message.
      Offending key in /home/shishimaru/.ssh/known_hosts:53
      RSA host key for testserver12 has changed and you have requested strict checking.
      Host key verification failed.
    • 削除方法
      shishimaru@myserver% ssh-keygen -R testserver12
      /home/shishimaru/.ssh/known_hosts updated.
      Original contents retained as /home/shishimaru/.ssh/known_hosts.old
    • 削除後、ログインできるようになる
      shishimaru@myserver% ssh root@testserver12
      The authenticity of host 'testserver12 (192.168.22.112)' can't be established.
      RSA key fingerprint is ed:7a:82:4a:83:2f:c4:21:e5:55:71:e2:b3:58:44:ae.
      Are you sure you want to continue connecting (yes/no)? yes
      Warning: Permanently added 'testserver12,192.168.22.112' (RSA) to the list of known hosts.
      root@testserver12's password:
      [root@testserver12 ~]#
  2. 新OSの/etc/sshディレクトリをバックアップ
    [root@testserver12 etc]# cp -pr /etc/ssh /etc/ssh_org 
  3. 旧OSのルートパーティションを適当な場所にマウント
    [root@testserver12 ~]# mkdir /mnt/tmp
    [root@testserver12 ~]# mount /dev/VG_rhel65/LV_root /mnt/tmp/
  4. 旧OSのホストキーをコピー
    [root@testserver12 etc]# cp -p /mnt/tmp/etc/ssh/*key* /etc/ssh/
    cp: overwrite ‘/etc/ssh/ssh_host_rsa_key’? y
    cp: overwrite ‘/etc/ssh/ssh_host_rsa_key.pub’? y
  5. 旧OSのルートパーティションをアンマウント。完了
    [root@testserver12 ~]# umount /mnt/tmp/
    • ちなみに、再度同じサーバからログインする場合は、冒頭のエラーが発生するので、同じ手順でホストキーを削除すること。 [#r761af56]

2. 起動OS切り替えコマンド'chbootos'のセットアップ

  1. セットアップファイル群をsvn からチェックアウト
    [root@testserver12 ~]# svn export http://svnserver/svn/trunk/personal/shishimaru/tools/linux/dual_boot
  2. チェックアウトしたディレクトリに移動し、dual_boot/etc/auto.rhel65のfstype, UUIDを書き換える
    [root@testserver12 ~]# cd dual_boot/
    [root@testserver12 dual_boot]# vim etc/auto.rhel65
    boot    -fstype=ext4    :UUID=8e861382-50ec-4773-8009-ccc1d8663ce3
    • 書き換える値は、下記を参照
      testserver01: boot      -fstype=ext4    :UUID=75af5a56-ca12-49ea-9107-df10b50c7ed8
  3. setup_rhel7.shを実行
    [root@testserver12 dual_boot]# ./setup_rhel7.sh
    Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
  4. chbootosコマンドを実行して、以下のような画面が表示されればOK
    [root@testserver12 dual_boot]# chbootos
    
    ---------------------------------------------------------
    Please select number you want boot next time.
    ---------------------------------------------------------
     [0] Red Hat Enterprise Linux 6.3 (2.6.32-279.el6.x86_64)
     [1] Red Hat Enterprise Linux 6.5 (2.6.32-431.el6.x86_64)
     [2] Red Hat Enterprise Linux 7.1 (3.10.0-229.el7.x86_64)
    *[3] Red Hat Enterprise Linux 7.2 (3.10.0-327.el7.x86_64)
    
     Current setting, '*' mark entry will run next rebooting
    
    >>
  5. ゴミ削除
    [root@testserver12 dual_boot]# cd ../
    [root@testserver05 ~]# rm -rf dual_boot/

3. testserver18とのホストベース認証

  • testserver18から新OSサーバにパスワードなしでログインする設定。設定自体は、ほとんどOSインストール直後に自動でおこなわれているので、最後のしめを手動で行う。
  • 手順はシンプルで、testserver18 -> 新OSサーバ -> testserver18 の順にsshログインするだけ。左記作業完了後、testserver18からパスワードなしでログインできるようになる

4. Nistpackの依存PKGの取得とインストール(RHEL7以降。rootユーザで実施)

# wget http://testserver18/cblr/ks_mirror/RHEL7.2/addedPkgByManual/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
# rpm -ihv compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm

5. Redmineの設備・ライセンス管理チケット( #2089 )への登録

  • 本作業を実施したサーバのチケットのOS項目を編集

起動OSの切り替え・インストール済OSの確認 (CUI編)

  • rootユーザでchbootosコマンドを実行する。起動OSの切り替えをするコマンドだが、インストール済みOSを確認するだけなら、Ctrl+Cを押して、キャンセルすればよい
  • 下記例では、5.5と6.5がインストールされていることがわかる
    [root@testserver05 ~]# chbootos
    ---------------------------------------------------------
    Please select number you want boot next time.
    ---------------------------------------------------------
     [0] Red Hat Enterprise Linux 5.5 (2.6.18-194.el5)
    *[1] Red Hat Enterprise Linux 6.5 (2.6.32-431.el6.x86_64)
    
     Current setting, '*' mark entry will run next rebooting
    
    >>
  • 「*」マークがついているエントリが、次回リブート時に起動されるOS
  • 変更する場合は、続けて、次回リブート時に起動したエントリの番号を入力する
    ---------------------------------------------------------
    Please select number you want boot next time.
    ---------------------------------------------------------
     [0] Red Hat Enterprise Linux 5.5 (2.6.18-194.el5)
    *[1] Red Hat Enterprise Linux 6.5 (2.6.32-431.el6.x86_64)
    
     Current setting, '*' mark entry will run next rebooting 
    
    >>0
    ---------------------------------------------------------
    Success to update entry which will be booted next time.
    ---------------------------------------------------------
    *[0] Red Hat Enterprise Linux 5.5 (2.6.18-194.el5)
     [1] Red Hat Enterprise Linux 6.5 (2.6.32-431.el6.x86_64)
    
    [root@testserver05 ~]#
  • 以上で、次回リブート時には、RHEL5.5のOSが起動されることになる

起動OSの切り替え (GUI編)

  • サーバ起動時の画面が見れることが前提。リモートKVM?を使用すれば、自席からでも可能。
  • 起動時の、以下の画面で、Enterを押す
    • &ref(): File not found: "grub_wait_disp.png" at page "tech_memo/linux/cobbler/dualBoot/appendix";
  • 以下のように、インストール済みOSが表示されるので、起動したいレコードにカーソルを合わせてEnterを押す
    • &ref(): File not found: "select_boot_os.png" at page "tech_memo/linux/cobbler/dualBoot/appendix";

現在起動しているOSの確認方法

  • /etc/redhat-releaseを確認する
    [root@testserver05 ~]# cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 6.5 (Santiago)