2011年3月15日 星期二

使用PXE開機 (for soekris)

前言:
因為soekris net4521沒有os 而且不能外接螢幕、鍵盤、滑鼠、USB、光碟機
要裝linux很麻煩 只有CF卡和網路開機可以用

雖然說有想過直接拿CF卡在桌電上安裝fedora 可是拿去soekris會無法開機
(可以看到開機選單 可是在loading image的時候就會重開機)

雖然可以直接用dd把openwrt的東西複製到CF卡上 可是他沒有gcc, make
想到cross compile就會暈倒 orz....

最簡單的方式就是直接讓soekris可以跑gcc, make
如果可以在他上面裝一般常見的linux系統 應該就沒問題 (ex:Fedora)

所以說 繞了一堆路 最後還是繞回PXE安裝 QQ

我的PXE server是fedora 不過也可以利用它來安裝其他作業系統

================================================================
ref: http://docs.fedoraproject.org/en-US/Fedora/7/html/Installation_Guide/ap-pxe-server.html

先在fedora上裝這些東西:
yum install tftp-server dhcp syslinux

基本上大部分的設定都是參考他的 不過這邊還是重貼一下 順便當備份 XD

dhcp設定 (本機fedora server的IP為192.168.1.10)
--------------------------------------------------
vi /etc/dhcpd.conf

allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;

subnet 192.168.1.0 netmask 255.255.255.0
{
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
range dynamic-bootp 192.168.1.200 192.168.1.240;
next-server 192.168.1.10;
filename "pxelinux.0";
}

--------------------------------------------------
我在/tftproot裡面建立很多資料夾 有fc7, rh9, debian, ubuntu
這四個資料夾分別都放他們自己的PXE image (不過debian我弄不出來 QQ)

如果你想使用某一個系統的PXE安裝 就去改選單設定就好
(/tftproot/pxelinux.cfg/default)
--------------------------------------------------
這是fedora的設定

SERIAL 0 19200 0
PROMPT 1
DEFAULT cf
TIMEOUT 40

label cf
kernel linux
append initrd=fc7/initrd console=ttyS0,19200n81
\ root=/dev/nfs nfsroot=192.168.1.10:/bunlab/fc7
\ ip=dhcp panic=10 ramdisk_size=16384 rw


--------------------------------------------------
這是redhat9的設定

(其實跟上面幾乎一樣 XD)

--------------------------------------------------
http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/netboot.tar.gz

這是ubuntu的設定(vi pxelinux.cfg/default)

console 0
serial 0 19200 0x000
include ubuntu/ubuntu-installer/i386/boot-screens/menu.cfg
default ubuntu/ubuntu-installer/i386/boot-screens/vesamenu.c32
prompt 0
timeout 0

default install
label install
menu label ^Install
kernel ubuntu/ubuntu-installer/i386/linux
append initrd=ubuntu/ubuntu-installer/i386/initrd.gz -- console=ttyS0,1920000 earlyprint=serial,ttyS0,19200
--------------------------------------------------

基本上 只要路徑沒問題 應該就可以開機了

只是問題變成 開機後你能不能看到畫面&能不能安裝 囧....

1.
像我安裝Fedora 7時 它一開始就說記憶體太小 無法安裝 然後就重開機了 囧

2.
改成redhat 9 安裝畫面到最後一步才說這個電腦的架構沒在支援清單中 然後就重開機
(為什麼不早點說 QQ 害我花一堆時間在勾套件)

3.
改用debian 可是載入image之後他就沒有畫面了 哭哭

4.
換成ubuntu 看起來似乎是可以安裝...
(安裝中 還沒裝完 所以我也不知道能不能用 orz)

2011年3月13日 星期日

更新openwrt的ipkg站台 (kamikaze 7.09)

vi /etc/ipkg.conf

src release http://downloads.openwrt.org/kamikaze/7.09/x86-2.6/packages
#src packages http://downloads.openwrt.org/kamikaze/packages/i386
src packeges http://downloads.openwrt.org/kamikaze/7.09/packages/i386
dest root /
dest ram /tmp

2011年3月10日 星期四

修改ssh port (for openwrt)

try了很久 也改了很多檔案 我也不確定哪些才是必備的
反正就統統記下來 XDD


1. 編輯/etc/config/dropbear
把port 22 改成你要的 (以下用port 5566代替)

