How to Set up GRUB to boot from both disks of mirrored RAID

ถ้าในระบบได้มีการใช้งาน software raid ของ linux แบบ raid 1 หรือ mirror raid เวลา boot เครื่อง grub จะอ่านค่าโปรแกรมและ configure จาก hard disk ที่เป็น primary แต่เราสามารถที่จะ configure ให้ grub สามารถอ่านค่าโปรแกรมและ configure จาก secondary hard disk ได้ในกรณีที่ primary hard disk เกิด fail ขึ้น วิธีการนี้อาจจะเรียกว่า การทำ High Available ให้กับ grub บน mirror raid

สมมติว่าในระบบมี hard disk แบบ sata หรือ scsi หรือ SAS 2 ตัว และมี device ชื่อ sda, sdb  และให้ sda เป็น primary hard disk ส่วน sdb เป็น secondary hard disk

วิธีการสามารถทำได้ ตามขั้นตอนข้างล่างนี้

แก้ไขไฟล์ /boot/grub/device.map เพื่อให้ grub เข้าใจว่า sda และ sdb เป็น hard disk ตัวเดียวกัน

# cat /boot/grub/device.map

(hd0) /dev/sda
(hd0) /dev/sdb

ให้เข้าไปยัง grub shell ด้วยคำสั่ง

# grub

เมื่อเข้าสู่ grub shell แล้วให้พิมพ์คำสั่งด้านล่างนี้เพื่อ define ค่า hd0
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd

จากนั้นพิมพ์คำสั่ง ด้านล่างเพื่อติดตั้ง grub ไปที่ sdb

grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 15 sectors are embedded.
succeeded
Running “install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst”… succeeded
Done.

เมื่อเสร็จสิ้นขั้นตอนข้างต้นแล้วให้ออกจาก grub shell ด้วยคำสั่ง quit

grub> quit

Note:

เมื่อแก้ไขเสร็จแล้ว ถ้าลองรัน คำสั่ง grub-install ไปที่ sdb จะไม่สามารถทำได้เพราะว่า grub ไม่อนุญาตให้มี hd0 ได้มากกว่า 1

# grub-install /dev/sdb
The drive (hd0) is defined multiple times in the device map /boot/grub/device.map

Related posts:

  1. Regenerate a GRUB device.map file ไฟล์ device.map มีไว้เพื่อทำการ map harddisk device ไปเป็นชื่อ device...
  2. How to Remove LILO, GRUB or Master Boot Record from system โดยทั่วไป Hard disk จะมีการเก็บ binary code ของ system...
  3. Re-shape or Grow a Raid 5 array. การเพิ่มเนื้อที่ในการทำ Raid Software ของทาง linux นั้นมีการแก้ไขที่ไม่ยากอย่างที่คิด โดยสมมติให้เรามีการทำ Software...
  4. Change I/O Disk Scheduler without Reboot I/O Scheduler สำหรับ Hard disk หรือพวก block device...
  5. Decrease the time for rebuilding the RAID 1 array เมื่อต้องการลดเวลาการ rebuild Raid 1 เราสามารถใช้คำสั่งด้านล่างนี้ได้ครับ #mdadm -C /dev/md0...

You can leave a response, or trackback from your own site.

Leave a Reply