Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
26.2. 開機進入救援模式
Rescue mode provides the ability to boot a small Red Hat Enterprise Linux environment entirely from CD-ROM, or some other boot method, instead of the system's hard drive.
As the name implies, rescue mode is provided to rescue you from something. During normal operation, your Red Hat Enterprise Linux system uses files located on your system's hard drive to do everything — run programs, store your files, and more.
However, there may be times when you are unable to get Red Hat Enterprise Linux running completely enough to access files on your system's hard drive. Using rescue mode, you can access the files stored on your system's hard drive, even if you cannot actually run Red Hat Enterprise Linux from that hard drive.
從安裝的開機光碟啟動系統。[12]:
- 從安裝的開機光碟啟動系統。
- 從安裝啟動媒體(例如 USB 隨身)碟開機。
- 使用 Red Hat Enterprise Linux CD-ROM #1 啟動系統。
當您使用以上的其中一種方法開機後,請增加
rescue
當作一個核心參數,舉例來說,對於 x86 系統,請在安裝的開機提示符號輸入以下指令:
linux rescue
您將會被提示詢問一些基本的問題,包括要使用那一種語言。也會提示您選擇放置一個有效救援映像檔的位置,請選擇 本機光碟機、硬碟、NFS 映像檔、FTP 或 HTTP。所選取的位置必須包含一個有效的安裝目錄,而且該安裝目錄必須與您所開機之 Red Hat Enterprise Linux 光碟含有相同的 Red Hat Enterprise Linux 版本。如果您使用一片開機光碟或磁碟片來啟動救援模式,安裝目錄必須來自與用來建立該媒體相同的目錄。如需更多關於如何設定在硬碟、NFS 伺服器、FTP 伺服器或 HTTP 伺服器中安裝目錄的更多資訊,請參照本手冊前面的章節。
如果您選取一個不需要網路連線的救援映像檔,您仍會被訊問是否要建立一個網路連線。網路連線適用於需要備份檔案到另一部電腦會從一個共享的網路位置安裝某些 RPM 套件時。
顯示下列訊息:
The rescue environment will now attempt to find your Linux installation and mount it under the directory /mnt/sysimage. You can then make any changes required to your system. If you want to proceed with this step choose 'Continue'. You can also choose to mount your file systems read-only instead of read-write by choosing 'Read-only'. If for some reason this process fails you can choose 'Skip' and this step will be skipped and you will go directly to a command shell.
如果您選取 繼續,它將會試著掛載您的檔案系統到
/mnt/sysimage/
目錄下,如果無法掛載該分割區,系統將會提示您。如果您選取 唯讀,系統將會試著以僅能讀取的模式掛載檔案系統到 /mnt/sysimage/
目錄下。如果您選取 略過,您的檔案系統將不會被掛載,如果您認為您的檔案系統已經毀損了,請選擇 略過。
當您進入救援模式後,在虛擬主控台 1 與 2 會出現一個提示符號(使用 Ctrl-Alt-F1 按鍵組合來進入虛擬主控台 1,而使用 Ctrl-Alt-F2 來進入虛擬主控台 2):
sh-3.00b#
如果您選擇 繼續 來自動掛載您的分割區,而且成功掛載,您即會進入單機使用者模式。
即使您的檔案系統已經被掛載了,救援模式中的預設根目錄分割區只是暫時的根目錄分割區,而不是正常使用者模式(執行層級 3 或 5)檔案系統所使用的根目錄分割區。如果您選擇要掛載您的檔案系統,而且掛載順利,您可以更改救援模式環境的根目錄分割區為您檔案系統的根目錄分割區,請使用下列指令:
chroot /mnt/sysimage
這個方法適用於您需要執行例如
rpm
指令時(需要您的根目錄分割區掛載為 /
)。如要離開 chroot
的環境,請輸入 exit
,您則會回到提示符號。
如果您選擇 略過,您仍然可以在救援模式中試著手動掛載分割區或 LVM2 邏輯空間,您只要建立一個例如
/foo
的目錄,然後輸入以下指令:
mount -t ext3 /dev/mapper/VolGroup00-LogVol02 /foo
在以上的指令中,
/foo
是您剛建立的目錄,而 /dev/mapper/VolGroup00-LogVol02
為您想要掛載的 LVM 邏輯空間。如果該分割區類型為 ext2
,請以 ext2
取代 ext3
。
如果您不知道實體分割區的名稱,請使用下列指令來將它們列出:
fdisk -l
如果您不知道 LVM 實體空間的、空間群組或邏輯空間的名稱,請使用下列指令來將它們列出:
pvdisplay
vgdisplay
lvdisplay
在提示符號下,您可以執行許多有用的指令,如:
ssh
,scp
與ping
:測試網路是否已啟動dump
與restore
:適用於擁有磁帶機的使用者parted
與fdisk
:用來管理分割區rpm
:用來安裝或升級軟體joe
來編輯設定檔注意
如果您試著啟動其它受歡迎的編輯器,例如emacs
、pico
或vi
,將會啟動joe
編輯器。
26.2.1. 重新安裝開機管理程式
在許多情況下,GRUB 會被其它作業程式錯誤刪除、破壞或替代。
下列步驟為將 GRUB 重新安裝於主開機紀錄的程序:
- 從安裝開機媒體啟動系統。
- 在開機提示符號下輸入
linux rescue
以進入救援環境。 - 請輸入
chroot /mnt/sysimage
以掛載 root 分割區。 - 在
/dev/hda
為開機分割機的情況下,輸入/sbin/grub-install /dev/hda
重新安裝 GRUM 開機管理程式。 /boot/grub/grub.conf
檔案,瀏覽其它 GRUB 控制其它作業系統所需的檔案。- 重新啟動系統。
[12]
如要建立安裝的開機光碟,請參照本使用手冊前給章中的指示。