initramfs-nosizelimit.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 9a18df7a71bfa620b1278777d64783a359d7eb4e Mon Sep 17 00:00:00 2001
  2. From: Thorsten Glaser <tg@mirbsd.org>
  3. Date: Sun, 4 May 2014 01:37:54 +0200
  4. Subject: [PATCH] mount tmpfs-as-rootfs (initramfs) with -o
  5. nr_blocks=0,nr_inodes=0
  6. I would have preferred to write this patch to be able to pass
  7. rootflags=nr_blocks=0,nr_inodes=0 on the kernel command line,
  8. and then hand these rootflags over to the initramfs (tmpfs)
  9. mount in the same way the kernel hands them over to the block
  10. device rootfs mount. But at least the Debian/m68k initrd also
  11. parses $rootflags from the environment and adds it to the call
  12. to the user-space mount for the eventual root device, which
  13. would make the kernel command line rootflags option be used in
  14. both places (tmpfs and e.g. ext4) which is guaranteed to error
  15. out in at least one of them.
  16. This change is intended to aid people in a setup where the
  17. initrd is the final root filesystem, i.e. not mounted over.
  18. This is especially useful in automated tests running on qemu
  19. for boards with constrained memory (e.g. 64 MiB on sh4).
  20. Considering that the initramfs is normally emptied out then
  21. overmounted, this change is probably safe for setups where
  22. initramfs just hosts early userspace, too, since the tmpfs
  23. backing it is not accessible any more later on, AFAICT.
  24. Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
  25. ---
  26. init/do_mounts.c | 4 ++++
  27. 1 file changed, 4 insertions(+)
  28. diff --git a/init/do_mounts.c b/init/do_mounts.c
  29. index 82f2288..55a4cfe 100644
  30. --- a/init/do_mounts.c
  31. +++ b/init/do_mounts.c
  32. @@ -594,6 +594,7 @@ out:
  33. }
  34. static bool is_tmpfs;
  35. +static char tmpfs_rootflags[] = "nr_blocks=0,nr_inodes=0";
  36. static struct dentry *rootfs_mount(struct file_system_type *fs_type,
  37. int flags, const char *dev_name, void *data)
  38. {
  39. @@ -606,6 +607,9 @@ static struct dentry *rootfs_mount(struct file_system_type *fs_type,
  40. if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs)
  41. fill = shmem_fill_super;
  42. + if (is_tmpfs)
  43. + data = tmpfs_rootflags;
  44. +
  45. return mount_nodev(fs_type, flags, data, fill);
  46. }
  47. --
  48. 2.0.0.rc0