기본 콘텐츠로 건너뛰기

Grub2

source:  https://help.ubuntu.com/community/Grub2#Reinstalling%20from%20LiveCD

GRUB 2 is the default boot loader and manager for Ubuntu since version 9.10 (Karmic Koala). As the computer starts, GRUB 2 either presents a menu and awaits user input or automatically transfers control to an operating system kernel. GRUB 2 is a descendant of GRUB (GRand Unified Bootloader). It has been completely rewritten to provide the user significantly increased flexibility and performance. GRUB 2 is Free Software.
In this guide, GRUB 2 is version 1.98 or later. GRUB legacy (version 0.97) will be referred to as GRUB. To determine your version, use grub-install -v. Grub version 1.99 became the default on Ubuntu 11.04 (Natty Narwhal) and introduced some major changes in the Grub file contents. This guide covers the use of Grub 1.98, the Grub release found in Ubuntu 10.04 LTS (Lucid Lynx). and Grub 1.99, packaged with Ubuntu 12.04 LTS (Precise Pangolin). Content reflecting other versions of Grub 2 will be noted in the appropriate entry.
http://pix.toile-libre.org/upload/original/1353953772.png

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)

GRUB vs GRUB 2

GRUB 2's default menu will look familiar to GRUB users but there are a great number of differences beneath the surface.
  • On a new installation of Ubuntu 9.10 or later with no other installed operating systems, GRUB 2 will boot directly to the login prompt or Desktop. No menu will be displayed.
  • Hold down (right) SHIFT to display the menu during boot. In certain cases, pressing the ESC key may also display the menu.
  • No /boot/grub/menu.lst. It has been replaced by /boot/grub/grub.cfg.
  • There is no "/find boot/grub/stage1" at the grub prompt. Stage 1.5 has been eliminated.
  • The main Grub 2 configuration file, normally located in the /boot/grub folder, is grub.cfg. It is the product of various scripts and should not normally be edited directly.
  • grub.cfg is overwritten by certain Grub 2 package updates, whenever a kernel is added or removed, or when the user runs update-grub.
  • The menu list of available Linux kernels is automatically generated by running update-grub.
  • The user can create a custom file in which the user can place his own menu entries. This file will not be overwritten. By default, a custom file named 40_custom is available for use in the /etc/grub.d folder.
  • The primary configuration file for changing menu display settings is called grub and by default is located in the /etc/default folder.
  • There are multiple files for configuring the menu - /etc/default/grub mentioned above, and all the files in the /etc/grub.d/ directory.
  • Partition numbering has changed. The first partition is now 1 rather than 0. The first device/drive is still hd0 by default (no change). These designations can be altered if necessary in the device.map file in the /boot/grub folder.
  • Automated searches for other operating systems, such as Windows, are accomplished whenever update-grub is executed. Operating systems found will be placed in the Grub 2 menu.
  • Changes made in the configuration files will not take effect until the update-grub command is executed.

Upgrading to GRUB 2 From GRUB

GRUB 2 is the default bootloader for Ubuntu. Users who still have Grub 0.97 installed on their Ubuntu systems can upgrade to GRUB 2 by installing the currently-supported releases of Ubuntu or by enabling repositories which contain the GRUB 2 package grub-pc.
Please visit the Grub2/Upgrading community documentation for more information and instructions.

File Structure

GRUB 2 incorporates a totally revised directory and file hierarchy. The major GRUB 2 folders include /etc/grub.d, which contains the main GRUB 2 scripts, and /boot/grub, which contains the GRUB 2 modules and menu file (grub.cfg). User customizations are normally made to the /etc/default/grub file.
The description of the major GRUB 2 folders and files is located on the Grub2/Setup page.

Configuring GRUB 2

Configuration changes are normally made to the /etc/default/grub file and to the custom scripts located in /etc/grub.d. No changes are made to the GRUB 2 menu until the update-grub command is run as root. This command runs the GRUB 2 configuration scripts and updates the /boot/grub/grub.cfg file.
Descriptions of the GRUB 2 options and how to change them are presented on the Grub2/Setup community documentation page.

Boot Display Behavior

GRUB 2 loads before any operating system. Its modular components are loaded on an as-needed basis. Menu display behavior is generally determined by settings in /etc/default/grub. Review the "Configuring GRUB 2" section for specific entry and formatting guidance.

Initial Default

  • GRUB 2 will boot straight into the default operating system if no other operating system is detected. No menu will be displayed. If another operating system is detected, the GRUB 2 menu will display.

