Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows Server

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

Boot Manager ใน Windows เวอร์ชันใหม่ใช้ไฟล์ BCD (Boot Configuration Data) เพื่อบูท Operating System ที่ติดตั้งบนคอมพิวเตอร์ ไฟล์นี้มีข้อมูลเกี่ยวกับ OS ที่ติดตั้งและ Boot Parameters Windows ไม่สามารถบูทปกติได้หาก BCD File ถูกลบหรือเสียหาย นอกจากนี้ จะบูท Windows ไม่ได้หาก Master Boot Record (MBR) บนฮาร์ดดิสก์เสียหาย บทความนี้แสดงวิธี Rebuild Windows Boot Manager, BCD Configuration File และแก้ไข MBR บน Windows 10 และ 11 ให้ถูกต้อง

The Boot Configuration Data File is Missing ใน Windows 10 หรือ 11

หาก BCD File หายหรือเสียหาย หากลบ/Format Disk Partition แยกที่มี Label System Reserved (ขนาด 500 MB) หรือ Special OEM Recovery Partition ผู้ใช้มักเห็นข้อความตอนพยายามบูท Windows:

Your PC needs to be repaired The Boot Configuration Data file is missing some required information File: \Boot\BCD Error code: 0xc0000034

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

Error อาจมีรูปแบบอื่น:

The Boot Configuration Data for your PC is missing or contains errors. File: \boot\bcd Error Code: 0xc000000f

หาก MBR เสียหาย อาจเกิด Error "An operating system wasn't found"

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

หากข้อความ Error อ้างถึง File winload.efi ไปที่บทความ Winload.efi is missing in Windows 10

วิธีซ่อม Windows Bootloader แบบอัตโนมัติ

หาก Error ปรากฏ ลองแก้ปัญหา Boot OS ด้วย Startup Repair Mode ที่เริ่มจาก Windows Recovery Environment (Windows RE)

เคล็ดลับ ควรตรวจสอบสุขภาพ WinRE Environment เป็นประจำ หากไม่ทำงาน ใช้วิธีในบทความ "How to Recover WinRE in Windows" ซ่อมมัน

หาก Automatic Repair ด้วย Startup Repair ไม่ช่วย Boot คอมพิวเตอร์จาก Windows Boot/Installation Disk หรือใน WinRE Environment (Repair your computer → Troubleshoot → Advanced options → Command Prompt) เริ่ม Command Prompt ลองสร้าง BCD File ใหม่ และ Update MBR Record ใหม่จากศูนย์

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ตัวอย่างใช้ Windows 10 Installation Disk เปลี่ยน Primary Boot Device เป็น DVD Drive หรือ USB Flash Drive ที่มี Windows Setup Files ใน BIOS Settings (ขึ้นอยู่กับอุปกรณ์ที่ต้องการ Boot) Boot คอมพิวเตอร์จาก Windows Install Image กด Shift + F10 บนหน้าจอเลือกภาษา จะเห็น Command Prompt

ลองซ่อม BCD File อัตโนมัติด้วยคำสั่ง:

bootrec /RebuildBCD

Reboot Computer และตรวจสอบว่า Windows บูทได้ (อย่าลืมเปลี่ยน Boot Device Priority ใน BIOS Settings) หาก Windows ไม่บูท Boot จาก Installation Media อีกครั้งและเปิด Command Prompt

ระบุ Disk Partition Layout และ Drive Letters

สำคัญมาก คำแนะนำด้านล่างเหมาะกับคอมพิวเตอร์ BIOS มาตรฐาน (หรือ Boot ใน UEFI Legacy Mode) ที่มี MBR Partition Table บนคอมพิวเตอร์ที่มี UEFI Firmware ต้องใช้คู่มือซ่อม EFI Bootloader บน Windows 10 หรือ Restore Deleted EFI Partition

วิธีรู้ว่ามี BIOS หรือ UEFI? วิธีง่ายที่สุดตรวจสอบ Disk Partition Table ที่ติดตั้ง Windows: GPT หรือ MBR รันคำสั่ง:

diskpart

List Available Disks:

list disk

  • หาก Disk มี Asterisk (*) ใน Column Gpt แสดงว่าใช้ GPT Partition Table บน Disk นี้ หมายถึงคอมพิวเตอร์ UEFI ต้องใช้บทความจาก Link ด้านบนซ่อม Bootloader
  • หากไม่มี Asterisk ใน GPT Column แสดงว่าเป็น MBR Partition Table บน Disk สามารถทำต่อตามคู่มือนี้ได้

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ต่อไป ต้องระบุ Local Drives และ Volumes บนคอมพิวเตอร์ (Drive Letters ที่ Assign ไปน่าจะต่างจากที่เห็นตอนทำงานใน Windows) ทำง่ายด้วย diskpart รันคำสั่ง:

