Add a filesystem option so a device can be booted over NFS.
Subsystems (3)
PATCH 1/1 Add a filesystem option so a device can be booted over NFS.
This options allows specifying a directory where the target rootfs is copied to so it can be used to boot a device over NFS.
--- Makefile | 5 +++++ fs/Config.in | 1 + fs/nfs/Config.in | 13 +++++++++++++ fs/nfs/nfs.mk | 16 ++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 fs/nfs/Config.in create mode 100644 fs/nfs/nfs.mk
Makefile +5 -0
@@ -833,6 +833,11 @@ clean: rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \ $(BUILD_DIR) $(BASE_DIR)/staging \ $(LEGAL_INFO_DIR) +ifeq ($(BR2_TARGET_ROOTFS_NFS),y) + if [ -d $(TARGET_ROOTFS_NFS_PATH) ]; then \ + rm -rf $(TARGET_ROOTFS_NFS_PATH) ;\ + fi +endif distclean: clean ifeq ($(DL_DIR),$(TOPDIR)/dl)
fs/Config.in +1 -0
@@ -7,6 +7,7 @@ source "fs/ext2/Config.in" source "fs/initramfs/Config.in" source "fs/iso9660/Config.in" source "fs/jffs2/Config.in" +source "fs/nfs/Config.in" source "fs/romfs/Config.in" source "fs/squashfs/Config.in" source "fs/tar/Config.in"
fs/nfs/Config.in new file +13 -0
@@ -0,0 +1,13 @@ +config BR2_TARGET_ROOTFS_NFS + bool "create NFS boot directory" + help + Creates a directory that contains the rootfs for booting over NFS. + +if BR2_TARGET_ROOTFS_NFS +config BR2_TARGET_ROOTFS_NFS_PATH + string "path to the directory used for booting over NFS" + default "~/nfsrootfs" + help + Path to the directory used for booting over NFS. + (This should also be added to your /etc/exports file.) +endif
fs/nfs/nfs.mk new file +15 -0
@@ -0,0 +1,15 @@ +################################################################################ +# +# create a directory for booting the device from an NFS. +# +################################################################################ + +TARGET_ROOTFS_NFS_PATH := $(call qstrip,$(BR2_TARGET_ROOTFS_NFS_PATH)) + +define ROOTFS_NFS_CMD + rm -rf $(TARGET_ROOTFS_NFS_PATH) ;\ + mkdir -p $(TARGET_ROOTFS_NFS_PATH) ;\ + cp -r $(TARGET_DIR)/* $(TARGET_ROOTFS_NFS_PATH) +endef + +$(eval $(call ROOTFS_TARGET,nfs))
Signature · 1 line
2.0.1
PATCH 1/1 Add a filesystem option so a device can be booted over NFS.
Hi Sagaert,
Quoted 18 lines · Sagaert Johan
This options allows specifying a directory where the target rootfs is copied to so it can be used to boot a device over NFS.
Signed-off-by Sagaert Johan <[email protected]>--- Makefile | 5 +++++ fs/Config.in | 1 + fs/nfs/Config.in | 13 +++++++++++++ fs/nfs/nfs.mk | 16 ++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 fs/nfs/Config.in create mode 100644 fs/nfs/nfs.mkMakefile +0
-0
Makefile clean: · line 839
Quoted 7 lines
Makefile +4
-0@@ -833,6 +833,11 @@ clean: rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \ $(BUILD_DIR) $(BASE_DIR)/staging \ $(LEGAL_INFO_DIR) +ifeq ($(BR2_TARGET_ROOTFS_NFS),y) + if [ -d $(TARGET_ROOTFS_NFS_PATH) ]; then \ + rm -rf $(TARGET_ROOTFS_NFS_PATH) ;\ + fi
Too many indentation tabs here.
Quoted 43 lines
Makefile +1
-0+endif distclean: clean ifeq ($(DL_DIR),$(TOPDIR)/dl)fs/Config.in +1
-0@@ -7,6 +7,7 @@ source "fs/ext2/Config.in" source "fs/initramfs/Config.in" source "fs/iso9660/Config.in" source "fs/jffs2/Config.in" +source "fs/nfs/Config.in" source "fs/romfs/Config.in" source "fs/squashfs/Config.in" source "fs/tar/Config.in"fs/nfs/Config.in new file +13
-0@@ -0,0 +1,13 @@ +config BR2_TARGET_ROOTFS_NFS + bool "create NFS boot directory" + help + Creates a directory that contains the rootfs for booting over NFS. + +if BR2_TARGET_ROOTFS_NFS +config BR2_TARGET_ROOTFS_NFS_PATH + string "path to the directory used for booting over NFS" + default "~/nfsrootfs" + help + Path to the directory used for booting over NFS. + (This should also be added to your /etc/exports file.) +endiffs/nfs/nfs.mk new file +2
-0@@ -0,0 +1,15 @@ +################################################################################ +#
fs/nfs/nfs.mk line 12
Quoted 10 lines
fs/nfs/nfs.mk new file +10
-0+# create a directory for booting the device from an NFS. +# +################################################################################ + +TARGET_ROOTFS_NFS_PATH := $(call qstrip,$(BR2_TARGET_ROOTFS_NFS_PATH)) + +define ROOTFS_NFS_CMD + rm -rf $(TARGET_ROOTFS_NFS_PATH) ;\ + mkdir -p $(TARGET_ROOTFS_NFS_PATH) ;\ + cp -r $(TARGET_DIR)/* $(TARGET_ROOTFS_NFS_PATH)
This doesn't look right. What about creating device nodes and SUID binaries? You must be root for that, $(TARGET_DIR) doesn't carry this information (fakeroot does that), and even if it did cp doesn't preserve these attributes. A better approach would be to extract a generated tar image, but you still must be root for that.
baruch
Quoted 3 lines
fs/nfs/nfs.mk new file +3
-0+endef + +$(eval $(call ROOTFS_TARGET,nfs))
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/1 Add a filesystem option so a device can be booted over NFS.
In reply to Sagaert Johanfs/nfs/nfs.mk line 15
Quoted 7 lines · Sagaert Johan
fs/nfs/nfs.mk new file +7
-0+define ROOTFS_NFS_CMD + rm -rf $(TARGET_ROOTFS_NFS_PATH) ;\ + mkdir -p $(TARGET_ROOTFS_NFS_PATH) ;\ + cp -r $(TARGET_DIR)/* $(TARGET_ROOTFS_NFS_PATH) +endef + +$(eval $(call ROOTFS_TARGET,nfs))
As Baruch suggested, using "cp" for this purpose is no good. Refer to the buildroot manual and the warning file installed to the target dir:
http://buildroot.uclibc.org/downloads/manual/manual.html#_nfs_boot
http://git.buildroot.net/buildroot/tree/support/misc/target-dir-warning.txt
Instead, consider simply making a post-build script that does the un-tar for you. Maybe something like this:
#!/bin/sh
NFSROOT=${NFS_SHARE:-/srv/my_nfsroot}
mkdir -p $NFS_SHARE
sudo tar -xavf ${BASE_DIR}/images.rootfs.tar -C $NFSROOT(Not actually tested.)
Then no patch is needed.
Danomi -
PATCH 1/1 Add a filesystem option so a device can be booted over NFS.
Quoted 9 lines · Danomi Manchego
Instead, consider simply making a post-build script that does the un-tar for you. Maybe something like this:
#!/bin/sh NFSROOT=${NFS_SHARE:-/srv/my_nfsroot} mkdir -p $NFS_SHARE sudo tar -xavf ${BASE_DIR}/images.rootfs.tar -C $NFSROOT
Apologies - those two "NFS_SHARE" should have been "NFSROOT" - last minute name change ...
Danomi -
PATCH 1/1 Add a filesystem option so a device can be booted over NFS.
In reply to Danomi Manchego-----Oorspronkelijk bericht-----
Van: Danomi Manchego [mailto:danomimanchego123 at gmail.com]
Verzonden: dinsdag 15 juli 2014 16:46
Aan: Sagaert Johan
CC: buildroot
Onderwerp: Re: [Buildroot] [PATCH 1/1] Add a filesystem option so a device can be booted over NFS.
fs/nfs/nfs.mk line 15
Quoted 6 lines · Sagaert Johan
fs/nfs/nfs.mk new file +6
-0+define ROOTFS_NFS_CMD + rm -rf $(TARGET_ROOTFS_NFS_PATH) ;\ + mkdir -p $(TARGET_ROOTFS_NFS_PATH) ;\ + cp -r $(TARGET_DIR)/* $(TARGET_ROOTFS_NFS_PATH) endef + +$(eval $(call ROOTFS_TARGET,nfs))
As Baruch suggested, using "cp" for this purpose is no good. Refer to the buildroot manual and the warning file installed to the target dir:
http://buildroot.uclibc.org/downloads/manual/manual.html#_nfs_boot
http://git.buildroot.net/buildroot/tree/support/misc/target-dir-warning.txt
Quoted 9 lines
Instead, consider simply making a post-build script that does the un-tar for you. Maybe something like this:
#!/bin/sh NFSROOT=${NFS_SHARE:-/srv/my_nfsroot} mkdir -p $NFS_SHARE sudo tar -xavf ${BASE_DIR}/images.rootfs.tar -C $NFSROOT
Quoted 4 lines
(Not actually tested.)
Then no patch is needed.
Danomi -
Hi all
Right, until now I always used a post script that extracted the rootfs.tar. So I tought I could integrate this into br.
And yes, I run linux in a vm and am to lazy to create a user and use sudo, so on my virtual linux machine, I am always logged in as root.
Regards, Johan
PATCH 1/1 Add a filesystem option so a device can be booted over NFS.
In reply to Sagaert JohanDear Sagaert Johan,
Quoted 5 lines · Sagaert Johan
This options allows specifying a directory where the target rootfs is copied to so it can be used to boot a device over NFS.
Signed-off-by Sagaert Johan <[email protected]>
How to boot from NFS is explained at
http://buildroot.org/downloads/manual/manual.html#_nfs_boot, and the solution you propose requires root privileges to extract the tarball image, which is not acceptable as Buildroot doesn't run as root.
Therefore, I'll have to mark your patch as Rejected in our patch tracking system. Do not hesitate to let us know if you disagree and see a better way of doing things.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com