學習嵌入式Linux都需要搭建一個好的嵌入式環境,迅速的搭建好一個嵌入式環境是每個學嵌入式人員必備的,下面介紹了基於ubuntu11.04下的嵌入式環境搭建。
- ubuntu11.04之root登錄
ubuntu默認是普通用戶登錄,每次終端都要切換root用戶,相當的麻煩,直接用root用戶登錄將方便各種操作
在終端下輸入:
sudo passwd root
提示輸入密碼:xxxxxx(root登入用戶密碼)
再次輸入密碼:xxxxxx
重啟後就可以root用戶登錄
- ubuntu之samba伺服器
ubuntu默認沒有安裝samba伺服器,所以要自己安裝,以下都是在root用戶模式下操作:
#apt-get install samba
#apt-get install smbfs
這樣samba伺服器就裝好,我用的是圖像介面來配置samb用戶所以還要裝samba圖像介面
#apt-get install system-config-samba
點擊系統-->系統管理--->samba 就可以添加samb用戶和共用目錄了。
- ubuntu之tftp伺服器
ubuntu默認沒有安裝tftp伺服器,所以要自己安裝,以下都是在root用戶模式下操作:
#apt-get install xinetd
#apt-get install tftpd-hpa
修改tftp默認的共用路徑
#gedit /etc/fault/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/tftp" (這是我的tftp目錄)
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure -c"
#service tftpd-hpa start
在/var/tftp目錄下創建一個zImage檔,在到任意一個目錄下運行
#tftp localhost
tftp>get zImage
tftp>q
#ls
get是從tftp目錄下取檔(相反的是put),如果可以看到zImge檔在當前目錄下,說明tftp就成功了。
- ubuntu之nfs
ubuntu默認沒有安裝nfs伺服器,所以要自己安裝,以下都是在root用戶模式下操作:
#apt-get install nfs-kernel-server
#apt-get install nfs-common
接下來開始配置nfs
#gedit /etc/default/portmap
注釋掉最後一行
#gedit /etc/hosts.deny
加入以下內容
portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
#gedit /etc/hosts.allow
允許的接入的IP,加入以下內容
portmap: 10.168.1.
lockd: 10.168.1.
rquotad: 10.168.1.
mountd: 10.168.1.
statd: 10.168.1.
#gedit /etc/exports
設置NFS掛載目錄及許可權
比如我要將我的home目錄下是arm目錄給10.168.15.*IP段共用,在檔最後加入
/home/nfsdir 10.168.15.*(rw,sync,no_root_squash)
如果覺得安全沒問題,那就允許所以的IP訪問
/home/nfsdir *(rw,sync,no_root_squash)
重啟NFS
#./etc/init.d/portmap restart #./etc/init.d/nfs-common restart #./etc/init.d/nfs-kernel-server restart
測試NFS
#chmod 777 arm
#mount localhost:/home/arm /mnt
#ls mnt
可以看到arm中的相關目錄,測試成功
#umount /mnt
卸載NFS
- ubuntu之vim高亮語法顯示
vi不支援高亮語法顯示,安裝vim
#apt-get install vim
- ubuntu之交叉編譯器
我用的是arm-linux-gcc 4.4.3版本的編譯器,搞arm的你懂的
#tar arm-linux-gcc-4.4.3.tar.gz -C /usr/local/arm/4.4.3
添加環境變數,使編譯器全局可用
#gedit /etc/bash.bashrc
在最後行加入
export PATH=$PATH:/usr/local/arm/4.4.3/bin
#source /root/.bashrc
- ubuntu之make menuconfig錯誤
在用到圖形選項編譯make menuconfig時,會遇到無法載入某庫的錯誤。
在終端輸入:
#apt-get install libncurses5-dev
安裝好庫以後就可以使用make menconfig命令
可能問題;;
解決 ubuntu 掛載 nfs 時出現的錯誤!!
17 Nov
用 ubuntu 掛載 linux nfs server時, 出現下列錯誤 :
# mount fileserver:/disk1/home /home/
mount: wrong fs type, bad option, bad superblock on scorpius:/disk1/home,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog – try
dmesg | tail or so
執行下列指令後, 就可以順利掛載解決
sudo aptitude install nfs-common
Ubuntu 架設nfs server
1. Install
$ sudo apt-get install nfs-common
$ sudo apt-get install nfs-kernel-server
2. 設定 /etc/exports (For example: 將/mnt/iso share給all net使用)
$ sudo vi /etc/exports
/mnt/iso *(ro,sync)
3. 啟動 nfs server
$ sudo /etc/init.d/nfs-kernel-server start
4. 檢查
$ showmount -e localhost
成功的話應該可以看到這樣的訊息:
Export list for localhost:
/mnt/iso *