diskpart
list vol

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

จะเห็นรายการ Partitions, Drive Letters ที่ Assign และ Sizes ในกรณีของเรา มี Hard Drive เดียว มี 2 Volumes:

  • System Reserved Partition ขนาด 500 MB Drive Letter C: Assigned โดย Default Windows Boot Manager และ BCD File อยู่บน Service Partition ขนาดเล็กนี้ (อ่านเพิ่มเติม)
  • NTFS Partition ขนาด 39 GB Letter D: Assigned Partition นี้มี Windows ติดตั้ง, Programs, และ User Data

สำคัญ จด Drive Letters ที่ Assign ไว้ เนื่องจากจะใช้ในคำสั่งต่อไป

ซ่อม Master Boot Record (MBR) บน Windows 10/11

ใช้ Tool bootrec.exe เขียนทับ Data ใน MBR และ Boot Sector เพิ่ม Path ที่จำเป็นไปยัง Windows Boot Manager

ลองเขียนทับ Master Boot Record (MBR) ของ System Partition เพื่อความเข้ากันได้กับ Windows Boot Loader (Existing Partition Table ไม่ถูกเขียนทับ)

bootrec.exe /fixmbr

เพิ่ม Code ไปยัง Boot Sectors ของ Disk เพื่อโหลดไฟล์ bootmgr (Windows Boot Manager):

bootsect.exe /nt60 all /force

หากไม่พบ bootsect.exe ลองระบุ Full Path:
X:\boot\bootsect.exe /nt60 all /force

ก่อนขั้นต่อไป ลอง Rebuild BCD Bootloader Configuration อัตโนมัติด้วยคำสั่ง (วิธีง่ายสำหรับมือใหม่):

bootrec /FixBoot – สร้าง Boot Sector ใหม่บน System Partition และเขียนทับ Boot Record ของ PBR Partition
bootrec /ScanOs – สแกน Drives ทั้งหมด หา Installed Copies ของ Windows ที่ไม่อยู่ใน Boot Configuration Store
หาก Scan สำเร็จ จะ Prompt ให้เพิ่ม Entries เกี่ยวกับ Windows ที่พบเข้า BCD Configuration:

Scanning all disks for Windows installations. Please wait, since this may take a while... Successfully scanned Windows installations. Total identified Windows installations: 1 [1] D:\Windows Add installation to boot list? Yes/No/All:

bootrec /RebuildBcd – สร้าง Bootloader Configuration Store ใหม่ เพิ่ม Copies ของ Windows ที่พบบนคอมพิวเตอร์เข้า BCD Bootloader

หลังจากนั้น Restart Computer และตรวจสอบว่า Windows บูทปกติหรือไม่ หาก OS ไม่บูท ทำตามคำแนะนำด้านล่าง

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

วิธีสร้าง Windows Boot Configuration (BCD) ใหม่จากศูนย์

ต่อไปใช้คำสั่ง BCDedit สร้าง Boot Configuration Data File ใหม่ (สมมติว่าไม่มี BCD Backup File)

ขั้นตอนต่อไปขึ้นอยู่กับว่า Disk มี System Reserved Partition แยกหรือไม่ รันคำสั่ง:

diskpart
list vol

ตรวจสอบว่ามี System Reserved Partition บน Hard Disk หรือไม่ ระบุได้จาก Volume Label หรือแม่นยำกว่าคือ Size (500 MB สำหรับ Windows 10+, 350 MB สำหรับ Windows 8.1, และ 100 MB สำหรับ Windows 7)

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

  • หากไม่มี System Reserved Partition (อาจลบไปโดยไม่ได้ตั้งใจ) สามารถเก็บ Boot Manager Files บน System Drive ที่มี Windows Directory ได้ สร้าง Bootmgr และ BCD Bootloader Configuration Files บน Drive ที่ระบุ: bcdboot C:\Windows /S C: ควรปรากฏข้อความ:
    Boot files successfully created.
  • หากมี System Reserved Partition ลบ BCD File เก่า (เสียหาย) และสร้างใหม่: del c:\boot\bcd

หาก Drive Letter ไม่ได้ Assign ให้ System Reserved Partition (โดย Default) สามารถ Assign เองด้วย diskpart รัน: diskpart

