個人心情和 Linux / FreeBSD 等技術

顯示具有 FreeBSD 標籤的文章。 顯示所有文章
顯示具有 FreeBSD 標籤的文章。 顯示所有文章

2011/03/04

升級到 freebsd 8.2 備忘

The freebsd-update(8) utility supports binary upgrades of i386 and amd64 systems running earlier FreeBSD releases. Systems running 7.[01234]-RELEASE, 8.[01]-RELEASE, 8.2-BETA1, or 8.2-RC[123] can upgrade as follows:
# freebsd-update upgrade -r 8.2-RELEASE


During this process, FreeBSD Update may ask the user to help by merging some configuration files or by confirming that the automatically performed merging was done correctly.
# freebsd-update install


The system must be rebooted with the newly installed kernel before continuing.
# shutdown -r now


After rebooting, freebsd-update needs to be run again to install the new userland components:
# freebsd-update install


At this point, users of systems being upgraded from FreeBSD 7.4-RELEASE or earlier will be prompted by freebsd-update to rebuild all third-party applications (e.g., ports installed from the ports tree) due to updates in system libraries.


為了 rebuild  third-party application , 最快的方式就是全部移除掉重來..


免的解一些奇怪的 ports bug , 這邊參考  portmaster


Using portmaster to do a complete reinstallation of all your ports:
1. portmaster --list-origins > ~/installed-port-list
2. Update your ports tree
3. portmaster -ty --clean-distfiles
4. portmaster --check-port-dbdir
5. portmaster -Faf
6. pkg_delete '*'
7. rm -rf /usr/local/lib/compat/pkg
8. Back up any files in /usr/local you wish to save,
such as configuration files in /usr/local/etc
9. Manually check /usr/local and /var/db/pkg
to make sure that they are really empty
10. Re-install portmaster
11. portmaster `cat ~/installed-port-list`




After updating installed third-party applications (and again, only if freebsd-update printed a message indicating that this was necessary), run freebsd-update again so that it can delete the old (no longer used) system libraries:
# freebsd-update install


Finally, reboot into 8.2-RELEASE:
# shutdown -r now


參考: http://www.freebsd.org/releases/8.2R/announce.html 

2009/10/19

Argument list too long

錯誤訊息是


bash: /bin/rm: Argument list too long


今天用 rm -f db-* 遇到這個問題 ...


有點鳥呀


改用 find . -name "db-*" | xargs rm -f 就跑的蠻正常的

2009/08/27

ssh-keygen

這已經在公司用了好久了,不是什麼了不起的應用

來這裡筆記一下吧

詳細的使用看 manpage 第一段就明確的告訴你

ssh-keygen generates, manages and converts authentication keys
for ssh(1). ssh-keygen can create
RSA keys for use by
SSH protocol version 1 and RSA or DSA keys for use by SSH
protocol version 2. The type of key to be generated is specified
with the -t option. If invoked without any arguments, ssh-keygen
will generate an RSA key for use in SSH protocol 2 connections.

預設不自作聰明的帶參數的話會是 SSH protocol 2 可使用的 RSA key。

但是 RSA非對稱式加密 有些歷史因素,個人認為在 1024 bits 以下都很危險..


所以個人還是偏好使用 DSA演算法

廢話不多說來產生 key

rellik@desktop(01:05:08)[~]$
ssh-keygen -t dsa

