2012年3月24日 星期六

[Linux][Ubuntu][Kernel Local Version 比較]

試了兩種方法

http://zqpmmemo.blogspot.com/2012/03/linuxubuntukernel-local-name.html
http://zqpmmemo.blogspot.com/2012/03/linuxubuntuerror-message-after.html

一個是用 make-kpkg 的 --append-to-version。

一種是修改 kernel 裡的 Local Version,且在 compile kernel 的過程中,修改 debian/control 這檔案裡的資訊使兩者一致。

兩者都能達到同樣的結果,不過就手續上而言的確後者比較麻煩一些。

[Linux][Ubuntu][Kernel Local Name]

因為直接改 Kernel 裡的 Local Name 需要一些方法才能正確的編譯。

所以乾脆直接利用 make-kpkg 的 flag 來改比較方便,就是「--append-to-version」。

指令如下:

sudo fakeroot make-kpkg --initrd --append-to-version=-zqpm kernel_image kernel_headers

編出來的檔案在我這邊的情形是

linux-headers-3.1.10-zqpm_3.1.10-zqpm-10.00.Custom_amd64.deb
linux-image-3.1.10-zqpm_3.1.10-zqpm-10.00.Custom_amd64.deb

安裝好後在 grub.cfg 呈現的樣子是

menuentry 'Ubuntu, with Linux 3.1.10-zqpm' --class ubuntu --class gnu-linux --class gnu --class os

理論上來說,重開機後選它登入後 uname -a 顯示類似

Linux 3.1.10-zqpm

[Linux][Ubuntu][Error Message After Compiling]

在 make menuconfig 後於 local version 填入了 zqpm,但在 compile 之後會出現類似

"dpkg-gencontrol: error: package linux-image-3.1.10zqpm not in control info"

這樣的 error message。

原因是在 kernel 資料夾底下 debian/control 這檔案裡的資料與 target file 不符合。

比較直接的解決方法是進行

http://zqpmmemo.blogspot.com/2012/03/linuxubuntucompile-new-kernel.html

的第五步,sudo make-kpkg clean

然後再一次進行第六步。

第六步 Enter 按下去執行指令後立刻開另一個 Terminal。

修改 debian/control 這個檔案。

把開頭為 linux-source、linux-image、linux-header 的字串都加上自己 local version 設定的字串。

以我的狀況就是

linux-source-3.1.10 -> linux-source-3.1.10zqpm
linux-image-3.1.10 -> linux-image-3.1.10zqpm
linux-headers-3.1.10 -> linux-headers-3.1.10zqpm

阿,linux-image-3.1.10-dbg 不用改。

改好後存檔,另一邊的 compile 就讓它自己繼續跑下去吧~

大概這樣子就不會出現 error 了。

方法我自己有試過了,也順利編出在下一步需要用的兩個 .deb 檔了。

不過非人工的作法我還沒找到,似乎跟 make-kpkg 有關。

Reference:
http://ubuntuforums.org/showpost.php?p=9638461&postcount=1488

2012年3月21日 星期三

[Linux][Latex][右上角的 (R) 或是 TM]

ABC 後加上 \textsuperscript{\texttrademark} 這樣會在 ABC 的右上角出現代表商標的 TM。

將 \texttrademark 改成 \textregistered 則會在右上角出現代表註冊的圈圈內的 R。

2012年3月20日 星期二

[Linux][Ubuntu][調整單一 Terminal 內字體的大小]

剛剛無意間試出來的。

在一個 Terminal 下,按 「Ctrl」 + 「-」 可以縮小該 Terminal 的字體。

不過那個 <-> 是在英文字母區塊的那個 「-」,上頭的注音符號是ㄦ。

按數字鍵的不會作用。

而要放大該 Terminal 的字體,就是按 「Ctrl」 + 「Shift」 + 「=」。

說到底,「Shift」 + 「=」 也就等於是 「+」 了。

不過在這邊為了能清楚知道按鍵要怎麼按,所以還是採用比較麻煩的敘說方式。

同樣的,按數字區的 「+」 並不會作用。

2012年3月15日 星期四

[Linux][Ubuntu][Compile a New Kernel]

