Skip to contentSkip to conversation

init: enable system-on-initramfs: root-on-tmpfs

PATCH Bodo Eggert 2 participants 4 messages Jul 14, 2007 – Jul 26, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 1 line · Al Boldi

Bodo Eggert wrote:

Please reply-to-all, I'm not subscribed, but reading through a news gateway.

Quoted 11 lines
Quoted 3 lines

This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use tmpfs instead of ramfs". All the fame belongs to him, the bugs belong to me.

Actually, my patch was a rework of John Zielinski's
http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the credit really goes to him.

Quoted 3 lines
Quoted 8 lines
Quoted 5 lines

diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig

2007-07-12 14:05:16.000000000 +0200 +++ linux-2.6.22.tmpfsroot/fs/Kconfig
 2007-07-12 15:10:09.000000000 +0200 @@ -989,6 +989,22 @@ config

TMPFS_POSIX_ACL

Setting this in fs/Kconfig is way to deep, and too far away from the initramfs Kconfig, which makes it obscure.

If it were under general setup, you'd have to enter fs to select tmpfs, enter general setup to replace ramfs, and re-enter fs to disable ramfs. I consider making people do that to be an evil deed.

The current position is very convenient, ramfs is below tmpfs, and while you go from top to the bottom, you can enable tmpfs, tmpfs-replaces-ramfs and ramfs=n.

Quoted 10 lines

Review

Quoted 4 lines

If you don't know what Access Control Lists are, say N.

(quoted diff) +2 -0
+config TMPFS_ROOT
+       bool "Use tmpfs instrad of ramfs for initramfs"

Check typo.

Quoted 1 line

+ depends on TMPFS

Should probably depend on SHMEM too.

Sounds reasonable.

Quoted 8 lines

Review config HUGETLB_PAGE · line 1022

Quoted 6 lines
(quoted diff) +1 -1
@@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
        def_bool HUGETLBFS
 
 config RAMFS
-       bool
+       bool "Ramfs file system support" if TMPFS_ROOT

What's wrong with the original Kconfig of making this tristate?

I tested =m, found it not to compile because of a nonexported __symbol and decided it wasn't worth the effort of adding another export while other people struggle to reduce their number.

Quoted 17 lines
Quoted 17 lines

diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c

2007-07-12 14:05:25.000000000 +0200 +++ linux-2.6.22.tmpfsroot/mm/shmem.c
 2007-07-12 15:01:32.000000000 +0200 @@ -2369,6 +2369,8 @@ static void

init_once(void *foo, struct

static int init_inodecache(void)
{

(quoted diff) +2 -0
+       if (shmem_inode_cachep)
+               return 0;
        shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
                                sizeof(struct shmem_inode_info),
                                0, 0, init_once, NULL);
@@ -2582,6 +2584,34 @@ put_memory:
        return ERR_PTR(error);
 }
 
Quoted 8 lines

Review put_memory: · line 2592

Quoted 6 lines
(quoted diff) +5 -0
+#ifdef CONFIG_TMPFS_ROOT
+static int rootfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
+{
+       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
 shmem_fill_super, +                           mnt);

Setting the MS_NOUSER flag will make this invisible to df (diskfree).

Which is obviously a bad thing for my cause, but good if you'd boot a normal system. Is there any way out?

Quoted 11 lines

Review put_memory: · line 2599

Quoted 7 lines
(quoted diff) +6 -0
+}
+
+/*static struct super_block *rootfs_get_sb(struct file_system_type
 *fs_type, +       int flags, const char *dev_name, void *data)
+{
+       return get_sb_single(fs_type, flags, data, shmem_fill_super);
+}*/

You commented this out, probably asking for clarification: IIRC, it's get_sb_single instead of get_sb_nodev, because tmpfs can be mounted more than once and thus needs to be reference counted.

No, I had left it there accidentially. Your comment tells me it was ment to happen.

Signature · 4 lines
If at first you don't succeed call in an air-strike. 

Friß, Spammer: [email protected] [email protected]
 [email protected] [email protected]
#2 lore raw

Re: [PATCH 0/3][try 1] init: enable system-on-initramfs

Quoted 28 lines · Bodo Eggert
Quoted 7 lines · H. Peter Anvin
Quoted 6 lines · Bodo Eggert
Quoted 5 lines · H. Peter Anvin
Quoted 3 lines · Bodo Eggert

Setting the name of the rdinit process to the name of the init process in order to select the root device should not be the right knob.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

What's wrong with it?

rdinit is supposed to be the program that mounts, root is supposed to be whatever is mounted and init is supposed to run the system. Three different things. Now if you want to change the third, just set the first to the second ...

That only applies to a model that you explicitly doesn't want to use.

I don't want to use rdinit, because there is no task for rdinit(3), and I don't want to mount a filesystem(3). But I do want to use init(2).

I have to lie to the kernel saying (2) is (1) in order to trick it into beleaving I'd do (3) myself, which I don't, just in order to not do (3). If the bug of not calling the security hook would be fixed, this trick would use the path where rdinit is expected to trigger the callback, but since that rdinit would be no rdinit, that callback would still be wrongly skipped. That would not be a bad thing for my setup, but it clearly shows this setup to be wrong.

