歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> ubuntu中的grub2功能和操作方法詳解

ubuntu中的grub2功能和操作方法詳解

日期:2017/3/1 15:43:22   编辑:關於Linux
ubuntu中的grub2功能和操作方法詳解 各ubuntu版本對應的grub版本號: GRUB 2 Ubuntu since version 9.10 (Karmic Koala) //grub2 從9.10的ubuntu版本開始使用。 Grub version 1.99 Ubuntu 11.04 (Natty Narwhal) 改進 Improvements GRUB 2's major improvements over the original GRUB include: Scripting support including conditional statements and functions Dynamic module loading Rescue mode Custom Menus Themes Graphical boot menu support and improved splash capability Boot LiveCD ISO images directly from hard drive New configuration file structure Non-x86 platform support (such as PowerPC) Universal support for UUIDs (not just Ubuntu) 在ubuntu系統中可以使用如下命令查看grub的版本號: grub-install -v 如果只裝了一個操作系統,即ubuntu。 那麼,默認是不會出現grub的啟動菜單的。 有兩種方法可以進入啟動菜單: 按鍵: 點擊“SHIFT” 或者 “ESC ” ,可以進去grub的啟動菜單。 早期grub版本的配置文件  /boot/grub/menu.lst 在grub2中已經被替換為 /boot/grub/grub.cfg . grub.cfg 會被某些動作更新。 比如,當一個內核被添加或者移除時,或者當哦難怪乎運行 update -grub 命令時。 列出有效linux內核的菜單列表(menu list)是通過運行 update -grub 來自動產生的。 grub.cfg 會更新的時候會被覆蓋,但是在 /etc/grub.d/ 文件夾下有些自定義的配置文件可以使用 如 40_custom 。 $ ls /etc/grub.d/ 00_header 10_linux 20_memtest86+ 40_custom README 05_debian_theme 20_linux_xen 30_os-prober 41_custom 改變菜單顯示設置項的配置文件是: /etc/default/grub [plain] # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1" 分區編號已經改了! 現在第一個分區是 1,而不是 0 。 第一個設備驅動(device/drive)依然默認是 hd0 。如果需要,可以再 /boot/grub 下的 device.map 文件中配置。 當運行 update-grub 命令的時候,grub會自動去找其他的操作系統。 找到之後,相關的操作系統啟動項可以再grub2的 菜單中找到。 對配置文件的任何改變不會立即起作用,必須 運行 update-grub 命令 之後才會生效。 文件結構 ---- File Structure GRUB2改變目錄的結構層次。 GRUB2的文件夾包括: /etc/grub.d ---包括GRUB2的腳本 /boot/grub ---包括GRUB2的模塊和 menu文件(grub.cfg) /etc/default/grub --- 包括用戶自定義配置 配置GRUB2 ---- Configuring GRUB 2 啟動失敗,進入安全模式 設置安全模式下的 啟動菜單超時時間: /etc/grub.d/00_header , 找到 約236行 ,即make_timeout()函數的內容。有如下timeout的變量設置: set timeout=0 For timeout=-1, 沒有倒計時,會直接顯示 啟動菜單 。 For timeout=0, 即便是進入失敗啟動,啟動菜單也不會顯示。 For timeout>=1, 啟動菜單將停住 一定的時間,這個時間就是這個數字所代表的秒數。 改動了之後,一定要 運行 update-grub 命令才生效。 上面的改變之後,grub依然會啟動至 text graphics 模式。因此,可以修改 /etc/grub.d/10_linux (大約第188行)這個文件的內容來達到 相應的目的。 同樣需要 運行 update-grub 命令才生效。
Copyright © Linux教程網 All Rights Reserved