繼PowerPC平台 Linux移植二,實作單闆挂載nfs網絡檔案系統。
1.ubuntu安裝 配置 啟動nfs服務
詳細過程見 http://blog.csdn.net/u010216127/article/details/8825735
=> nfs 0x3000000 10.3.56.9:/home/freescale/work/nfs_root/hello
Speed: 100, full duplex
Using eTSEC2 device
File transfer via NFS from server 10.3.56.9; our IP address is 10.3.56.242
Filename '/home/freescale/work/nfs_root/hello'.
Load address: 0x3000000
Loading: ##T T *** ERROR: Cannot umount
解決方法:
要在主機的/etc/hosts檔案中加入
你的開發闆ip nfs目錄(Ubuntu),eg
10.3.56.242 /home/freescale/work/nfs_root
=> nfs 0x3000000 10.3.56.9:/home/freescale/work/nfs_root/hello
Speed: 100, full duplex
Using eTSEC2 device
File transfer via NFS from server 10.3.56.9; our IP address is 10.3.56.242
Filename '/home/freescale/work/nfs_root/hello'.
Load address: 0x3000000
Loading: ##
done
Bytes transferred = 7920 (1ef0 hex)
=>
2.燒寫uImage dtb
=> setenv ethact eTSEC2
=> tftp 0x1000000 uImage
Speed: 100, full duplex
Using eTSEC2 device
TFTP from server 192.168.2.242; our IP address is 192.168.2.21
Filename 'uImage'.
Load address: 0x1000000
Loading: #################################################################
#################################################################
#################################################################
####
done
Bytes transferred = 2907800 (2c5e98 hex)
=> erase 0xee080000 0xee37ffff
........................ done
Erased 24 sectors
=> cp.b 0x1000000 0xee080000 0x300000
Copy to Flash... 9....8....7....6....5....4....3....2....1....done
=> md 0xee080000
ee080000: 27051956 2899922f 55640aa4 002c5e58 '..V(../Ud...,^X
ee080010: 00000000 00000000 06436151 05070201 .........CaQ....
ee080020: 4c696e75 782d322e 362e3335 00000000 Linux-2.6.35....
燒寫 dtb
=> tftp 0xc00000 p1010rdb.dtb
Speed: 100, full duplex
Using eTSEC2 device
TFTP from server 192.168.2.242; our IP address is 192.168.2.21
Filename 'p1010rdb.dtb'.
Load address: 0xc00000
Loading: #
done
Bytes transferred = 11988 (2ed4 hex)
=> erase 0xee040000 0xee07ffff
.. done
Erased 2 sectors
=> cp.b 0xc00000 0xee040000 0x40000
Copy to Flash... 9....8....7....6....5....4....3....2....1....done
=> md 0xee040000
ee040000: d00dfeed 00002ed4 00000038 00002778 ...........8..'x
ee040010: 00000028 00000011 00000010 00000000 ...(............
ee040020: 0000035c 00002740 00000000 00000000 ...\..'@........
ee040030: 00000000 00000000 00000001 00000000 ................
ee040040: 00000003 0000000a 00000000 66736c2c ............fsl,
ee040050: 50313031 30000000 00000003 0000000d P1010...........
ee040060: 00000006 66736c2c 50313031 30524442 ....fsl,P1010RDB
3.實作nfs挂載檔案系統
setenv nfsargs 'setenv bootargs root=/dev/nfs rw nfsroot=10.3.56.9:/home/freescale/work/source/fs_mini nolock ip=10.3.56.242:10.3.56.9:10.3.57.255:255.255.0.0::eth1:off init=/linuxrc console=ttyS0,115200'
setenv bootcmd 'run nfsargs; bootm 1000000 - c00000'
=> setenv bootargs root=/dev/nfs nfsroot=10.3.56.9:/home/freescale/work/source/fs_mini nolock ip=10.3.56.242:10.3.56.9:10.3.57.255:255.255.0.0::eth1:off init=/linuxrc \
> console=ttyS0,115200
ALSA device list:
No soundcards found.
IPv4 over IPv4 tunneling driver
GRE over IPv4 tunneling driver
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
NET: Registered protocol family 15
turn off boot console udbg0
出現這個halt是因為$consoledev is not set,重新修改參數即可
=> setenv ethact eTSEC2
=> setenv nfsargs 'setenv bootargs root=/dev/nfs nfsroot=10.3.56.9:/home/freescale/work/source/fs_mini nolock ip=10.3.56.242:10.3.56.9:10.3.57.255:255.255.0.0::eth1:off \
> init=/linuxrc console=ttyS0,115200'
=> setenv bootcmd 'run nfsargs; bootm 1000000 - c00000'
=> tftp 0x1000000 uImage
Speed: 100, full duplex
Using eTSEC2 device
TFTP from server 192.168.2.242; our IP address is 192.168.2.21
Filename 'uImage'.
Load address: 0x1000000
Loading: #################################################################
#################################################################
#################################################################
########
done
Bytes transferred = 2969010 (2d4db2 hex)
=> tftp 0xc00000 p1010rdb.dtb
Speed: 100, full duplex
Using eTSEC2 device
TFTP from server 192.168.2.242; our IP address is 192.168.2.21
Filename 'p1010rdb.dtb'.
Load address: 0xc00000
Loading: #
done
Bytes transferred = 11988 (2ed4 hex)
=> setenv ipaddr 10.3.56.242
=> set serverip 10.3.56.9
Unknown command 'set' - try 'help'
=> setenv serverip 10.3.56.9
=> ping $serverip
Speed: 100, full duplex
Using eTSEC2 device
host 10.3.56.9 is alive
=> boot
........
NET: Registered protocol family 17
NET: Registered protocol family 15
eth1: attached PHY driver [Generic PHY] (mii_bus:[email protected]:06, id=4dd074)
IP-Config: Complete:
device=eth1, addr=10.3.56.242, mask=255.255.0.0, gw=10.3.57.255,
host=10.3.56.242, domain=, nis-domain=(none),
bootserver=10.3.56.9, rootserver=10.3.56.9, rootpath=
Looking up port of RPC 100003/2 on 10.3.56.9
Looking up port of RPC 100005/1 on 10.3.56.9
VFS: Mounted root (nfs filesystem) readonly on device 0:15.
devtmpfs: mounted
Freeing unused kernel memory: 212k init
nfs: server 10.3.56.9 not responding, still trying
4.繼續修改檔案系統
原因是挂載系統時改變了開發闆的ip,修改Ip即可。
eth1: attached PHY driver [Generic PHY] (mii_bus:[email protected]:06, id=4dd074)
IP-Config: Complete:
device=eth1, addr=10.3.56.242, mask=255.255.0.0, gw=10.3.57.255,
host=10.3.56.242, domain=, nis-domain=(none),
bootserver=10.3.56.9, rootserver=10.3.56.9, rootpath=
Looking up port of RPC 100003/2 on 10.3.56.9
Looking up port of RPC 100005/1 on 10.3.56.9
VFS: Mounted root (nfs filesystem) readonly on device 0:15.
devtmpfs: mounted
Freeing unused kernel memory: 212k init
can't open /dev/ttySAC0: No such file or directory
can't open /dev/ttySAC0: No such file or directory
can't open /dev/ttySAC0: No such file or directory
can't open /dev/ttySAC0: No such file or directory
can't open /dev/ttySAC0: No such file or directory
can't open /dev/ttySAC0: No such file or directory
5.繼續修改檔案系統
修改inittab檔案
ttyS0::askfirst:-/bin/sh
6.最終成功挂載
eth1: attached PHY driver [Generic PHY] (mii_bus:[email protected]:06, id=4dd074)
IP-Config: Complete:
device=eth1, addr=10.3.56.242, mask=255.255.0.0, gw=10.3.57.255,
host=10.3.56.242, domain=, nis-domain=(none),
bootserver=10.3.56.9, rootserver=10.3.56.9, rootpath=
Looking up port of RPC 100003/2 on 10.3.56.9
Looking up port of RPC 100005/1 on 10.3.56.9
VFS: Mounted root (nfs filesystem) readonly on device 0:15.
devtmpfs: mounted
Freeing unused kernel memory: 212k init
Please press Enter to activate this console.
# ls
bin etc linuxrc proc sbin tmp
dev lib mnt root sys usr
#
7.解決隻讀檔案系統
# mkdir test1
mkdir: cannot create directory 'test1': Read-only file system
# ls
bin etc linuxrc proc sbin test usr
dev lib mnt root sys tmp
# mount
rootfs on / type rootfs (rw)
/dev/root on / type nfs (ro,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=udp,port=65535,timeo=11,retrans=3,sec=sys,mountport=65535,mountproto=,addr=10.3.56.9)
devtmpfs on /dev type devtmpfs (rw,relatime,size=516660k,nr_inodes=129165,mode=755)
proc on /proc type proc (rw,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
然後就是挂載nfs目錄後隻讀不可寫問題了,折騰半天,
後面發現是要求UID,GID與伺服器一緻
于是在伺服器上用id指令一查
# id
uid=0 gid=0
# id
uid=0 gid=0
#
修改/etc/exports 檔案
/home/freescale/work/source/fs_mini *(rw,sync,no_root_squash,anonuid=0,anongid=0)
sudo service nfs-kernel-server restart
setenv nfsargs 'setenv bootargs root=/dev/nfs rw nfsroot=10.3.56.9:/home/freescale/work/source/fs_mini nolock ip=10.3.56.242:10.3.56.9:10.3.57.255:255.255.0.0::eth1:off init=/linuxrc console=ttyS0,115200'
setenv bootcmd 'run nfsargs; bootm 1000000 - c00000'
8.重新挂載nfs檔案系統,讀寫正常
# mkdir test1
# ls
bin etc linuxrc proc sbin test tmp
dev lib mnt root sys test1 usr
# rmdir test1
# ls
bin etc linuxrc proc sbin test usr
dev lib mnt root sys tmp
# ping 10.3.56.9
PING 10.3.56.9 (10.3.56.9): 56 data bytes
64 bytes from 10.3.56.9: seq=0 ttl=64 time=1.042 ms
64 bytes from 10.3.56.9: seq=1 ttl=64 time=0.429 ms
^C
--- 10.3.56.9 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.429/0.735/1.042 ms
#