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

Oleksii Konoplitskyi okonopli at cisco.com
Wed Apr 18 09:57:58 UTC 2018


Hi Andre,

I could boot my device using your code (+ parsing nfs server ip address 
from ip option):

nfsrootfs_run() {
     local nfs_opts
     local location
     local flags
     local server_ip

     nfs_opts=""
     if [ "${bootparam_nfsroot#*,}" != "${bootparam_nfsroot}" ]; then
         nfs_opts="-o ${bootparam_nfsroot#*,}"
     fi

     location="${bootparam_nfsroot%%,*}"
     if [ "${location#*:}" = "${location}" ]; then
         # server-ip is not given. Get server ip from ip option
         server_ip=""
         if [ "${bootparam_ip#*:}" != "${bootparam_ip}" ]; then
             server_ip=$(echo "$bootparam_ip" | cut -d: -f2)
         fi

         if [ -z "$server_ip" ]; then
             fatal "Server IP is not set. Update ip or nfsroot options."
         fi
         location=${server_ip}:${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}
}

Should module fail if ip is set to dhcp (or off)?

Should we mount rootfs via nfs if "nfsroot" option is not set?

Best regards,
Oleksii


On 03.04.18 17:23, André Draszik wrote:
> 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