Select Local Disk (ในกรณีมี Hard Disk เดียว แต่ List Local Disks ได้ด้วย list disk): select disk 0

Screenshot ด้านบนแสดงว่า System Reserved Partition ชื่อ Volume 1 Select มัน: select volume 1

Assign Drive Letter (ผม Assign C: แต่ใช้ Letter อื่นได้ ในกรณีนี้เปลี่ยน Path ในคำสั่งถัดไป): assign letter C:

exit

สร้าง Temporary File bcd.tmp ว่าง:

bcdedit /createstore c:\boot\bcd.tmp

สร้าง Entry สำหรับ Windows Boot Manager (bootmgr):

bcdedit.exe /store c:\boot\bcd.tmp /create {bootmgr} /d "Windows Boot Manager"

Import Settings จาก bcd.tmp ไป BCD:
bcdedit.exe /import c:\boot\bcd.tmp

หาก bcdedit คืน Error ระหว่าง Access BCD File (access denied, the store import operation has failed, the required system device cannot be found, the volume does not contain a recognized file system. please make sure that all required file system drivers are loaded and that the volume is not corrupted) ลองลบ Attributes Hidden, Read-only, และ System:

attrib C:\Boot\BCD -s -h -r

ระบุว่า Windows Boot Manager อยู่บน System Reserved Partition (Drive Letter C: Assigned ให้):

bcdedit.exe /set {bootmgr} device partition=c:

ตั้งค่า Timeout เลือก OS:

bcdedit.exe /timeout 10

ลบ Temporary File:
del c:\boot\bcd.tmp

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ตอนนี้สร้าง BCD File ว่างพร้อม Bootloader Settings แล้ว ต้องเพิ่ม Entries เกี่ยวกับ Windows ที่ติดตั้ง

สร้าง Entry ใหม่ใน BCD Configuration สำหรับ Windows 10:

bcdedit.exe /create /d "Windows 10" /application osloader

คำสั่งคืน Unique Identifier (GUID) ของ Bootloader Entry นี้

The entry {8a7f03d0-5338-11e7-b495-c7fffbb9ccfs} was successfully created.

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ระบุว่า bootmgr ควรใช้ Entry นี้เป็น Default (หลัง Timeout จะใช้ Entry นี้ Boot Windows):

bcdedit /default {8a7f03d0-5338-11e7-b495-c7fffbb9ccfs}

ระบุ Path ไปยัง Windows 10 ที่ติดตั้งใน Bootloader Entry ใหม่ ก่อนหน้านี้พบว่า Drive Letter D: Assigned ให้ Windows Partition ใน WinPE ใช้ Drive Letter นี้ในคำสั่งต่อไป:

bcdedit.exe /set {default}device partition=d:
bcdedit.exe /set {default} osdevice partition=d:
bcdedit.exe /set {default} path \Windows\system32\winload.exe
bcdedit.exe /set {default} systemroot \Windows

ทำให้ Boot Entry ใน BCD มองเห็นได้ เนื่องจาก Hidden โดย Default:

bcdedit.exe /displayorder {default} /addlast

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ดังนั้นเราสร้าง Windows 10 Bootloader (bootmgr) และ BCD File ใหม่ทั้งหมด และเขียนทับ MBR Boot Sector แล้ว

ตอนนี้ต้องทำให้ Partition ที่มี bootmgr และ BCD File พร้อม Windows Bootloader Configuration เป็น Active Partition (BIOS ส่ง Control ให้ OS Bootloader บน Active MBR Partition) ตัวอย่าง Partitions ที่มีบนคอมพิวเตอร์:

  • Volume 0 – Installation Flash Drive (ISO Image) ที่ Boot Computer มา
  • Volume 1 – System Reserved Partition (500 MB) พร้อม Windows bootmgr และ \Boot\BCD File
  • Volume 2 – Partition พร้อม Windows System Folders (%Windir%, Program Files, Users, ฯลฯ)

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ในตัวอย่าง ต้องทำให้ Volume 1 เป็น Active Partition (ในกรณีของคุณ ต้องหา Partition Number ของคุณ) ทำ Partition Active ด้วย diskpart:

diskpart
list disk
sel disk 0
list vol
select volume 1
(bootmgr และ \Boot\BCD ต้องอยู่บน Partition นี้)
active
exit

ตรวจสอบว่า Volume 1 Active แล้ว:

select vol 1
detail partition

(Active: Yes )

วิธีซ่อม Windows Boot Manager, BCD และ Master Boot Record (MBR)

ตอนนี้ Restart Computer และตรวจสอบว่า Windows บูทปกติแล้ว