2. 編輯/etc/init.d/dropbear
然後把 start() 裡面的 /usr/sbin/dropbear $DROPBEAR_ARGS
移到config_cb() 裡面的 DROPBEAR_ARGS="${nopasswd:+-s }${port:+-p $port}" 的後面

(我也不知道為啥 在討論區看到的)
ref: https://forum.openwrt.org/viewtopic.php?id=11957

3. 編輯/etc/config/firewall
新增 accept:proto=tcp dport=5566

4. 編輯 /etc/firewall.user
iptables -t nat -A prerouting_wan -p tcp --dport 5566 -j ACCEPT
iptables -A input_wan -p tcp --dport 5566 -j ACCEPT



弄完之後 dropbear和firewall都要重新啟動 (重開機也可以 XD)

這樣應該就可以用ssh連到5566 port

----

要使用ssh遠端前,記得先設定密碼,不然就無法登入

打passwd就可設定密碼了

而且openwrt開機時還是會自動登入,不需要另外打密碼 XD

設定固定IP

編輯/etc/config/network

然後新增這個:

config interface wan
option ifname eth1
option proto static
option ipaddr 192.168.2.xx
option netmask 255.255.255.0
option gateway 192.168.2.1
option dns 8.8.8.8

ref
http://wiki.openwrt.org/doc/uci/network#protocol.static

--

沒重開機測試 應該是可以 XD

用find搜尋檔案

find 搜尋目錄 -name 檔名

ex:
find / -name eth1


ref:
超強的鳥哥 XD
http://linux.vbird.org/linux_basic/0220filemanager.php#find

--

平常都是習慣用locate找檔案 find一直記不起來 QQ

net4521上網

承上篇 一樣是使用openwrt-x86-2.6-ext2.image

開完機之後 要按個enter 才會跳出打指令的畫面 XD

這個時候把網路線接在eth1
然後再打udhcpc -i eth1

就可以自動取得ip了!!!!!!!!!!!

--

超感動 原來是這麼簡單的步驟 QQ

2011年3月9日 星期三

接上usb裝置的錯誤訊息

接上usb裝置時 打fdisk -l都找不到sdb

於是用dmesg 會看到下列這些錯誤訊息

usb 1-2: new full speed USB device using uhci_hcd and address 8
usb 1-2: device descriptor read/64, error -71
usb 1-2: device descriptor read/64, error -71
usb 1-2: new full speed USB device using uhci_hcd and address 9
usb 1-2: device descriptor read/64, error -71
usb 1-2: device descriptor read/64, error -71
usb 1-2: new full speed USB device using uhci_hcd and address 10
usb 1-2: device not accepting address 10, error -71
usb 1-2: new full speed USB device using uhci_hcd and address 11
usb 1-2: device not accepting address 11, error -71


這個時候打rmmod ehci_hcd
再重新連接usb裝置 過一陣子就可以抓到了
打fdisk -l可以看到sdb

--

我忘記我在哪裡看到的 囧.....

使用atheros晶片組的網路卡

剛剛發現madwifi官網有這個東西
(太晚看到了 不然之前可以直接在這邊查詢 QQ)

http://madwifi-project.org/wiki/Compatibility

不過madwifi似乎不支援USB的樣子 囧.....

本來還打算買個usb網卡來試試 ~"~

2011年3月5日 星期六

在cmd使用系統管理員權限執行指令

(好長的標題 XD)

在電腦教室的時候 大部分都是使用一般user權限登入
如果這個時候想要系統管理員權限執行一些指令 可以使用runas這個指令

ex: 使用net user這個指令可以幫使用者變更密碼
net user USERNAME PASSWORD

可是一般user不能改別人(系統管理員)的密碼
這個時候用runas就可以了

runas /user:administrator "net user USERNAME PASSWORD"

輸入這個指令之後 就要輸入administrator的密碼 然後就可以了!!

--
不用另外登出再用管理員登入 XD
--

有些安裝程式可以在上面按右鍵選"執行身份"就可以使用系統管理員權限安裝

指令的話就可以用runas

2011年3月3日 星期四

把man所顯示的結果存下來

存成純文字:
man xxx | col -b > xxx.txt

存成html:
man2html /usr/local/share/man/man5/xxx > xxx.html

存成html比較麻煩 因為你要去找出那個manual的位置在哪裡才可以

--

詳情可以用man man來搜尋 XDDDD