Timed Display

  • The menu is displayed for a predetermined number of seconds. The default entry is highlighted and other selections may be made by the user until the timeout expires. The default timeout is 10 seconds. The timer continues until any key is pressed or the highlighted entry is selected by pressing ENTER. If no user input is made GRUB 2 boots the default entry at the end of the timeout period.
  • Once a key has been pressed the timeout is deactivated and the user must make a selection manually.
  • The default entry is determined by the GRUB_DEFAULT= setting in /etc/default/grub; the first "menuentry" has a value of "0".

Hidden

  • Normal Hidden Operations Enabled:
    • No menu entries are displayed. The splash screen, if configured, will be displayed.
    • The time the screen remains blank but available for display is determined by a setting in /etc/default/grub (GRUB_HIDDEN_TIMEOUT)
    • GRUB 2 can display a countdown timer to provide visual feedback on the time remaining until the default selection is chosen. The timeout setting is enabled in /etc/default/grub (GRUB_HIDDEN_TIMEOUT_QUIET)
    • The user may display the menu by pressing any key.
      • Once the menu displays, the GRUB_TIMEOUT counter begins. Pressing any key stops the countdown.
        • If no key is pressed by the end of the timeout the default entry determined by settings in /etc/default/grub will be selected.
  • Hidden Menu Operations Not Expected (Abnormal):
    • The user may be able to display the menu in one or more of the following ways:
      • Holding down the SHIFT key early in the boot process until the menu displays.
        • GRUB 2 searches for a depressed SHIFT key signal during boot. If the key is pressed or GRUB 2 cannot determine the status of the key, the menu is displayed.
      • Pressing the ESC key during a 3 second window as GRUB 2 runs.

Saved

  • Saving an OS can be achieved by running sudo grub-set-default if GRUB_DEFAULT=saved is set in /etc/default/grub. It may also be saved if GRUB_SAVEDEFAULT=true is also set in /etc/default/grub. In this case, the default OS remains until a new OS is manually selected from the GRUB 2 menu or the grub-set-default command is executed.

Last Boot Failed or Boot into Recovery Mode

If the last boot failed or after a boot into Recovery Mode the menu will be displayed until the user makes a selection. The timeout setting in /etc/default/grub do not apply in this case.
To change this behaviour, edit /etc/grub.d/00_header and change line 236 (this line is in the make_timeout() function) to
set timeout=0
  • For timeout=-1, there will be no countdown and thus the menu will display.
  • For timeout=0, menu will not display even for a failed startup.
  • For timeout>=1, menu will display for the specified number of seconds.
Run update-grub after the change have been made. Special thanks to McCunha on Ubuntu Forums for the above tip.
The above change, however, still causes grub to boot into text graphics mode. Thus, an additional change is required. Edit /etc/grub.d/10_linux and change line 188 to
set linux_gfx_mode=keep
Once again, run update-grub after the change has been made.

Password Protection

GRUB 2 is capable of password-protecting menu editing, access to the GRUB 2 terminal, and specific or all menuentries. It can also limit access to specific entries to specific users, and can encrypt plain-text passwords for increased security. Please refer to the Grub2/Passwords community documentation.

Custom Menu Entries

GRUB 2 allows users to create customized menu selections which will be automatically added to the main menu when sudo update-grub is executed. A 40_custom file is available in /etc/grub.d/ for use or to serve as an example to create other custom menus. Information on building and using custom menus in GRUB 2 is located in the Grub2/CustomMenus community document.

Troubleshooting

GRUB 2 provides excellent capabilities for troubleshooting and correcting boot problems from the boot menu or GRUB 2 terminal. Troubleshooting and recovery procedures detailed in the Grub2/Troubleshooting community document.
Included on the referenced page is a section on Selected_Problems_and_Bugs.

Fixing reboot/shutdown freezes

If your machine freezes upon attempts to shutdown or reboot, try modifying /etc/default/grub. Open the file with gksudo gedit /etc/default/grub (graphical interface) or sudo nano /etc/default/grub (command-line). Any other plaintext editor (Vim, Emacs, Kate, Leafpad) is fine too. Find the line that starts with GRUB_CMDLINE_LINUX_DEFAULT and add reboot=bios to the end. It should result in something like
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash reboot=bios"
if done properly. Then save the file, run sudo update-grub and reboot in any way that's possible for you. After that, reboots and shutdowns should start working properly.
With certain hardware (notably DELL) the kernel parameter that you add needs to be reboot=pci (instead of reboot=bios), the procedure remains the same.

Displays

GRUB 2 can do more than provide a simple black & white menu. Its menu can be customized by the user to present a more visually-appealing menu by changing font colors, backgrounds and resolutions.
For information on using splash images and changing font colors and menu resolutions, please refer to the Grub2/Displays community documentation.
Some people may have old bookmarks leading to this page in which case these links might be useful to them but it's better to link to the sub-pages directly as the sub-sections here are only here temporarily while this main page gets broken-up into digestible sub-pages.

GRUB 2 Splash Images