Generating public/private dsa key pair.
Enter file in which to save the key (/home/rellik/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/rellik/.ssh/id_dsa.
Your public key has been saved in /home/rellik/.ssh/id_dsa.pub.

大概按兩三次 Enter 鍵就結束了

而在工作環境下我的 HOME 目錄又是使用 NFS 掛載到每一台機器上的

這有個好處可以讓我快速的游移在多台機器中不需要打帳號密碼節省了

很多敲鍵盤的時間。

作法是在 $HOME/.ssh 目錄底下建立一個 authorized_keys

然後把 $HOME/.ssh/id_dsa.pub (記得是 public key 呀)貼到

authorized_keys 裡,權限 600 ,這樣就可以利用 nfs 快速的在

機器間遊走了 。

最後忘了說,Debian liked 的系統強烈建議安裝 openssh-blacklist

這個套件 ......, 不清楚的人可參考之前的文章 Debian的openssl漏洞

2007/05/05

The FreeBSD Booting Process

FreeBSD開關機流程

1. Boot Manager :
在MBR或boot manager裡的程式碼通常是指開機流程的 stage 0(第0階段),
底下會討論兩種boot manager: boot0 和 LILO

The boot0 Boot Manager :這個 manager 可在剛安裝 FreeBSD
或以 boot0cfg工具安裝安裝後預設位置在 /boot/boot0 。
(boot0程式非常的簡單輕巧,由於 slice table 和 0x55AA 識別符放置
在MBR結尾處的關係,boot0 只有446bytes大小)。如果你有多個系統,
開機時你將會看到如下列的圖示

Example 12-1. boot0 Screenshot
F1 DOS
F2 FreeBSD
F3 Linux
F4 ??
F5 Drive 1
Default: F2

其他系統,特別是Windows,會將自己的開機loader寫入MBR中,
如果你想用FreeBSDloader蓋寫現存的MBR可以使用下列命令

# fdisk -B -b /boot/boot0 device

如果想以現存的linux loader(LILO)開機,可先開起linux 編輯 /etc/lilo.conf
如下

other=/dev/hdXY (hd是ide硬碟,XY可自己代換成linux上的磁區編號)
table=/dev/hdX
loader=/boot/chain.b (如果兩個系統是在同一個硬碟上可忽略這行)
label=FreeBSD

存檔後執行 /sbin/lilo -v 讓新的變更生效

2. Stage One, /boot/boot1, 和 Stage Two, /boot/boot2
stage1 和 stage2 在概念上屬於同一程式和同一磁碟區域,由於磁區
大小限制,他們被分成了兩個階段,但是安裝時會一起安裝。他們存
在於檔案系統之外,位於開機slice的第一軌,開始於第一個 sector 。

這是 boot0 或是任何其他存放於MBR的程式所要尋找以繼續完成開機
程序的地方。 boot1 也無法超過512bytes,不過這對 FreeBSD disk
label 而言已經足夠。 disklabel 是用來儲存 slice 的相關訊息,並去找
到和執行 boot2 。

boot2 比較高階和精密,boot2 必須要在FreeBSD的檔案系統上找到
檔案,並提供一個介面去選擇 kernel 或 loader 來執行。因 loader
又比 boot2 更高一級,且易於設定,所以 boot2 通常會執行它,
但是通常會直接執行kernel

Example 12-2. boot2 Screenshot

>> FreeBSD/i386 BOOT
Default: 0:ad(0,a)/kernel <--執行kernel
boot:

如果要取代現有的boot1和boot2 可用 bsdlabel工具
# bsdlabel -B diskslice (diskslice是指機器開機的slice,例如ad0s1)

3. Stage Three, /boot/loader
loader 是三步驟中的最後一步,且置於 FreeBSD 的檔案系統之內,
通常是/boot/loader.rc 初始化時,loader 會探測終端機和磁碟,
辨識是從哪個硬碟啟動的。開始設置所要開啟的磁碟、設定變數對
應,並啟動解譯程式開始解釋loader所傳遞的命令

loader 然後會讀取並執行 /boot/loader.rc, 預設地讀取
/boot/defaults/loader.conf
以設定可靠的預設變數,讀取
/boot/loader.conf
對這些變數作區域修改。loader.rc 依據這些
變數進行動作,加載任何被選取的模組和核心。

最後,預設地,loader 會停留 10 秒等待按鍵, 若沒有發生中斷
,就開始啟動核心。如果被中斷,用戶會得到一個指令行輔助說明
符, 在這裡用戶得變更變數、解除裝載所有模組、加載模組、最後
啟動 或重新啟動。

4. kernel interaction During Boot
一但 kernel 經由 loader 或 boot2 (略過執行loader),kernel將會
檢查它的開機旗標 (flag) ,如果有,就開始依照旗標做一些必要調節。

常用開機旗標
-a :在kernel初始化階段,訊問要使用哪一個裝置當root檔案系統。
-C :從光碟機開機
-c :執行userconfig,開機階段的kernel配置檔。
-s :進入單人模式
-v :在kernel啟動時顯示較多訊息

5. Device Hints
在FreeBSD5.0版後才出現在起始系統啟動時,loader 會讀取 device.hints
檔案。這個檔案以變數的形式儲存著核心啟動資訊, 有時被稱為
「 device hints 」。 裝置驅動程式用「 device hints " 對裝置進行配置。

Device hints 也可以在 第三階段的boot loader 的指令行輔助說明符中指定。
變數可以用 set /boot/device.hints 設定的變數亦可以在這裡被覆寫。
鍵入 boot loader 中的變數不是永久性的,在下次啟動時就會被忘記。

指令添加,unset 指令移除, show 指令檢視。在檔案 /boot/device.hints
設定的變數亦可以在這裡被覆寫。寫入 boot loader 中的變數並非永久性的,
在下次啟動時就會被忘記。

一旦系統啟動成功,kenv 指令可以用來清楚所有的變數。
檔案 /boot/device.hints 的語法是一行一個變數, 使用「#」作為註釋記號。
每行是按照如下方式組織的:

hint.driver.unit.keyword="value"

第三階段 boot loader 的語法是:

set hint.driver.unit.keyword=value

driver 是裝置驅動程式名,unit 是裝置驅動程式單位名,keyword 是
hint 關鍵字。

關鍵字可以由以下選項組成:

at:指明裝置所連結的匯流排
port:指明所使用 I/O 的起始位址。
irq:指明所使用的中斷要求號。
drq:指明 DMA channel 號。
maddr:指明裝置使用的物理記憶體位址。
flags:給裝置設定各種旗標。
disabled:如果設成 1, 裝置被禁用。

裝置驅動程式能夠接受更多的 hints,建議參看它們的手冊。參看
device.hints(5)、kenv(1)、loader.conf(5) 和 loader(8) 關機手冊以獲得
更多資訊。

6. Init :進行系統控制權轉移
一旦 kernel 完成載入後, kernel 就將控制權交給使用者層的
命令 init ,位於/sbin/init。或是loader的環境變數 init_path
所指定的位置。

自動reboot啟動程序
這個程序會確認系統將要使用的檔案系統是存在的。如果不在,
則fsck就不能正常的被執行去修復磁碟機,接著init把系統切換
成單人模式,系統管理者就可以在這時候直接處理這個錯誤。

單人模式
要進入這模式可以經由自動 reboot 啟動程序,或是在開機階
段設置 -s 參數,或設定 boot_single 的變數給 loader。或是
在多人模式之下執行 shutdown ,不加上reboot (-r)或halt (-h)
參數也可以進入單人模式。

如果系統主控台 console 在 /etc/ttys 之中是設定成 insecure 的,那麼在進
入單人模式時,系統就會要求輸入 root 的密碼。

*insecure的console代表你決定你的console的安全等級是
insecure 的 ; 而不是代表你的
console是insecure,而是你要
多一點的安全防護,則請選擇insecure,而不是secure



多人模式
如果init無誤的找到了你的檔案系統,或結束了單人模式,系統
就會進入多人模式,並開始資源配置(rc)。

7. 系統資源配置(rc)

資源配置系統會先執行預設的配置檔 /etc/defaults/rc.conf 和系
統詳細配置
/etc/rc.conf。接著依照 /etc/fstab 來掛載檔案系統,
再啟動網路服務、和其他的系統監控程式,最後執行部份程式
的起始script。

8. 關機程序

藉由 shutdown 可以控制系統進行關機, init 將會執行
/etc/rc.shutdown這個script。接著送出終止信號給所有的程序,
在此時如果有無法終止的程序就送出 kill (-9)的信號。

參考資料
http://www.freebsd.org/doc/zh_TW.Big5/books/handbook/boot.html
os.還有忘了再哪看到的中文文件~ = =||