What is Grub 2


کانفیگ و تنظیمات Grub 2 و تفاوت های آن با Grub 1 :

  • he GRUB2 system changes the configuration filename to grub.cfg, and it stores it in the /boot/grub/ folder. (This allows you to have both GRUB Legacy and GRUB2 installed at the same time.)
  • instead of the title command, GRUB uses the menuentry command
    • menuentry "CentOS Linux" {
      set root=(hd1,1)
      linux /boot/vmlinuz
      initrd /initrd
      }
      menuentry "Windows" {
      set root=(hd0,1)
      }
  • در فایل کانفیگ خیلی تغییرات و آپشن های جدید نسبت به ورژن قبل اضافه شده است که برای امتحان LPIC 2 اصلا نیازی نیست که به همه این موارد مسلط باشیم.
  • در مثال بالا به خط دو توجه کنید که قبل از root از واژه set استفاده شده است ( تفاوت با ورژن 1 )
  • GRUB2 changes the numbering system for partitions. While it still uses 0 for the first hard drive, the first partition is set to 1
  • در صورتی که در ورژن 1 می تونستیم هارد 0 و پارتیشن 0 داشته باشیم ( پارتیشن 0 همان اولین پارتیشن است )
  • Also, notice that the rootnoverify and kernel commands are not used in GRUB2.
  • and you define the kernel location using the linux command.
  • همان طور که در خط بالا گفته شد؛ جهت مشخص کردن آدرس کرنل لینوکس از عبارت linux به جای root استفاده می کنیم. ( تفاوت با ورژن 1 )
  • GRUB2 uses the /boot/grub/grub.cfg file as the configuration file, you should never modify that file.
  • there are separate configuration files stored in the /etc/grub.d folder. This allows you (or the system) to create individual configuration files for each boot option installed on your system (for example, one configuration file for booting Linux and another for booting Windows).
  • For global commands, use the /etc/default/grub configuration file
  • توجه داشته باشید که دو نوع کانفیگ داریم؛ یکی کانفیگ های عمومی و دیگر سیستمی ( مربوط به سیستم عامل )
  • The format for some of the global commands has changed from the GRUB Legacy commands so it is GRUB_TIMEOUT instead of just timeout.

نصب و راه اندازی Grub 2 :

برای نصب و راه اندازی grub 2 کافیست دستور زیر را اجرا کنیم :

grub-mkconfig > /boot/grub/grub.cfg

با اجرای این دستور سیستم به صورت خودکار سیستم عامل های موجود را شناسایی کرده و فایل کانفیگ گراب را در مسیری که مشخص کردیم ایجاد می کند.


کار در محیط گراب :

وقتی که در صفحه مربوط به گراب هستیم می تونیم با استفاده از کلید E فایل کانفیگ گراب مربوط به آن کرنل یا سیستم عامل را به صورت موقت ( نه همیشکی ) ویرایش کنیم و یا با استفاده از کلید C وارد محیط command line گراب بشویم و تنظیمات مربوطه را به صورت دستی وارد کرده و در نهایت اجرا کنیم ( مثلا مشخص کنیم initrd از کدام مسیر خوانده شود یا نام دقیق کرنل چی باشد و … )