aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initrdscripts/initramfs-framework
diff options
context:
space:
mode:
authorOleksii Konoplitskyi <okonopli@cisco.com>2018-05-25 16:56:48 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-07 11:02:57 +0100
commitd1737f2dabac5e338061863c78a91b4c115365c7 (patch)
tree5a8efb265a5b3a611bd5cb53e78cecacab22543d /meta/recipes-core/initrdscripts/initramfs-framework
parent5c9c61250bb23fd5fd1c18e243cab0d80573b749 (diff)
downloadopenembedded-core-contrib-d1737f2dabac5e338061863c78a91b4c115365c7.tar.gz
initramfs-framework: add nfsrootfs module
nfsrootfs module mounts rootfs via nfs parsing "nfsroot" and "ip" cmdline options. Signed-off-by: Oleksii Konoplitskyi <okonopli@cisco.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework')
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs48
1 files changed, 48 insertions, 0 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs b/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs
new file mode 100644
index 0000000000..e67ee4c25d
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+nfsrootfs_enabled() {
+ if [ ${bootparam_root} != "/dev/nfs" ] || [ -z ${bootparam_nfsroot} ]; then
+ return 1
+ fi
+ return 0
+}
+
+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 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}
+}
+