在系統啟動首部曲文章中, Extlinux 系統啟動器, 會根據 extlinux.conf 設定檔, 將指定的 Kernel image 及 Initial RAM disk 載入到記憶體中, 然後將執行權交由它們處理, 在系統啟動後的第二個階段, 會去啟動 Initial RAM disk 中的 init 程式來帶動第二階段所有程式的執行, 程序如下 :
[BootLoader -> bzImage -> ???core.gz] -> init -> inittab -> init.d/rcS -> tc-config -> ( dhcp.sh & tce-setup & restore.sh & bootsync.sh -> bootlocal.sh) -> init -> /root/.profile
啟動執行 /root/.bashrc 程式
在上述的啟動流程中, 並沒有去執行 /root/.bashrc 這程式, 解決方法就是在 /root/.profile 程式中加入 "source /root/.bashrc" 這行程式, 製作步驟如下 :
1.解開 initial RAM disk 檔 (microcore.gz)
$ mkdir /mnt/hda1/rd
$ cd /mnt/hda1/rd
$ zcat /mnt/hda1/boot/microcore.gz | sudo cpio -i -H newc -d
2. 列出目錄結構
$ ls -al
total 4
drwxr-xr-x 16 root root 340 Aug 16 22:52 .
drwxrwxrwt 5 root root 120 Aug 16 22:52 ..
drwxr-xr-x 2 root root 1380 Aug 16 22:52 bin
drwxr-xr-x 7 root root 2560 Aug 16 22:52 dev
drwxr-xr-x 8 root root 660 Aug 16 22:52 etc
drwxr-xr-x 3 root root 60 Aug 16 22:52 home
-rwxr-xr-x 1 root root 369 Aug 16 22:52 init
drwxr-xr-x 4 root root 840 Aug 16 22:52 lib
drwxr-xr-x 2 root root 40 Aug 16 22:52 mnt
drwxrwsr-x 2 root staff 180 Aug 16 22:52 opt
drwxr-xr-x 2 root root 40 Aug 16 22:52 proc
drwxr-xr-x 2 root root 80 Aug 16 22:52 root
drwxr-xr-x 2 root root 1080 Aug 16 22:52 sbin
drwxr-xr-x 2 root root 40 Aug 16 22:52 sys
drwxrwxrwt 2 root root 80 Aug 16 22:52 tmp
drwxr-xr-x 7 root root 140 Aug 16 22:52 usr
drwxr-xr-x 7 root root 160 Aug 16 22:52 var
3.編輯 /mnt/hda1/rd/root/.profile
$ nano root/.profile
:
source /root/.bashrc
4.產生 /mnt/hda1/rd/root/.bashrc
$ nano root/.bashrc
#!/bin/bash
source /usr/local/etc/bashrc
alias ping='ping -c 4'
alias bye='filetool.sh -b;sudo poweroff'
alias reboot='filetool.sh -b;sudo reboot'
alias nano='nano -w'
PS1='\u@\h:\w# '
if [ -z "$SSH_TTY" ]; then
setterm -blank 0 &>/dev/null
fi
5. 重製 initial RAM disk 檔 (microcore.gz)
$ sudo find | sudo cpio -o -H newc | gzip -2 > ../microcore.gz
6. 複製 microcore.gz 至啟動目錄
$ cp ../microcore.gz ../boot/
7. 重新開機
$ sudo reboot
8.自動登入後, 檢視 alias 命令
$ alias
alias bye='filetool.sh -b;sudo poweroff'
alias cp='cp -i'
alias df='df -h'
alias du='du -h'
alias la='ls -la'
alias ll='ls -l'
alias ls='ls -p'
alias mv='mv -i'
alias nano='nano -w'
alias ping='ping -c 4'
alias reboot='filetool.sh -b;sudo reboot'
alias rm='rm -i'
沒有留言:
張貼留言