Quoted 2 lines

The correct solution is tell the kernel not to do (3) if you don't want it to do (3). The rest will work as intended.

Sounds rather confusing.

This is how I see it:

initrd=initrd.img.gz implies root=rootfs rdinit=/bin/sh is the special init=/bin/sh for initrd.

Both initrd/root and rdinit/init must be separate for pivoting to succeed. If you want to drop into the initrd (i.e. rootfs), then instruct your initrd.img.gz not to pivot (i.e. not over-mount another filesystem).

Thanks!

--
Al

#3 lore raw
In reply to Bodo Eggert
Quoted 5 lines · Bodo Eggert
Quoted 1 line · Al Boldi

Bodo Eggert wrote:

Please reply-to-all, I'm not subscribed, but reading through a news gateway.

Same here. The problem is, I have no idea who's on the cc, and expected you to be on the list. Sorry.

Quoted 20 lines
Quoted 11 lines
Quoted 3 lines

This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use tmpfs instead of ramfs". All the fame belongs to him, the bugs belong to me.

Actually, my patch was a rework of John Zielinski's
http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the credit really goes to him.

Quoted 3 lines
Quoted 8 lines

Review config TMPFS_POSIX_ACL

Quoted 5 lines

diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig

2007-07-12 14:05:16.000000000 +0200 +++

linux-2.6.22.tmpfsroot/fs/Kconfig 2007-07-12 15:10:09.000000000 +0200

(quoted diff) +0 -0
@@ -989,6 +989,22 @@ config TMPFS_POSIX_ACL

Setting this in fs/Kconfig is way to deep, and too far away from the initramfs Kconfig, which makes it obscure.

Quoted 3 lines

If it were under general setup, you'd have to enter fs to select tmpfs, enter general setup to replace ramfs, and re-enter fs to disable ramfs. I consider making people do that to be an evil deed.

That's easy to fix, just change "depends on" to "select" in Kconfig.

Quoted 26 lines

The current position is very convenient, ramfs is below tmpfs, and while you go from top to the bottom, you can enable tmpfs, tmpfs-replaces-ramfs and ramfs=n.

Quoted 10 lines

Review config TMPFS_POSIX_ACL · line 992

Quoted 4 lines
(quoted diff) +2 -0
          If you don't know what Access Control Lists are, say N.
 
+config TMPFS_ROOT
+       bool "Use tmpfs instrad of ramfs for initramfs"

Check typo.

Review config TMPFS_POSIX_ACL · line 993

Quoted 1 line
(quoted diff) +1 -0
+       depends on TMPFS

Should probably depend on SHMEM too.

Sounds reasonable.

Quoted 8 lines

Review config HUGETLB_PAGE · line 1022

Quoted 6 lines
(quoted diff) +1 -1
@@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
        def_bool HUGETLBFS
 
 config RAMFS
-       bool
+       bool "Ramfs file system support" if TMPFS_ROOT

What's wrong with the original Kconfig of making this tristate?

Quoted 3 lines

I tested =m, found it not to compile because of a nonexported __symbol and decided it wasn't worth the effort of adding another export while other people struggle to reduce their number.

Ok.

Quoted 26 lines
Quoted 17 lines
Quoted 17 lines

diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c

2007-07-12 14:05:25.000000000 +0200 +++

linux-2.6.22.tmpfsroot/mm/shmem.c 2007-07-12 15:01:32.000000000 +0200

(quoted diff) +2 -0
@@ -2369,6 +2369,8 @@ static void init_once(void *foo, struct
 
 static int init_inodecache(void)
 {
+       if (shmem_inode_cachep)
+               return 0;
        shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
                                sizeof(struct shmem_inode_info),
                                0, 0, init_once, NULL);
@@ -2582,6 +2584,34 @@ put_memory:
        return ERR_PTR(error);
 }
 
Quoted 8 lines

Review put_memory: · line 2592

Quoted 6 lines
(quoted diff) +4 -0
+#ifdef CONFIG_TMPFS_ROOT
+static int rootfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount
 *mnt) +{
+       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
 shmem_fill_super, +                           mnt);

Setting the MS_NOUSER flag will make this invisible to df (diskfree).

Quoted 2 lines

Which is obviously a bad thing for my cause, but good if you'd boot a normal system. Is there any way out?

Just remove the MS_NOUSER flag. Normal systems would want to umount it after pivoting, so it won't be visible then.

Quoted 12 lines
Quoted 11 lines

Review put_memory: · line 2599

Quoted 7 lines
(quoted diff) +6 -0
+}
+
+/*static struct super_block *rootfs_get_sb(struct file_system_type
 *fs_type, +       int flags, const char *dev_name, void *data)
+{
+       return get_sb_single(fs_type, flags, data, shmem_fill_super);
+}*/

You commented this out, probably asking for clarification: IIRC, it's get_sb_single instead of get_sb_nodev, because tmpfs can be mounted more than once and thus needs to be reference counted.

Quoted 2 lines

No, I had left it there accidentially. Your comment tells me it was ment to happen.

