दस्तावेज़
अमेज़न EC2 / TurnKey Hub - ग्रब बूट मुद्दों को ठीक करें / रूट पासवर्ड ठीक करें
एक VM (या नंगे धातु स्थापित) पर, आप कई grub, कर्नेल और अन्य संबंधित मुद्दों (जैसे रूट एक्सेस खो दिया) को ठीक करने के लिए एक लाइव ISO का उपयोग कर सकते हैं। लेकिन AWS पर यह विकल्प नहीं है। हालांकि, रूट वॉल्यूम को एक सर्वर से दूसरे सर्वर तक संलग्न करना संभव है, जिससे आपको कई grub, बूट और संबंधित मुद्दों को ठीक करने के लिए कुछ समान वातावरण प्रदान किया जा सकता है। यह पृष्ठ हब, AWS कंसोल और SSH सत्र के माध्यम से कैसे किया जाए, इसका अवलोकन देता है।
विशिष्ट चरण - कमांड सहित
मैं सर्वर लेबल OLD और NEW का उपयोग क्रमशः मूल (टूट) सर्वर और नए अस्थायी सर्वर को दर्शाने के लिए करता हूं।
इन चरणों को 'हब' या 'AWS कंसोल' के भीतर उल्लेखित किया जाना चाहिए। कमांड सभी को आपके NEW सर्वर (SSH सत्र के माध्यम से) में एक खोल के भीतर किया जाना चाहिए।
- हब: NEW सर्वर को भीतर शुरू करें टूटे सर्वर के समान उपलब्धता क्षेत्रयह किसी भी सर्वर या आकार हो सकता है, उदाहरण के लिए एक t2.micro कोर ठीक होगा - लेकिन एक ही उपलब्धता क्षेत्र में होना चाहिए!
- हब: OLD सर्वर बंद करो।
- AWS कंसोल: एक बार OLD बंद हो गया है, रूट वॉल्यूम को अलग करें।
-
AWS कंसोल: Attach the (OLD) root volume to NEW (as a secondary volume). When asked for mount point, use
/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 में फिक्स (es) का प्रदर्शन: यह मानते हुए कि कोई त्रुटि नहीं है, अब आप अपने OLD सर्वर वॉल्यूम के चुटकुले के भीतर हैं। आप क्या करते हैं, क्या आप इस बात पर निर्भर करेंगे कि आप किस मुद्दे को संबोधित करना चाहते हैं। मैं कुछ संभावित फिक्स को नोट करता हूं जो बूटिंग मुद्दों के साथ-साथ रूट पासवर्ड को रीसेट करने के लिए प्रासंगिक हैं:
# 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: उम्मीद है कि सभी अच्छी तरह से काम करते हैं और आपको कोई त्रुटि नहीं मिली। ऐसा करने से, चुटकुले से बाहर निकलें और सब कुछ अनमाउंट करें:
# exit and tidy up exit umount /mnt2/dev umount /mnt2/proc umount /mnt2/sys umount /mnt2
-
AWS कंसोल: Unattach OLD root volume from NEW, and reattach to the original server (OLD). Specify the attachment point as
/dev/xvda. - हब: बूट OLD - उंगलियों को पार कर गया यह अब बूट होगा! यदि ऐसा नहीं है तो दोहराएं चरण 2-8 चुटकुले (चरण 6) के भीतर कुछ अलग चरणों की कोशिश कर रहा है।