[OE-core] [PATCH] core-image-minimal-initramfs: prepare initramfs for NFS boot

André Draszik git at andred.net
Tue Apr 3 14:23:41 UTC 2018


Thanks!

On Fri, 2018-03-16 at 20:20 +0200, Oleksii Konoplitskyi wrote:
> Taking into account your recommendations, module should have the next 
> content:
> 
> nfsrootfs_enabled() {
>      [ -z ${bootparam_nfsroot+x} ] && return 1
>      return 0
> }
> 
> nfsrootfs_run() {
>      nfs_mount_point=$(echo $bootparam_nfsroot | cut -d ',' -f 1)
>      nfs_mount_params=$(echo $bootparam_nfsroot | cut -d ',' -f 2)
> 
>      mount -t nfs ${nfs_mount_point} -o nolock,${nfs_server_params} 
> $ROOTFS_DIR
> }

Actually, this is missing various things, according to
linux/Documentation/filesystems/nfs/nfsroot.txt

nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]

* The server-ip is optional (and would be taken from the ip= option in
  that case)
* there can be more than one nfs-option (which is probably more important
  to fix)
* it ignores the 'ro' or rootflags=ro option

Maybe something like this (completely untested):

nfsrootfs_run() {
    local nfs_opts
    local location
    local flags

    nfs_opts=""
    if [ "${bootparam_nfsroot#*,}" != "${bootparam_nfsroot}" ] ; then
        nfs_opts="-o ${bootparam_nfsroot#*,}"
    fi
    location="${bootparam_nfsroot%%,*}"
    if [ "${location#*:}" = "${location}" ]; then
        # server-ip not given
        location=${ROOTSERVER}:${location}
    fi

    flags="-o nolock"
    if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then
        if [  -n "$bootparam_rootflags" ]; then
            bootparam_rootflags="$bootparam_rootflags,"
        fi
        bootparam_rootflags="${bootparam_rootflags}ro"
    fi
    if [ -n "$bootparam_rootflags" ]; then
        flags="$flags -o$bootparam_rootflags"
    fi

    mount -t nfs ${flags} ${nfs_opts} ${location} ${ROOTFS_DIR}
}

? Just need to get at $ROOTSERVER now, or at least issue a warning that it
should be given on the command line.


> What module is responsible for network configuration and network driver 
> loading?

I'd say IP should be separate, as you can then also easily add DHCP or
zeroconf. It's not really related to nfsroot (except for the ROOTSERVER
bit).
Network driver loading should definitely be a machine specific thing...

> Should it be separate custom module in initramfs-framework not related 
> to upstream?
> 
> Best regards,
> Oleksii


Cheers,
Andre'




More information about the Openembedded-core mailing list