Set the splash image

Set menu font and highlight colors

Testing Fonts and Splash Images

Changing Resolutions w/ Splash Images

Creating User Splash Images

Resolution Settings

Image Creation and Setup

Themes

GRUB 2 Theming is still under development, as is integration with gfxmenu. Theme elements will include colors, fonts, progress indicators, menus, and labels. Both of these hold great promise but are not ready for release with Ubuntu 9.10. Check the Links section at the bottom of this page for references.
  • grub2.theme.dinxter.png
    grub2.theme.bennett.png

Installing/Reinstalling/Moving GRUB2

Please visit the Grub2/Installing community documentation. Information concerning upgrades from GRUB 0.97 (Legacy) to GRUB 2 is now located at Grub2/Upgrading.

Booting an ISO from a Menuentry

Ubuntu ISOs, as well as many utility ISOs and some other Linux operating systems, can be booted from a hard drive via a GRUB menuentry. This eliminates the need to create a CD/DVD and allows bootable image files to be stored only on the hard drive.
For information on this Grub 2 feature, please visit the Grub2/ISOBoot page.

Security

Preventing booting via Grub command-line

The ability to manually boot using the Grub command-line constitutes the biggest security risk in Linux. Any OS can be booted in this manner from any USB or CD/DVD drive, circumventing BIOS restrictions. Placing passwords or locking menu items (in the Grub configuration files) does not prevent a user from booting manually using commands entered at the grub command-line. (Once a foreign OS is booted, of course, it can be used to access any part of an unencrypted hard drive).
To prevent the command-line usage of Grub and require bootloading from menu options only, there are currently no options.

Miscellaneous

Booting from a serial console

If you want GRUB to operate over a serial line, you will need to uncomment GRUB_TERMINAL in /etc/default/grub and set it to serial (instead of the console default). The default serial console settings are to operate on the first serial port (ttyS0) at a 9600 bit/s transfer rate with 8 data bits, 1 stop bit and no parity.
If you want to use another serial port or if your console uses different settings, you must add a GRUB_SERIAL_COMMAND line to specify additional parameters to the serial command. The serial command in GRUB 2 uses the same syntax as its GRUB Legacy counterpart (documented here). For example, for a very common 9600 bit/s (baud) serial line with 8 data bits, 1 stop bit and no parity:
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
An example is a 4800 bit/s (baud) serial line with 7 data bits, 1 stop bit and even parity:
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=4800 --word=7 --parity=even --stop=1"

Booting FreeBSD, NetBSD, and multiboot OSes

Please refer to the article Grub2OtherOs

Links

External Links

댓글

이 블로그의 인기 게시물

[linux] 뻔하지 않은 파일 퍼미션(file permissions) 끄적임. 정말 속속들이 아니?

1. [특수w]내 명의의 디렉토리라면 제아무리 루트가 만든 파일에 rwxrwxrwx 퍼미션이라 할지라도 맘대로 지울 수 있다. 즉 내 폴더안의 파일은 뭐든 지울 수 있다. 2. [일반rx]하지만 읽기와 쓰기는 other의 권한을 따른다. 3.[일반rwx]단 남의 계정 폴더는 그 폴더의 퍼미션을 따른다. 4.[일반]만약 굳이 sudo로 내 소유로 파일을 넣어놓더라도 달라지는건 없고, 단지 그 폴더의 other퍼미션에 write권한이 있으면 파일을 만들고 삭제할 수 있다. 5.디렉토리의 r권한은 내부의 파일이름 정도만 볼 수있다. 하지만 ls 명령의 경우 소유자, 그룹, 파일크기 등의 정보를 보는 명령어므로 정상적인 실행은 불가능하고, 부분적으로 실행됨. frank@localhost:/export/frankdir$ ls rootdir/ ls: cannot access rootdir/root: 허가 거부 ls: cannot access rootdir/fa: 허가 거부 fa  root #이처럼 속한 파일(폴더)만 딸랑 보여준다. frank@localhost:/export/frankdir$ ls -al rootdir/ # al옵션이 모두 물음표 처리된다.. ls: cannot access rootdir/root: 허가 거부 ls: cannot access rootdir/..: 허가 거부 ls: cannot access rootdir/.: 허가 거부 ls: cannot access rootdir/fa: 허가 거부 합계 0 d????????? ? ? ? ?             ? . d????????? ? ? ? ?             ? .. -????????? ? ? ? ?             ? fa -????????? ? ? ? ?             ? root 하지만 웃긴건, r에는 읽기 기능이 가능하므로 그 폴더 안으로 cd가 되는 x권한이 없더라도 어떤 파일이 있는지 목록 정도는 알 수 있다. 하지만 r이라고

[인코딩] MS949부터 유니코드까지

