diff --git a/fs/Kconfig b/fs/Kconfig
index 780725a..d055f72 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -152,6 +152,16 @@ config TMPFS_XATTR
 
 	  If unsure, say N.
 
+config TMPFS_ROOT
+	bool "Use tmpfs instead of ramfs for initramfs"
+	depends on TMPFS && SHMEM
+	default n
+	help
+	  This replaces the ramfs used for unpacking the cpio images
+	  with tmpfs.
+
+	  If unsure, say N
+
 config HUGETLBFS
 	bool "HugeTLB file system support"
 	depends on X86 || IA64 || SPARC64 || (S390 && 64BIT) || \
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index eab8c09..fda8eb1 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -244,35 +244,19 @@ struct dentry *ramfs_mount(struct file_system_type *fs_type,
 	return mount_nodev(fs_type, flags, data, ramfs_fill_super);
 }
 
+#ifndef CONFIG_TMPFS_ROOT
 static struct dentry *rootfs_mount(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data)
 {
 	return mount_nodev(fs_type, flags|MS_NOUSER, data, ramfs_fill_super);
 }
 
-static void ramfs_kill_sb(struct super_block *sb)
-{
-	kfree(sb->s_fs_info);
-	kill_litter_super(sb);
-}
-
-static struct file_system_type ramfs_fs_type = {
-	.name		= "ramfs",
-	.mount		= ramfs_mount,
-	.kill_sb	= ramfs_kill_sb,
-};
 static struct file_system_type rootfs_fs_type = {
 	.name		= "rootfs",
 	.mount		= rootfs_mount,
 	.kill_sb	= kill_litter_super,
 };
 
-static int __init init_ramfs_fs(void)
-{
-	return register_filesystem(&ramfs_fs_type);
-}
-module_init(init_ramfs_fs)
-
 int __init init_rootfs(void)
 {
 	int err;
@@ -287,3 +271,23 @@ int __init init_rootfs(void)
 
 	return err;
 }
+
+#endif
+
+static void ramfs_kill_sb(struct super_block *sb)
+{
+	kfree(sb->s_fs_info);
+	kill_litter_super(sb);
+}
+
+static struct file_system_type ramfs_fs_type = {
+	.name		= "ramfs",
+	.mount		= ramfs_mount,
+	.kill_sb	= ramfs_kill_sb,
+};
+
+static int __init init_ramfs_fs(void)
+{
+	return register_filesystem(&ramfs_fs_type);
+}
+module_init(init_ramfs_fs)
diff --git a/mm/shmem.c b/mm/shmem.c
index efd0b3a..d713953 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2657,6 +2657,10 @@ static void shmem_init_inode(void *foo)
 
 static int shmem_init_inodecache(void)
 {
+#ifdef CONFIG_TMPFS_ROOT
+	if (shmem_inode_cachep)
+		return 0;
+#endif
 	shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
 				sizeof(struct shmem_inode_info),
 				0, SLAB_PANIC, shmem_init_inode);
@@ -2935,6 +2939,27 @@ put_memory:
 }
 EXPORT_SYMBOL_GPL(shmem_file_setup);
 
+#ifdef CONFIG_TMPFS_ROOT
+static struct dentry *rootfs_mount(struct file_system_type *fs_type,
+	int flags, const char *dev_name, void *data)
+{
+	return mount_nodev(fs_type, flags, data, shmem_fill_super);
+}
+
+static struct file_system_type rootfs_fs_type = {
+	.name		= "rootfs",
+	.mount		= rootfs_mount,
+	.kill_sb	= kill_litter_super,
+};
+
+int __init init_rootfs(void)
+{
+	if (shmem_init_inodecache())
+		panic("Can't initialize shm inode cache");
+	return register_filesystem(&rootfs_fs_type);
+}
+#endif
+
 /**
  * shmem_zero_setup - setup a shared anonymous mapping
  * @vma: the vma to be mmapped is prepared by do_mmap_pgoff
