ドキュメント
Amazon EC2 / TurnKey Hub - 起動の問題のgrubを修正/rootパスワードを回復
VM(またはベアメタルインストール)では、ライブISOを使用して、多くのgrub、カーネル、その他の関連の問題(例えば、ルートアクセスを紛失)を修正することができます。 しかし、AWSではオプションではありません。 しかし、root ボリュームを 1 つのサーバーから別のサーバーに添付することができます。, あなたには、多くの grub を修正するために、やや類似の環境を与える, 起動や関連の問題. このページでは、Hub、AWS コンソール、SSH セッションで行う方法の概要について説明します。
特定のステップ - コマンドを含む
サーバラベルはOLDとNEWで、それぞれ元の(壊れた)サーバと新しい一時サーバを記述します。
これらの手順は、'Hub' または 'AWS コンソール' 内で通知されるように実行する必要があります。コマンドは、NEW サーバー内のシェル内で実行されるすべてのもの(SSH セッション経由)です。
- ハブ: NEWサーバをNEWサーバで起動 壊れたサーバーと同じ可用性ゾーン. これは、t2.microコアがうまくいくなど、アプライアンスまたはサイズであってもよい - しかし、同じ可用性ゾーンにある必要があります!
- ハブ: OLDサーバーを停止します。
- AWS コンソール: OLDが止まったら、rootのボリュームを外します。
- AWS コンソール: NEW(二次ボリュームとして)にrootのボリュームを添付します。マウントポイントを要求する場合は、使用してください。
/dev/sdf. - SSH 経由で NEW にログインします。 chroot を設定し、入力するために、次のコマンドを使用します。
# check that the OLD server volume is attached as /dev/xvdf: gdisk -l /dev/xvdf # Assuming OLD server volume is /dev/xvdf, mount it and chroot in: mkdir /mnt2 mount /dev/xvdf2 /mnt2 mount --bind /dev /mnt2/dev mount --bind /proc /mnt2/proc mount --bind /sys /mnt2/sys chroot /mnt2
- SSH - chroot で Fix(es) を実行します。 エラーなしで成功すると、OLDサーバーのボリュームのchrootの中にいます。 次回の作業は、アドレスを探し出す問題によって異なります。 起動の問題に関連するいくつかの潜在的な修正、root パスワードのリセットに関係しています。
# optional: update kernel
apt-get update
apt-get install linux-image-$(dpkg --print-architecture)
apt-get install linux-image-$(uname -r)
# optional: regenerate initramfs (will be run automatically if the kernel is updated)
update-initramfs -u
# Note: as part of the initramfs regeneration process (whether via updating the
# kernel, or manually regenerating) it is expected and normal to see the
# following errors/warnings:
#
# /usr/share/initramfs-tools/scripts/casper-bottom/25autologin: 13: .: Can't open /scripts/casper-functions
# /usr/share/initramfs-tools/scripts/casper-bottom/25singleuser_shell: 6: .: Can't open /scripts/casper-functions
# /usr/share/initramfs-tools/scripts/casper-bottom/25ssh_emptypw: 6: .: Can't open /scripts/casper-functions
# To avoid adding grub boot entries for the host machine (i.e. the NEW server), disable the OS prober
# (note os-prober has no value other than on dual boot machines)
chmod a-x /etc/grub.d/30_os-prober
# reinstall grub2
grub-install --boot-directory=/boot /dev/xvdf
update-grub
# reset root password
passwd root
# add a public SSH key
echo "_keytype_ _public_key_data_ _email_" >> /root/.ssh/authorized_keys
# IMPORTANT: replace "_keytype_ _public_key_data_ _email_" with the contents of your public key.
# email is optional but highly recommended
# ログをチェックしたり、必要に応じて追加のパッケージをインストールしたりなど、他のことをすることもできます。- SSH - Unmount OLD volume: うまく機能し、エラーがなかったことを願っています。 仮定すると、chrootを終了し、すべてをアンマウントします。
# exit and tidy up exit umount /mnt2/dev umount /mnt2/proc umount /mnt2/sys umount /mnt2
- AWS コンソール: NEW から OLD のルートボリュームを解除し、元のサーバー (OLD) に再添付します。 添付ポイントをそのまま指定します。
/dev/xvda. - ハブ: ブートOLD - 指は、それが今起動します! もしそう素晴らしい! そうでない場合は、ステップ2-8を繰り返して、chroot(ステップ6)内のいくつかの異なるステップを試みます。