此處以 3.0.24 做範例,我的 Ubuntu 版本是 10.04。

裡邊有些所需要的 package 自行安裝,反正系統會提醒的。

============================================================

從 http://www.kernel.org/ 下載 linux-3.0.24.tar.bz2 到 /usr/src。

1) sudo tar zxvf linux-3.0.24.tar.bz2

2) sudo cd linux-3.0.24

3) sudo make menuconfig
(有出現錯誤的話看這裡:
http://zqpmmemo.blogspot.com/2012/02/linuxubuntumake-menuconfig-requires.html)

4) 挑選自己想要編的項目,可以以核心 (*) 的型式或是模組 (M) 的型式,完成後退出並儲存 configure。
(會有個 .config 檔產生在同目錄下)

5) sudo make-kpkg clean
(optional)
(沒有 make-kpkg 的話就 sudo apt-get install kernel-package 吧!)

6) sudo fakeroot make-kpkg --initrd --revision=3.0.24 kernel_image kernel_headers
(其實 = 後面可以加上自己想要的編號或文字,只是我習慣直接寫上版本號)
(不過就是會產生等下有點有趣的狀況就是了)
(這個時間會有點長)

7) cd ../
(會產生兩個開頭為 linux- 的 .deb 檔案)
(以我為例的話是 linux-headers-3.0.22_3.0.22_amd64.deb 和 linux-image-3.0.22_3.0.22_amd64.deb)

8) sudo dpkg -i linux-*.deb

9) sudo vi /boot/grub/grub.cfg
(雖然理論上步驟八就會自動幫忙寫入,不過還是自己檢查一下吧)

10) sudo reboot
(沒問題的話就可以 reboot 選自己剛編好的 kernel 開機囉)

Reference:
http://blog.xuite.net/robert1030tw/blog/19639294-Debian%2FUbuntu+%E7%B7%A8%E8%AD%AF%E6%A0%B8%E5%BF%83

[Linux][Ubuntu][Change NIC Priority via Metric Value]

說實在的不算是設定 priority,只是算讓系統知道說這條路比較好而已。

所以送封包出去時會優先走這條路。

情況是這樣的,我有兩張網卡,兩張各有各的 IP,兩張都可以連線到外邊。

但我想要以 eth0 作為主要連出去的對象。

所以我改了 /etc/network/interfaces 裡 eth0 跟 eth1 的 metric 值。

直接在 eth0 跟 eth1 網路設定中加上「metric 」就好了。

範例如下:

auto eth0
iface eth0 inet static
address 192.168.77.88
netmask 255.255.255.0
gateway 192.168.77.254
metric 1

metric 的值愈小代表路徑愈佳,而我 eth1 的 metric 是設 9999。(印象中是極限了)

所以之後封包船送都會以 eth0 為優先。

2012年3月12日 星期一

[Linux][Ubuntu][Update GCC Version]

偶爾會碰到一些 GCC 4.6 版本的要求,雖然用舊有的 4.4.3 也可以做。

不過這次就趁勢升級一下好了。

由 sudo apt-get install 並沒辦法升級,所以要先

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.6
sudo apt-get install g++-4.6

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20

這兩道指令最後的「20」應該是 priority,但為什麼給定 20,目前還不清楚。

當 update-alternatives 的選擇是設定為 auto 時,會去看 priority 的值,值越大越優先。

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

最後這兩道指令都會出現「There is only one alternative in link group gcc: /usr/bin/gcc-4.6」。

所以應該是可打可不打吧。

所有指令完成後就可以發現自己的「gcc --version」和「g++ --version」顯示出「現在最新」的 4.6.2 囉。

Reference:
http://superuser.com/questions/310809/how-can-i-update-gcc-to-the-latest-version-in-ubuntu-10-04

2012年3月11日 星期日

[Linux][Ubuntu][Skype P2P connection failed]

本來還想說是不是上游端有設備擋住了。

後來嘗試著把 ~/.Skype/shared.xml 砍掉再重新啟動 Skype。

就可以順利連線了,真是奇也怪哉。

Reference:
http://askubuntu.com/questions/18537/how-can-i-fix-the-login-error-p2p-connect-failed-on-skype