kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* How is the size of init ram disk  determined when initramfs is used?
@ 2022-10-07  2:32 Chan Kim
  2023-01-01 16:54 ` Richard
  2023-01-01 17:32 ` Bernd Petrovitsch
  0 siblings, 2 replies; 5+ messages in thread
From: Chan Kim @ 2022-10-07  2:32 UTC (permalink / raw)
  To: kernelnewbies

Hello all,

I'm using initramfs.cpio.gz for initial file system image.
I embed it in the kernel Image file.
After linux boots, when I'm in the shell, I can create files.
But I'm curious how much the file system can grow.
I remember somewhere reading that the initramdisk is made and the initramfs
archive is extracted in the ramdisk.
Then how is the ramdisk size determined? During the build usig Kconfig
variable, or does it dynamically grow?
Thanks in advance.

Chan Kim





_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How is the size of init ram disk determined when initramfs is used?
  2022-10-07  2:32 How is the size of init ram disk determined when initramfs is used? Chan Kim
@ 2023-01-01 16:54 ` Richard
  2023-01-01 17:32 ` Bernd Petrovitsch
  1 sibling, 0 replies; 5+ messages in thread
From: Richard @ 2023-01-01 16:54 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I don't exactly how and where the size is determined, but

On 07/10/2022 04:32, Chan Kim wrote:
> Hello all,
> 
> I'm using initramfs.cpio.gz for initial file system image.
> I embed it in the kernel Image file.
> After linux boots, when I'm in the shell, I can create files.
> But I'm curious how much the file system can grow.
> I remember somewhere reading that the initramdisk is made and the initramfs
> archive is extracted in the ramdisk.
> Then how is the ramdisk size determined? During the build usig Kconfig

this is extremly unlikely. For example when you do "apt upgrade" on 
debian and there gets a new kernel installed (or I think even when it is 
only about specific new kernel modules), sometimes a new initramfs is 
built. This includes (as far as I know) also some modules and 
configuration specific to your computer. This way they can ship a 
generic kernel but it still works custom for you since the initramfs is 
custom.

This customization means the intitramfs' size will vary. But since the 
kernel is built independently and beforehand it can not know that size.

Also, why should the filesize be that important? Can't it just be stored 
in some file header when it's generated ? Maybe I'm missing something here

-- Richard

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How is the size of init ram disk determined when initramfs is used?
  2022-10-07  2:32 How is the size of init ram disk determined when initramfs is used? Chan Kim
  2023-01-01 16:54 ` Richard
@ 2023-01-01 17:32 ` Bernd Petrovitsch
  2023-01-01 19:23   ` Nicholas Mc Guire
  1 sibling, 1 reply; 5+ messages in thread
From: Bernd Petrovitsch @ 2023-01-01 17:32 UTC (permalink / raw)
  To: kernelnewbies

Hi all!

On 07/10/2022 04:32, Chan Kim wrote:
[...]
> I'm using initramfs.cpio.gz for initial file system image.
> I embed it in the kernel Image file.
> After linux boots, when I'm in the shell, I can create files.
> But I'm curious how much the file system can grow.

Why not just try it once;-)

> I remember somewhere reading that the initramdisk is made and the initramfs
> archive is extracted in the ramdisk.

Makes the most sense - a RamFS implementation exists (e.g. mounted
on /tmp for speed) and using this and extraction a cpio (or whatever
archive format) into it is the simplest.

> Then how is the ramdisk size determined? During the build usig Kconfig
> variable, or does it dynamically grow?

See also the other mail - the distribution builds it with the
"necessary" stuff (whatever that is) to mount the "real" root
filesystems.

After the real root filesystem is mounted, the initramfs as such
is no longer accessible and - thus - will be freed (I assume - I
didn't check recently) to not use physical RAM unnecessarily.

FWIW one can run the system completely out of a initramfs - we did
that at a former employer of mine for an embedded Linux system (4MB
Flash RAM for the bootimage, 16MB physical RAM - it was Kernel
2.4.0 in 2000:-).

Kind regards,
	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
      There is NO CLOUD, just other people's computers. - FSFE
                      LUGA : http://www.luga.at


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How is the size of init ram disk determined when initramfs is used?
  2023-01-01 17:32 ` Bernd Petrovitsch
@ 2023-01-01 19:23   ` Nicholas Mc Guire
  2023-01-02  2:37     ` Chan Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Mc Guire @ 2023-01-01 19:23 UTC (permalink / raw)
  To: Bernd Petrovitsch; +Cc: kernelnewbies

