initramfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: initramfs <initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Taras Kondratiuk
	<takondra-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
	Victor Kamensky
	<kamensky-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
	Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>,
	linux-security-module
	<linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Al Viro <viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	linux-kernel
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [RFC PATCH] rootfs: force mounting rootfs as tmpfs
Date: Tue, 30 Jan 2018 16:46:17 -0500	[thread overview]
Message-ID: <1517348777.3469.5.camel@linux.vnet.ibm.com> (raw)

Commit 16203a7a9422 ("initmpfs: make rootfs use tmpfs when CONFIG_TMPFS
enabled") introduced using tmpfs as the rootfs filesystem.  The use of
tmpfs is limited to systems that do not specify "root=" on the boot
command line.

Without the check "!saved_root_name[0]", rootfs uses tmpfs.  As there
must be a valid reason for this check, this patch introduces a new boot
command line option named "noramfs" to force rootfs to use tmpfs.

Signed-off-by: Mimi Zohar <zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
 Documentation/admin-guide/kernel-parameters.txt |  2 ++
 init/do_mounts.c                                | 15 +++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 6571fbfdb2a1..fd82df2ff150 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2733,6 +2733,8 @@
 
 	nopcid		[X86-64] Disable the PCID cpu feature.
 
+	noramfs		Don't use ramfs for rootfs, use tmpfs.
+
 	norandmaps	Don't use address space randomization.  Equivalent to
 			echo 0 > /proc/sys/kernel/randomize_va_space
 
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 7cf4f6dafd5f..74d8bfcd1294 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -315,6 +315,16 @@ static int __init root_data_setup(char *str)
 	return 1;
 }
 
+static bool force_tmpfs;
+static int __init force_tmpfs_setup(char *str)
+{
+	if (*str)
+		return 0;
+	force_tmpfs = true;
+	return 1;
+
+}
+
 static char * __initdata root_fs_names;
 static int __init fs_names_setup(char *str)
 {
@@ -332,6 +342,7 @@ static int __init root_delay_setup(char *str)
 __setup("rootflags=", root_data_setup);
 __setup("rootfstype=", fs_names_setup);
 __setup("rootdelay=", root_delay_setup);
+__setup("noramfs", force_tmpfs_setup);
 
 static void __init get_fs_names(char *page)
 {
@@ -632,8 +643,8 @@ int __init init_rootfs(void)
 	if (err)
 		return err;
 
-	if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
-		(!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
+	if (IS_ENABLED(CONFIG_TMPFS) && (force_tmpfs || (!saved_root_name[0] &&
+		(!root_fs_names || strstr(root_fs_names, "tmpfs"))))) {
 		err = shmem_init();
 		is_tmpfs = true;
 	} else {
-- 
2.7.5

             reply	other threads:[~2018-01-30 21:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30 21:46 Mimi Zohar [this message]
2018-01-31 19:32 ` [RFC PATCH] rootfs: force mounting rootfs as tmpfs Rob Landley
     [not found]   ` <1814af5c-170d-39c0-58fd-02eb7216e008-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2018-01-31 22:07     ` Mimi Zohar
2018-01-31 23:48       ` Rob Landley
     [not found]         ` <a538e55c-81ca-6d59-20cf-21b47387c3e2-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2018-02-01  2:03           ` Arvind Sankar
2018-02-01  4:22             ` Mimi Zohar
     [not found]               ` <1517458921.3329.2.camel-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2018-02-01 15:20                 ` Rob Landley
2018-02-01 15:55                   ` Mimi Zohar
     [not found]                     ` <1517500500.3974.45.camel-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2018-02-01 17:09                       ` Rob Landley
     [not found]                         ` <875e5d2d-9ffe-14ab-090a-4a9632af0f35-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2018-02-01 21:51                           ` Mimi Zohar
     [not found]                             ` <1517521912.3619.0.camel-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2018-02-01 22:41                               ` Taras Kondratiuk
2018-02-01 23:34                                 ` Rob Landley
2018-04-16 15:46                                   ` Mimi Zohar
2018-02-01 22:46               ` Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517348777.3469.5.camel@linux.vnet.ibm.com \
    --to=zohar-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=kamensky-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
    --cc=takondra-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    --cc=viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).