init: enable system-on-initramfs: root-on-tmpfs
Quoted 2 lines · Bodo Eggert
Change the root filesystem to tmpfs. Doing this makes having a system on tmpfs much easier, while allowing to discard the now unnecessary ramfs.
Thanks a lot!
Quoted 7 lines
Having the rootfs on tmpfs allows to safely run e.g. a rescue system without using tricks. You might even include the rescue system into the kernel.
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 8 lines
Signed-off-by Bodo Eggert <[email protected]>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.
Review
Quoted 5 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.
Quoted 17 lines
(quoted diff) +13
-0+ default n + help + This replaces the ramfs used for unpacking the cpio images + with tmpfs, thereby allowing swapping these contents to disk and + adding size limit support. + + Side effect: + This is useful only if you don't plan on mounting a different + root filesystem. Therefore it will change the default of the + root= parameter to "rootfs". + + If unsure, say N + config HUGETLBFS bool "HugeTLB file system support" depends on X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
Review config HUGETLB_PAGE · line 1022
Quoted 5 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?
Review config HUGETLB_PAGE · line 1025
Quoted 3 lines
(quoted diff) +0
-0default y ---help--- Ramfs is a file system which keeps all files in RAM. It allows
:
:
Quoted 14 lines
diff -Xdontdiff -pruN
linux-2.6.22.base/mm/shmem.clinux-2.6.22.tmpfsroot/mm/shmem.c---linux-2.6.22.base/mm/shmem.c2007-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 voidinit_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);
Review put_memory: · line 2592
Quoted 9 lines
(quoted diff) +5
-0@@ -2582,6 +2584,34 @@ put_memory: return ERR_PTR(error); } +#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).
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 8 lines
(quoted diff) +8
-0+ +static struct file_system_type rootfs_fs_type = { + .name = "rootfs", + .get_sb = rootfs_get_sb, + .kill_sb = kill_litter_super, +}; + +int __init init_rootfs(void)
Review put_memory:
Quoted 10 lines
(quoted diff) +7
-0+{ + if (init_inodecache()) + panic("Can't initialize shm inode cache"); + return register_filesystem(&rootfs_fs_type); +} +#endif + /* * shmem_zero_setup - setup a shared anonymous mapping *
Thanks!
--
Al