On Sun, Jan 01, 2023 at 06:32:55PM +0100, Bernd Petrovitsch wrote:
> Hi all!
> 
> On 07/10/2022 04:32, Chan Kim wrote:
> [...]
> >I'm using initramfs.cpio.gz for initial file system image.
> >I embed it in the kernel Image file.
> >After linux boots, when I'm in the shell, I can create files.
> >But I'm curious how much the file system can grow.
> 
> Why not just try it once;-)

ramdisks are static - so if you mount ram0 and ramdisk_size=8192
then your ramdisk is occupying 8MB and that will be the hard limit
at least on some architectures (x86, I think also arm).

> 
> >I remember somewhere reading that the initramdisk is made and the initramfs
> >archive is extracted in the ramdisk.

On some architectures you can pass the size as kernel parameter
ramdisk_size=#kb and that will then set the size of the ramdisk
when you mount it (at boot or during normaal operations). 

As I did not find what archtiecture you are refering to this might
help - grep for ramdisk_size in Documentations and you should have
it. E.g. for arm it is marked as obsolete (arm/boot.rst) but still
seems to be supported with CONFIG_DEPRECATED_PARAM_STRUCT set. 
Wonder what it is being replaced by.

thx!
hofrat

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: How is the size of init ram disk determined when initramfs is used?
  2023-01-01 19:23   ` Nicholas Mc Guire
@ 2023-01-02  2:37     ` Chan Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Chan Kim @ 2023-01-02  2:37 UTC (permalink / raw)
  To: 'Nicholas Mc Guire', 'Bernd Petrovitsch'; +Cc: kernelnewbies

Hello all,

Thanks for the replies and discussion.
So following Bernd's suggestion, I tried making a big file to see how big
the file system can grow.
Using qemu (arm64, I think it will be the same in real machine, it was
always almost the same), 
I tried 'dd if=/dev/zero of=test bs=1M count=768' and I see a file with size
768MB is generated.
So it seems it uses the available ram (I had 1GB ram, and the initial file
system size was only 19MB)
(BTW, I had to do 'mknod /dev/zero c 1 5 in the init script for this)
My real board doesn't have disk connected now and we'll be doing things on
ram for now.
Thank you.

Chan Kim

>-----Original Message-----
>From: Nicholas Mc Guire <der.herr@hofr.at>
>Sent: Monday, January 2, 2023 4:23 AM
>To: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
>Cc: kernelnewbies@kernelnewbies.org
>Subject: Re: How is the size of init ram disk determined when initramfs is
>used?
>
>On Sun, Jan 01, 2023 at 06:32:55PM +0100, Bernd Petrovitsch wrote:
>> Hi all!
>>
>> On 07/10/2022 04:32, Chan Kim wrote:
>> [...]
>> >I'm using initramfs.cpio.gz for initial file system image.
>> >I embed it in the kernel Image file.
>> >After linux boots, when I'm in the shell, I can create files.
>> >But I'm curious how much the file system can grow.
>>
>> Why not just try it once;-)
>
>ramdisks are static - so if you mount ram0 and ramdisk_size=8192 then your
>ramdisk is occupying 8MB and that will be the hard limit at least on some
>architectures (x86, I think also arm).
>
>>
>> >I remember somewhere reading that the initramdisk is made and the
>> >initramfs archive is extracted in the ramdisk.
>
>On some architectures you can pass the size as kernel parameter
>ramdisk_size=#kb and that will then set the size of the ramdisk when you
>mount it (at boot or during normaal operations).
>
>As I did not find what archtiecture you are refering to this might help -
>grep for ramdisk_size in Documentations and you should have it. E.g. for
arm
>it is marked as obsolete (arm/boot.rst) but still seems to be supported
with
>CONFIG_DEPRECATED_PARAM_STRUCT set.
>Wonder what it is being replaced by.
>
>thx!
>hofrat
>
>_______________________________________________
>Kernelnewbies mailing list
>Kernelnewbies@kernelnewbies.org
>https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies





_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-02  2:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07  2:32 How is the size of init ram disk determined when initramfs is used? Chan Kim
2023-01-01 16:54 ` Richard
2023-01-01 17:32 ` Bernd Petrovitsch
2023-01-01 19:23   ` Nicholas Mc Guire
2023-01-02  2:37     ` Chan Kim

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 NNTP newsgroup(s).