根文件系统挂载

一、nfs方式

1、配置内核,make menuconfig

网络部分,主要是使能CONFIG_IP_PNP以在2中能够看到Root file system on NFS选项
Networking support

    Networking options

        TCP/IP networking

            IP: kernel level autoconfiguration

                 [*] IP: DHCP support

                 [*] IP: BOOTP support
                    
配置开启nfs服务
File systems  --->

    Network File Systems  --->

         <*> NFS client support

        [*] NFS client support for NFS version 3

        [*] NFS client support for the NFSv3 ACL protocol extension

        [*] NFS client support for NFS version 4 (EXPERIMENTAL) 

        [*] NFS client support for NFSv4.1 (DEVELOPER ONLY) 

        [*] Root file system on NFS  

2.配置nfs服务器挂载目录

/home/lsm/workspace/x210/rootfs/rootfs *(rw,sync,no_subtree_check,no_root_squash)

3.向rootfs目录中写入一个普通文件linuxrc进行测试

touch linuxrc

4.在uboot中设置启动参数(IP根据实际使用更改)

set bootargs 'root=/dev/nfs nfsroot=192.168.0.63:/home/lsm/workspace/x210/rootfs/rootfs ip=192.168.0.88:192.168.0.63:192.168.0.1:255.255.255.0::eth0:off  init=/linuxrc console=ttySAC2,115200' 

重启开发板能够看到挂载成功,执行/linuxrc失败。

二、镜像方式

mke2fs是一个应用程序,在ubuntu中默认是安装了的。这个应用程序就是用来制作ext2、ext3、ext4等格式的根文件系统的。一般用来制作各种不同格式的rootfs的应用程序的名字都很相似,类似于mkfs.xxx(譬如用来制作ext2格式的rootfs的工具叫mkfs.ext2、用来制作jffs2格式的rootfs的工具就叫mkfs.jffs2)。

1.创建rootfs.ext2文件

dd if=/dev/zero of=rootfs.ext2 bs=1024 count=2048

losetup  /dev/loop1 rootfs.ext2

mke2fs -m 0 /dev/loop1 2048

2.将之挂载到它一个目录下方便访问

mount -t ext2 /dev/loop1 /home/lsm/workspace/x210/rootfs/rootfs

3.向rootfs目录中写入一个普通文件linuxrc进行测试

touch linuxrc

4.卸载

umount /dev/loop1

losetup -d /dev/loop1

5.使用fastboot将制作好的rootfs.ext2烧录到开发板。重启开发板能够看到挂载成功,执行/linuxrc失败。

猜你喜欢

转载自blog.csdn.net/lushoumin/article/details/85595564