UHC = Unified Hangul Code = 통합형 한글 코드 = ks_c_5601-1987 이는 MS사가 기존 한글 2,350자밖에 지원하지 않던 KS X 1001이라는 한국 산업 표준 문자세트를 확장해 만든 것으로, 원래 문자세트의 기존 내용은 보존한 상태로 앞뒤에 부족한 부분을 채워넣었다. (따라서 KS X 1001에 대한 하위 호환성을 가짐) 그럼, cp949는 무엇일까? cp949는 본래 코드 페이지(code page)라는 뜻이라 문자세트라 생각하기 십상이지만, 실제로는 인코딩 방식이다. 즉, MS사가 만든 "확장 완성형 한글 ( 공식명칭 ks_c_5601-1987 ) "이라는 문자세트를 인코딩하는 MS사 만의 방식인 셈이다. cp949 인코딩은 표준 인코딩이 아니라, 인터넷 상의 문자 송수신에 사용되지는 않는다. 하지만, "확장 완성형 한글" 자체가 "완성형 한글"에 대한 하위 호환성을 고려해 고안됐듯, cp949는 euc-kr에 대해 (하위) 호환성을 가진다. 즉 cp949는 euc-kr을 포괄한다. 따라서, 윈도우즈에서 작성되어 cp949로 인코딩 되어있는 한글 문서들(txt, jsp 등등)은 사실, euc-kr 인코딩 방식으로 인터넷 전송이 가능하다. 아니, euc-kr로 전송해야만 한다.(UTF-8 인코딩도 있는데 이것은 엄밀히 말해서 한국어 인코딩은 아니고 전세계의 모든 문자들을 한꺼번에 인코딩하는 것이므로 euc-kr이 한국어 문자세트를 인코딩할 수 있는 유일한 방식임은 변하지 않는 사실이다.) 물론 이를 받아보는 사람도 euc-kr로 디코딩을 해야만 문자가 깨지지 않을 것이다. KS X 1001을 인코딩하는 표준 방식은 euc-kr이며 인터넷 상에서 사용 가능하며, 또한 인터넷상에서 문자를 송수신할때만 사용.(로컬하드에 저장하는데 사용하는 인코딩방식으로는 쓰이지 않는 듯하나, *nix계열의 운영체제에서는 LANG을 euc-kr로 설정 가능하기도 한걸

[hooking, 후킹, 훅킹] Hooking이란?

source: http://jinhokwon.blogspot.kr/2013/01/hooking.html Hooking 이란? [출처] http://blog.daum.net/guyya/2444691 훅킹(Hooking)이란 이미 작성되어 있는 코드의 특정 지점을 가로채서 동작 방식에 변화를 주는 일체의 기술 이다. 훅이란 낚시바늘같은 갈고리 모양을 가지는데 여기서는 코드의 중간 부분을 낚아채는 도구라는 뜻으로 사용된다. 대상 코드의 소스를 수정하지 않고 원하는 동작을 하도록 해야 하므로 기술적으로 어렵기도 하고 운영체제의 통상적인 실행 흐름을 조작해야 하므로 때로는 위험하기도 하다. 훅킹을 하는 방법에는 여러 가지가 있는데 과거 도스 시절에 흔히 사용하던 인터럽터 가로채기 기법이나 바로 앞에서 알아본 서브클래싱도 훅킹 기법의 하나라고 할 수 있다. 이외에도 미리 약속된 레지스트리 위치에 훅 DLL의 이름을 적어 주거나 BHO(Browser Helper Object)나 응용 프로그램 고유의 추가 DLL(Add in)을 등록하는 간단한 방법도 있고 PE 파일의 임포트 함수 테이블을 자신의 함수로 변경하기, CreateRemoteThread 함수로 다른 프로세스의 주소 공간에 DLL을 주입(Injection)하는 방법, 메모리의 표준 함수 주소를 덮어 쓰는 꽤 어려운 방법들도 있다. 이런 고급 훅킹 기술은 이 책의 범위를 벗어나므로 여기서는 소개만 하고 다루지는 않기로 한다. 이 절에서 알아볼 메시지 훅은 윈도우로 전달되는 메시지를 가로채는 기법으로 다양한 훅킹 방법중의 하나이다. 메시지 기반의 윈도우즈에서는 운영체제와 응용 프로그램, 또는 응용 프로그램 사이나 응용 프로그램 내부의 컨트롤끼리도 많은 메시지들을 주고 받는다. 훅(Hook)이란 메시지가 목표 윈도우로 전달되기 전에 메시지를 가로채는 특수한 프로시저이다. 오고 가는 메시지를 감시하기 위한 일종의 덫(Trap)인 셈인데 일단 응용 프로그램이 훅 프로시저를 설치하면 메시지가 윈도우로 보내지기