grub rescue
fix grub rescue 'file not found' error in Ubuntu
Boot Ubuntu from a LiveCD or Live USB
Connect to the internet
Open a terminal, and add the Boot Repair PPA sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
Install Boot Repairsudo apt-get install -y boot-repair && boot-repair
Launch and use
grub rescue > ls (hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1) grub rescue > ls (hd0,msdos1) # try to recognize which partition is this grub rescue > ls (hd0,msdos2) # let's assume this is the linux partition grub rescue > set root=(hd0,msdos2) grub rescue > set prefix=(hd0,msdos2)/boot/grub # or wherever grub is installed grub rescue > insmod normal # if this produced an error, reset root and prefix to something else .. grub rescue > normal
or update upgrade it will reinstall new grub
For a permanent fix run the following after you successfully boot:
sudo update-grub sudo grub-install /dev/sdX
where /dev/sdX is your boot drive.
GRUB(GRand Unified Bootloader) เป็น bootloader เอนกประสงค์ ที่ถูกพัฒนาด้วย Linux จุดประสงค์ส่วนใหญ่เอาไว้ทำ multiboot
การปรากฏข้อความ error ดังกล่าว แสดงว่า sector 0 ของฮาร์ดดิสก์(MBR) มี bootloader ชื่อ GRUB legacy หรือ GRUB2
grub rescue> เป็นหนึ่งในโหมด rescue ของ GRUB2 ที่มีสาเหตุมาจาก GRUB2 หาโฟลเดอร์ grub ไม่เจอ หรือสูญหายไปจากฮาร์ดดิสก์(อาจเกิดขึ้นตอนที่คุณรี?/จัดการวินโดว์)
1. วิธีแก้ที่ง่ายและเร็ว เนื่องจากคุณไม่มีแผ่นสำหรับบูตใดๆเลย ให้ทำตามความเห็น 2 หาแผ่นบูตมาช่วยโดยดาวน์โหลดไฟล์ ISO ของวินโดว์จากเว็ป Microsoft โดยตรงมาทำเป็น bootable CD/DVD/USB แล้วบูตจากสื่อที่ทำ
ในหน้าติดตั้งวินโดว์ 10 กด Shift+F10 หรือ คลิก Next > Repair your computer > Troubleshoot > Advanced Options > Command prompt
แล้วพิมพ์
Bootrec /fixmbr เคาะ Enter
วินโดว์จะทำการเขียน bootloader ตัวใหม่ชื่อ BOOTMGR(Windows Boot Manager) ลงใน MBR และวินโดว์ก็จะกลับมาบูตได้โดยไม่ใช้ GRUB
2.ใช้พวก LiveCD เช่น "Ultimate Boot CD" หรือ WinPE หรือ Linux Live เช่น Ubuntu Live CD ในกรณีที่อยากเก็บ GRUB ไว้ใช้ในภายหลัง แหล่งข้อมูลลองหาจาก google
ตัวอย่างผลลัพธ์จากการค้นหา:
[Spoil] คลิกเพื่อดูข้อความที่ซ่อนไว้
3.ถ้าไม่อยากสืบหาหรือลงมือทำเองก็พึ่งช่าง(ง่ายสุด)
4.(กรณีฟิตจัด ต้องการความท้าทาย) อยากลองเสี่ยงโชคโดยไม่มีตัวบูตอะไรเลย โดยใช้แค่ทรัพยากรที่มีอยู่ตอนนี้ ถึงแม้โอกาสสำเร็จจะมีน้อย ลองตามนี้ดูครับ
4.1 ในหน้าคำสั่ง grub rescue> ในเมื่อมันหาโฟลเดอร์ grub ไม่เจอ ลองช่วยมันหาซิ(เผื่อมีโชค) อย่างแรกแสดงพาร์ติชั่นทั้งหมดด้วยคำสั่ง ls(แอลเอส)
grub rescue> ls แล้ว Enter
ตัวอย่างผลลัพธ์
(hd0) (hd0,msdos4) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1)
คำอธิบาย
[Spoil] คลิกเพื่อดูข้อความที่ซ่อนไว้
4.2 แสดงการตั้งค่าของ GRUB ที่กำลังใช้งานอยู่ ด้วยคำสั่ง set
grub rescue> set แล้ว Enter
ตัวอย่างผลลัพธ์
prefix=(hd0,msdos2)/grub2
root=hd0,msdos2
อธิบาย
[Spoil] คลิกเพื่อดูข้อความที่ซ่อนไว้
4.3 หาไฟล์ข้อมูลสำคัญของ GRUB ใน /boot/grub2 จากพาร์ติชั่นอื่น เช่น grub.cfg (ไฟล์เมนู) ด้วยคำสั่ง ls (xxx,xxx)/grub2
ตัวอย่างคำสั่งและผลลัพธ์
grub rescue> ls (hd0,msdos2)/grub2
error: unknown filesystem.
grub rescue> ls (hd0,msdos1)/grub2
error: unknown filesystem.
grub rescue> ls (hd0,msdos4)/grub2
error: unknown filesystem.
grub rescue> ls (hd0,msdos3)/grub2
./ ../ grubenv themes/ device.map i386-pc/ locale/ fonds/ grub.cfg
*ให้หาในทุกพาร์ติชั่นที่มีในรายการที่ได้จากคำสั่ง ls ในข้อ 4.1 ถ้าเจอเหมือนผลลัพธ์ที่ 4 ทำต่อ แต่ถ้าไม่เจอเหมือนผลลัพธ์ 1-3(error: unknown filesystem.) ให้เลิกทำวิธีนี้เพราะโฟลเดอร์ grub ถูกลบไปอย่างสมบูรณ์แล้ว*
จากตัวอย่างเราเจอไฟล์ grub.cfg ใน (hd0,msdos3) จดหรือจำไว้เพราะนี่คือเป้าหมายที่เราจะสั่งให้ GRUB บูตเข้าเมนู
4.4 เปลี่ยนพาร์ติชั่นที่จะบูตที่ได้จาก 4.3 ด้วยคำสั่ง set prefix และ set root
grub rescue> set prefix=(hd0,msdos3)/grub2
grub rescue> set root=hd0,msdos3
4.5 ตรวจสอบการเปลี่ยนแปลงด้วยคำสั่ง set (แล้วเปรียบเทียบกับผลลัพธ์ 4.2 ดูว่ามันเปลี่ยนให้รึยัง)
grub rescue> set
prefix=(hd0,msdos3)/grub2
root=hd0,msdos3
4.6 ติดตั้งและรันโหมด normal เพื่อเข้าสู่เมนูบูตของ GRUB2
grub rescue> insmod normal
grub rescue> normal
4.7 ในหน้าเมนูเลือกบูตจาก Linux(ปกติจะอยู่เมนูแรก) **แต่ถ้าโชคไม่เข้าข้าง มี error และไม่ปรากฏเมนู ก็หมดหวังสำหรับวิธีนี้**
***ถ้าในฮาร์ดดิสก์ไม่มี Linux รันอยู่เบื้องหลังหรือซ่อนอยู่จริง จะมี error ขึ้นมาแจ้ง เช่น "Kernel not found", "Please do load kernel first." อะไรประมาณนี้ ก็หมดสิทธิ์เช่นกัน ***
4.8 ถ้าในฮาร์ดดิสก์มี Linux ซ่อนอยู่ และสามารถผ่านเข้าสู่หน้าล็อกอินได้ ให้ทำการล็อกอิน แล้วตั้งค่าเริ่มต้นการบูตใหม่ให้กับ Linux ด้วยคำสั่งตามนี้ใน command line/terminal
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo grub2-install /dev/sda
โดยที่ /dev/sda เป็นไดรฟ์บูตของ Linux หลังจากระบบคืนค่าการบูตให้กับพาร์ติชั่นที่ active เรียบร้อยแล้ว ให้ทำการรีบูตเพื่อชมผลงานด้วยคำสั่ง
sudo reboot
คราวนี้ ระบบน่าจะบูตผ่าน kernel ของวินโดว์ได้ โดยมี GRUB เป็น bootloader ใน MBR เหมือนที่เครื่องคุณเคยมีมาอยู่แล้ว