Thanks!

--
Al

#4 lore raw

What happened to this one? Is it in -mm?

Thanks!

--
Al

Quoted 112 lines · Al Boldi
Quoted 22 lines · Bodo Eggert
Quoted 12 lines · Al Boldi
Quoted 3 lines · Bodo Eggert

This is a rework of Al Boldi's "[PATCH] initramfs: Allow rootfs to use tmpfs instead of ramfs". All the fame belongs to him, the bugs belong to me.

Actually, my patch was a rework of John Zielinski's
http://marc.info/?l=linux-kernel&m=107013630212011&w=4 patch, so the credit really goes to him.

Quoted 3 lines
Quoted 8 lines

Review config TMPFS_POSIX_ACL

Quoted 5 lines

diff -Xdontdiff -pruN linux-2.6.22.base/fs/Kconfig linux-2.6.22.tmpfsroot/fs/Kconfig --- linux-2.6.22.base/fs/Kconfig

2007-07-12 14:05:16.000000000 +0200 +++

linux-2.6.22.tmpfsroot/fs/Kconfig 2007-07-12 15:10:09.000000000 +0200

(quoted diff) +0 -0
@@ -989,6 +989,22 @@ config TMPFS_POSIX_ACL

Setting this in fs/Kconfig is way to deep, and too far away from the initramfs Kconfig, which makes it obscure.

Quoted 3 lines

If it were under general setup, you'd have to enter fs to select tmpfs, enter general setup to replace ramfs, and re-enter fs to disable ramfs. I consider making people do that to be an evil deed.

That's easy to fix, just change "depends on" to "select" in Kconfig.

Quoted 26 lines

The current position is very convenient, ramfs is below tmpfs, and while you go from top to the bottom, you can enable tmpfs, tmpfs-replaces-ramfs and ramfs=n.

Quoted 10 lines

Review config TMPFS_POSIX_ACL · line 992

Quoted 4 lines
(quoted diff) +2 -0
          If you don't know what Access Control Lists are, say N.
 
+config TMPFS_ROOT
+       bool "Use tmpfs instrad of ramfs for initramfs"

Check typo.

Review config TMPFS_POSIX_ACL · line 993

Quoted 1 line
(quoted diff) +1 -0
+       depends on TMPFS

Should probably depend on SHMEM too.

Sounds reasonable.

Quoted 8 lines

Review config HUGETLB_PAGE · line 1022

Quoted 6 lines
(quoted diff) +1 -1
@@ -1003,7 +1019,7 @@ config HUGETLB_PAGE
        def_bool HUGETLBFS
 
 config RAMFS
-       bool
+       bool "Ramfs file system support" if TMPFS_ROOT

What's wrong with the original Kconfig of making this tristate?

Quoted 3 lines

I tested =m, found it not to compile because of a nonexported __symbol and decided it wasn't worth the effort of adding another export while other people struggle to reduce their number.

Ok.

Quoted 26 lines
Quoted 17 lines
Quoted 17 lines

diff -Xdontdiff -pruN linux-2.6.22.base/mm/shmem.c linux-2.6.22.tmpfsroot/mm/shmem.c --- linux-2.6.22.base/mm/shmem.c

2007-07-12 14:05:25.000000000 +0200 +++

linux-2.6.22.tmpfsroot/mm/shmem.c 2007-07-12 15:01:32.000000000 +0200

(quoted diff) +2 -0
@@ -2369,6 +2369,8 @@ static void init_once(void *foo, struct
 
 static int init_inodecache(void)
 {
+       if (shmem_inode_cachep)
+               return 0;
        shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
                                sizeof(struct shmem_inode_info),
                                0, 0, init_once, NULL);
@@ -2582,6 +2584,34 @@ put_memory:
        return ERR_PTR(error);
 }
 
Quoted 8 lines

Review put_memory: · line 2592

Quoted 6 lines
(quoted diff) +4 -0
+#ifdef CONFIG_TMPFS_ROOT
+static int rootfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount
 *mnt) +{
+       return get_sb_nodev(fs_type, flags|MS_NOUSER, data,
 shmem_fill_super, +                           mnt);

Setting the MS_NOUSER flag will make this invisible to df (diskfree).

Quoted 2 lines

Which is obviously a bad thing for my cause, but good if you'd boot a normal system. Is there any way out?

Just remove the MS_NOUSER flag. Normal systems would want to umount it after pivoting, so it won't be visible then.

Quoted 12 lines
Quoted 11 lines

Review put_memory: · line 2599

Quoted 7 lines
(quoted diff) +6 -0
+}
+
+/*static struct super_block *rootfs_get_sb(struct file_system_type
 *fs_type, +       int flags, const char *dev_name, void *data)
+{
+       return get_sb_single(fs_type, flags, data, shmem_fill_super);
+}*/

You commented this out, probably asking for clarification: IIRC, it's get_sb_single instead of get_sb_nodev, because tmpfs can be mounted more than once and thus needs to be reference counted.

Quoted 2 lines

No, I had left it there accidentially. Your comment tells me it was ment to happen.

Thanks!

--
Al