What Happens When Booting Linux with Low Memory

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ • 172

  • @taldmd
    @taldmd 8 місяців тому +499

    I used to host my router and homelab server on an OG Pentium machine with 32 MB running Debian (Potato, then Woody) until around 2004-2005. Worked like an absolute charm. 20 years later you need 64 MB just to boot the kernel.

    • @elendil354
      @elendil354 8 місяців тому +105

      Bloat.

    • @Tart0p0mme78
      @Tart0p0mme78 8 місяців тому +110

      Compile your own kernel then

    • @Diamonddrake
      @Diamonddrake 8 місяців тому +122

      You can still run Linux with less memory than this, but not with all the kernel modules enabled

    • @rian0xFFF
      @rian0xFFF 8 місяців тому +8

      security

    • @Mmouse_
      @Mmouse_ 8 місяців тому +62

      First hard drive I ever had was 20mb - I remember talking to a friend about if video would ever be available online, we both agreed the resources required would be stupid and that it would never happen and yet... Here we are.

  • @realityveil6151
    @realityveil6151 8 місяців тому +21

    0:45 you're misreading the output of free. the 'free' column is how much memory is entirely unused, does not have any role at all. This is the pool that new memory requests will be drawn from first.
    'Available' is the column that shows you how much more memory can be used by applications, even though it is technically in use now.
    How is this possible? Because the linux kernel will use portions of your ram to buffer and cache (hence why there's a buff/cache column) data that isn't it direct use by an application *right now*, but may still be useful in the future. However, if there is no free memory and more memory is required, these caches will be cleared and that memory will be used instead.
    So at the timestamp provided, the kernel has addressed 45.3 MB of ram. 22.7MB is in hard use by the system or it's applications. 2.7mb has no purpose. 120k is in use by the tmpfs filesystem. 20Mb is tied up in buffers and caches. 13.5 MBs are available for use should an application or the kernel request more memory.

  • @Problematist
    @Problematist 7 місяців тому +26

    I love the "Found nothing?!?!" message in the kernel

  • @MeriaDuck
    @MeriaDuck 8 місяців тому +120

    Feeling a bit old :-) Ran linux, compiled kernel and even ran X window with netscape in 4Mb of RAM and 4Mb or swap (1995). Later (2003) we had 'big machines' in a 19" rack with 256Mb of RAM, plenty for linux AND a few Java JVMs!

    • @shallex5744
      @shallex5744 8 місяців тому +17

      something i wonder is why even the most simple and trivial of processes on a system nowadays seem to use at least several mb of ram to run, when obviously that would have been too much for machines of 70s,. 80s, and some in the 90s, so surely processes back then must have used less ram than they do now, yet when i compile my own program that does nothing but sit an in infinite loop forever, it takes 1 mb of ram to sit there and do nothing. i just wonder what changed between then and now

    • @yourcat8113
      @yourcat8113 8 місяців тому

      @@shallex5744 I imagine it's partly going from 32 bit to 64 bit doubled address and instruction lengths along with the libraries used to run everything getting bigger to account for all the different types of hardware they need to run on

    • @inertia_dagger
      @inertia_dagger 8 місяців тому

      ​​@@shallex57441mb for a program sounds like a stack size allocated by modern OSes. It has to be a constant size. That makes me think that defaults simply increased since then

    • @sepgh2216
      @sepgh2216 8 місяців тому +22

      @@shallex5744 one of the changes is at least moving from 32bit machines to 64 ones I guess. I also assume kernels do more complicated things because in short everything is more complicated, from cpu architectures, to multi threaded and multi process environments, security, etc.

    • @FluffyFoxUwU
      @FluffyFoxUwU 8 місяців тому +2

      @@shallex5744 i think libc just different than old times and you could just write bare assembly which infinite loop on `_start` symbol and you could drop the libc
      but at the end yea i can see what you mean there basic infinite loop takes way more than infinite loop in the past

  • @SyphistPrime
    @SyphistPrime 8 місяців тому +27

    Wow, that's cool. I also like how you showed the source code to give us an idea of what was happening. I'm not the best at reading code myself as I rarely develop things, but the quick explanation with the relevant code right there was super helpful for me.

  • @justinbasinger7728
    @justinbasinger7728 8 місяців тому +18

    I appreciate the structure of your videos. All the information you need, in a terse straight forward package. Always well done and covering topics I wouldn't likely dig into myself otherwise. Thanks!

  • @dev.rahulgurjar
    @dev.rahulgurjar 8 місяців тому +85

    Please, start a series on the OS basics.How it actually works, from scratch.

  • @eduardoroth8207
    @eduardoroth8207 8 місяців тому +32

    darn, i didn't about that sys request thing, quite awesome, it's like personally asking the kernel to do something from user space

    • @Epsicronics
      @Epsicronics 8 місяців тому +4

      I like the idea that sysrqs are just you telling the kernel "I messed up, help."

  • @prochazkaml
    @prochazkaml 8 місяців тому +9

    You can get Linux 6.5.0 to run alongside a minimal distro built with buildroot on an ESP32-S3 microcontroller with 8 MB of PSRAM. IIRC, after logging in, it still had ~3.5 MB free. (And yes, the onboard Wi-Fi does work.)

  • @wrathofainz
    @wrathofainz 8 місяців тому +128

    "Kernel panic" is hilarious to me for some reason.
    Insert "panik!" Meme here

    • @定义
      @定义 8 місяців тому +5

      The kernel actually "panics", because it has hit something critical, just like us humans. When we did something critically wrong, we panic.

  • @TheMohawkNinja
    @TheMohawkNinja 8 місяців тому +2

    2:22 Double exclamation mark, that's a new one for me. I had to look that one up to make sense of it since it seemed redundant.
    Basically converts an integer into a boolean by forcing it to be a 0 or 1. Certainly more elegant than a ternary.

    • @shr4pnel
      @shr4pnel 8 місяців тому

      also known as a "double bang". but don't diss my ternarys!

  • @dj.yacine
    @dj.yacine 8 місяців тому +15

    Always high quality content 👌

  • @wirytiox1577
    @wirytiox1577 8 місяців тому +1

    Thank you for explaining the acronyms for people that is not full into the subject is extreamly usefull ❤

  • @Hexnano
    @Hexnano 8 місяців тому +5

    One of the few channels I turned notifications on, awesome Linux content!

  • @joshuahudson2170
    @joshuahudson2170 8 місяців тому +6

    I've booted Linux in 16MB. I understand it can boot in as little as 2MB. Build your kernel without things you don't need. Usually this means disable loadable modules and only compile in drivers for hardware you actually have.

    • @_lun4r_
      @_lun4r_ 6 місяців тому

      I don't think 2 is ever possible for a modern kernel

  • @valentin-catalin1859
    @valentin-catalin1859 8 місяців тому +1

    Awesome channel, instant subscription. I have been binge-watching most of your Linux/bash/vim content. Hope this channel gets more subscribers so you can continue making videos.

  • @quintencabo
    @quintencabo 8 місяців тому +4

    How cool thanks for teaching about the sys request

  • @BobSockTwo
    @BobSockTwo 8 місяців тому +52

    I honestly don't know why, but seeing you use windows to record this video feels like a betrayal XD

    • @motoochhotoochintoo
      @motoochhotoochintoo 8 місяців тому +1

      Yes lol

    • @LostieTrekieTechie
      @LostieTrekieTechie 8 місяців тому +3

      I was wondering how they were making sure the key combo was not being intercepted by the host, were they running a different architecture? no it's windows

    • @pwii
      @pwii 8 місяців тому

      @@LostieTrekieTechie handling of the SysRQ key is a parameter you can disable when compiling the kernel. It's enabled by default but labeled as "don't enable this unless you really know what this hack does"

    • @manhle1582
      @manhle1582 8 місяців тому +3

      Windows is fine, but I got triggered when I saw Edge 😅

  • @justinnamilee
    @justinnamilee 8 місяців тому +1

    Neat! And the SysRq commands are _very_ useful when fooling around with custom kernel builds and you screw something up...

  • @CtrlAltFumble
    @CtrlAltFumble 8 місяців тому +1

    We've built a router firmware using kernel 2.6 in a mips hardware, it had 16 megs of ram and 4 megs of SPI flash. the entire system had to be compressed into the flash, only the kernel took 2 megs of flash space, the rest was used for userland tools. Kernel would uncompress itself in memory, taking about 8mb, so we had only 8 megs available for the rest of the system. It was challenging squeeze everything in 2 megs lol.

  • @whamer100
    @whamer100 8 місяців тому

    i remember trying out alpine once for a CTF game, and i was just amazed at how everything just worked with so little memory

  • @maximood-tired
    @maximood-tired 8 місяців тому

    I really like these short kernel videos. Maybe you could do more of this, explain little snippets of code of the kernel (not necessarily error handling)

  • @Tracing0029
    @Tracing0029 8 місяців тому +1

    The SysRq is only active if configured to be.

  • @DIYTechRepairs
    @DIYTechRepairs 8 місяців тому +5

    My first linux machine had 4mb ram so thats not small :D Not even 4mb is small
    But still i like your vids! Keep em comming.

  • @Jp-ue8xz
    @Jp-ue8xz 7 місяців тому

    Damn oveer a decade on linux, but today I finally learned what the sysreq key is good for lmao, good stuff!

  • @maciejk2
    @maciejk2 8 місяців тому +2

    very nice video!
    btw, its impressive how fast the vim is, how it allows for all of that stuff, so is there any easy tutorial how to setup it and learn? i never used it before, and i think that im missing something big. ive seen there are beautiful themes for it, but never got myself to really trying it out. would love to see instructions for windows or gnu/linux, even tho i currently only main windows :)

    • @nirlichtman
      @nirlichtman  8 місяців тому +1

      Check out my "Vim Tips" playlist for tutorials and tips. you can easily get Vim on windows using "winget install vim"

    • @maciejk2
      @maciejk2 8 місяців тому

      @@nirlichtman thank you :)

  • @weedsoldier.
    @weedsoldier. 8 місяців тому +4

    I think it's pretty obvious what happenes, the computer just... forgets

  • @markusTegelane
    @markusTegelane 8 місяців тому

    Didn't know you could trigger SysRq by just pressing the key not holding it. I've always just held Alt+SysRq and while doing that pressing a letter to send the command and it has worked every time.

  • @ronalerquinigoagurto555
    @ronalerquinigoagurto555 8 місяців тому +3

    More vids on exploring the kernel source

  • @HugoIsThatGuy
    @HugoIsThatGuy 8 місяців тому

    I am wondering what would happen if you have no swap or very little swap

  • @markzuckerbread1865
    @markzuckerbread1865 8 місяців тому

    This should be an exercise in OS courses in universities, nice way to show what happens on a deadlock.

  • @BarryKawooya-c3g
    @BarryKawooya-c3g 8 місяців тому +2

    My laptop keyboard doesn't have the sysrq

    • @nirlichtman
      @nirlichtman  8 місяців тому +2

      It should have, on some laptops you need to press Fn to activate the special keys (notice that SysRq and print screen are the same key so it may be that on your laptop it only says print screen)

    • @paulstelian97
      @paulstelian97 8 місяців тому +1

      @@nirlichtmanFor some it can be even weirder, like it can be some weird combo like Fn+S is SysRq on one laptop. You should find out what it is on your model.

    • @BarryKawooya-c3g
      @BarryKawooya-c3g 8 місяців тому

      @@nirlichtman thanks

  • @-ion
    @-ion 8 місяців тому

    Judging from the stack trace, it ran out of memory unpacking the initrd. How about if you boot without one?

  • @EdwardChan.999
    @EdwardChan.999 8 місяців тому

    I don't know why but this is very entertaining!

  • @MKOFT3N
    @MKOFT3N 7 місяців тому

    Could a commodore 64 run alpine linux?

  • @KingJellyfishII
    @KingJellyfishII 8 місяців тому

    i panicked for a second thinking the sysrequest key combination would reboot your host until realising it was windows...

  • @moody_weirdo
    @moody_weirdo 8 місяців тому +1

    Love your content.

  • @gerardzi7930
    @gerardzi7930 8 місяців тому +1

    Linux lite i don't know if more minimal system exist ?

    • @nirlichtman
      @nirlichtman  8 місяців тому

      I think Alpine would still be lighter than Linux Lite since I see that Linux Lite is based on Debian/Ubuntu and Alpine is def more minimal than them

    • @foxmoss_
      @foxmoss_ 8 місяців тому +1

      @@nirlichtman how does it compare to damn small linux?

  • @lucianchauvin8587
    @lucianchauvin8587 8 місяців тому

    how do you grep from vim like that it doesnt work for me:(

    • @nirlichtman
      @nirlichtman  8 місяців тому

      Check out my video about project search in Vim (on my playlist Vim tips), its simply adding a single line to the vimrc (no plugins required)

  • @comosaycomosah
    @comosaycomosah 10 днів тому

    since you have a great handle on this what would you suggest would be the "best" solution for low spec desktop like 2gb 4gb and old cpu...been looking at custom kernels like zen and cachyos kernel and self compiling the kernel with optimizations but only know so much...def gonna use a window manager prolly dwm but torn between void gentoo alpine and arch and then the kernel to use...any input would be appreciated

    • @nirlichtman
      @nirlichtman  7 днів тому

      In my opinion either Alpine or Debian are good options, if you go with Debian I would recommend installing the minimal installation (without a graphical environment), and then manually setting up and installing whatever you need. For the window manager I would go with dwm (or sway if you wanna use Wayland).

  • @DanelonNicolas
    @DanelonNicolas 8 місяців тому

    I love it. just love it. can't believe that key is for that. awesome 👍🏻 😎

  • @ligmagiga
    @ligmagiga 8 місяців тому

    The SysRq key on Linux is very similar to ‘System Call’ command from an anime called Sword Art Online. Pretty funny.

  • @Aragubas
    @Aragubas 7 місяців тому

    😮 wow did not know about the sysrq key

  • @SgtRamen69
    @SgtRamen69 8 місяців тому

    Crazy how there's CPUs now with enough cache to fit Linux inside

  • @xfaon
    @xfaon 7 місяців тому

    Great video!

  • @ehtrude
    @ehtrude 8 місяців тому +3

    Great video, but I have to ask… you know so much about Linux, and you even use DWM, so why use windows as the base system? Is there something missing in Linux for you?

    • @gwtar
      @gwtar 8 місяців тому +1

      He play roblox

    • @nirlichtman
      @nirlichtman  8 місяців тому +3

      I address this question on my welcome page, but mainly since I like both

    • @ehtrude
      @ehtrude 8 місяців тому +1

      @@nirlichtman oh, sorry, didn’t see it. Hmm, okay. My experience with windows has always been very buggy and unstable, but I guess it’s not like that for everyone. I do still prefer my OS to be open-source, and Linux has worked quite well for me. Interesting to see other opinions.

    • @wiinis-official
      @wiinis-official 8 місяців тому +1

      @ehtrude In my case at least, as much as I would like to daily drive Linux, my university pretty much runs on Windows and requires it for a lot of applications they use. Microsoft Office is a pretty big component too, so for the time being I need to stick with it (especially in grad school). Windows 11 isn’t awful, but I really do hate that it updates automatically without the user’s permission.

  • @typingcat
    @typingcat 8 місяців тому

    My first Windows 95 PC worked just fine on 8MB of RAM. Nowadays, a simple text editor would consume more RAM than that. I wonder how Windows 95 could work on such small RAM.

    • @Alice_Fumo
      @Alice_Fumo 8 місяців тому

      I had Notepad++ eating about 4 gigabytes a few days ago, so that puts our changing hardware demands really into perspective. Though it depends on what you're editing. Right now it's cruising on 2.4MB, which actually would fit your 8MB of RAM :)

    • @Knirin
      @Knirin 8 місяців тому

      @@Alice_Fumo A lot of the “problem” is programs started trading RAM for performance several decades ago because RAM capacity and speed were both improving much faster than general IOPS and speed were improving.
      I also doubt the stability of the 8MB Windows 95 machine. Per my recollection Windows 95 needed around 32MB to work well. It was much less picky about processor specs than memory. I had a 66MHz 486DX2 with 48MB of RAM that ran office stuff just fine. It hated doing much else though.

  • @neonblood4658
    @neonblood4658 4 місяці тому

    linux kernel code is honestly great for how massive the codebase is

  • @zootsuitpenguin
    @zootsuitpenguin 8 місяців тому

    Great info thanks!!

  • @Con-np9yx
    @Con-np9yx 7 місяців тому

    Would've loved to see you just completely remove the panic and then recompile Alpine.

  • @courtneymertz4596
    @courtneymertz4596 8 місяців тому

    Linux is never picky about the lowest of system resources, provided that you don’t use something for too much power of course. Like a desktop environment for example.

  • @010101110100
    @010101110100 8 місяців тому

    I’m still upset I couldn’t get Linux to boot on my 286 with 4mb ram

  • @galactic_dust42
    @galactic_dust42 8 місяців тому

    Thank for making video where I cant actually remember stuff

  • @Julian_H
    @Julian_H 8 місяців тому +1

    Very informative and i dont mean this as a slight, but i find it a bit funny how you're using windows and edge to explain linux

    • @turolretar
      @turolretar 8 місяців тому +1

      That’s hilarious

  • @SomeRandomPiggo
    @SomeRandomPiggo 8 місяців тому

    64MB seems surprisingly high to me

  • @dimaryk11
    @dimaryk11 8 місяців тому

    the code looks really simple, I wonder if I can actually help develop linux

  • @DegradationDomain_stuff
    @DegradationDomain_stuff 8 місяців тому

    Cool trick.
    Which text editor do you use?

  • @teldrah
    @teldrah 8 місяців тому

    The last time you were able to boot Windows with 64 MBs of memory was in the 90s 😂

  • @fanwojana-s7s
    @fanwojana-s7s 8 місяців тому +1

    Fun fact: if you press Alt + Sysrq on Windows 10, 11 it opens Onedrive

  • @frecio231
    @frecio231 8 місяців тому

    What's the System Request key?

    • @workonfire
      @workonfire 8 місяців тому

      Watch the video and you'll know

  • @isheamongus811
    @isheamongus811 7 місяців тому

    Will not run below 8KB on real x86 hardware. (BIOS won't start). EDIT: This is normal behavior. Maybe some BIOSes will work fine.

  • @vilian9185
    @vilian9185 8 місяців тому

    3:12 these magic keys help a lot lol

  • @bowedfloor
    @bowedfloor 7 місяців тому

    you have 20M of buffer/cache space. you could easily trim this another 15M
    Disable your initrd, and init=/bin/bash.

  • @klingoncowboy4
    @klingoncowboy4 8 місяців тому

    My dad loves to talk about running Slackware with less than 8mb back in the day... amazing now how 64 mb is the absulute minimum limit lol

  • @CocolinoFan
    @CocolinoFan 8 місяців тому

    Really cool.

  • @ambush427
    @ambush427 7 місяців тому

    The linux logo already tell the fate for someone who fail to fix it lol

  • @rohithkumarbandari
    @rohithkumarbandari 8 місяців тому

    Bro why do you use windows even after knowing so much about linux ?

    • @nirlichtman
      @nirlichtman  8 місяців тому +2

      I find it more comfortable as my main OS

    • @rohithkumarbandari
      @rohithkumarbandari 8 місяців тому

      @@nirlichtman Fair enough, great content though. How can we learn more about indepth stuff like this ?

  • @maximood-tired
    @maximood-tired 8 місяців тому

    very interesting!

  • @henryfleischer404
    @henryfleischer404 8 місяців тому

    Wow, that source code is really readable... I've gotta write some comments.

  • @SayaZionGoldTeam
    @SayaZionGoldTeam 8 місяців тому

    Perfect!

  • @kipchickensout
    @kipchickensout 8 місяців тому

    that's so interesting!

  • @clivethompson7831
    @clivethompson7831 8 місяців тому

    So neat

  • @werren894
    @werren894 8 місяців тому +1

    alpine is linux without GNU

    • @k2aj710
      @k2aj710 8 місяців тому

      Alpine is a tiny distro for containers / embedded.
      Lack of GNU is just an implementation detail.

  • @hyprodAx_
    @hyprodAx_ 7 місяців тому

    As soon as I saw the cover of the video I thought:
    "here’s a video made by a noob to make views with simple stuff," and instead it’s much more than that.

  • @PedroBastozz
    @PedroBastozz 8 місяців тому +1

    Bro it's literally glorified msdos. Why would it need decent amounts of ram?

    • @uooooooooh
      @uooooooooh 8 місяців тому +1

      Because "glorified" is doing a lot of heavy lifting there.

    • @PedroBastozz
      @PedroBastozz 8 місяців тому

      @@uooooooooh it’s all cli. This should be able to run on a ibm pc from like 1987 or something.

    • @uooooooooh
      @uooooooooh 8 місяців тому +1

      @@PedroBastozz Simply having a CLI says nothing about what you're I'ing with.

    • @PedroBastozz
      @PedroBastozz 8 місяців тому

      @@uooooooooh Having a cli is normal. You should definitely have a terminal app. Not having a GUI is just simply not an option. It wasn’t an option 20 years ago and it certainly isn’t today.

  • @dark-ghost4132
    @dark-ghost4132 8 місяців тому

    Nice ❤❤

  • @aleksamrda
    @aleksamrda 8 місяців тому

    Cool video :)

  • @arghyaprotimhalder5592
    @arghyaprotimhalder5592 8 місяців тому

    Debian runs literally on anything
    1GB ram naaa 512 GB ram debian no issues I can run .

  • @ChandrashekarCN
    @ChandrashekarCN 8 місяців тому

    💖💖💖💖

  • @akurasubject9617
    @akurasubject9617 3 місяці тому

    DOS with only 64kb of ram: Amatures!

  • @dv_xl
    @dv_xl 8 місяців тому

    Cool

  • @madmax404
    @madmax404 8 місяців тому

    cool beans

  • @attilapal3786
    @attilapal3786 8 місяців тому

    Double like!

  • @supercellex4D
    @supercellex4D 8 місяців тому

    Yeah well DOS can boot in less than 640k, so Microsoft still won

    • @CtrlAltFumble
      @CtrlAltFumble 8 місяців тому

      Can't even compare DOS w/ Linux. DOS does 5% of a basic GNU/Linux kernel/userland environment, it does not even has it's own network stack.

    • @supercellex4D
      @supercellex4D 8 місяців тому

      @@CtrlAltFumble Society has had a network stack for ages - it’s called the market
      Just get a floppy disk

    • @tigrankhachatryan6119
      @tigrankhachatryan6119 8 місяців тому

      DOS doesn't work with present-day software and hardware. So no.

  • @UltimatePerfection
    @UltimatePerfection 8 місяців тому

    Now let's see what happens if you boot Windows 10 with low memory... oh right, it's completely useless.

    • @nirlichtman
      @nirlichtman  8 місяців тому +2

      I actually just tried Windows XP and to my surprise it booted and was somewhat usable with 32MB, but 16MB already caused a BSOD on boot.

    • @UltimatePerfection
      @UltimatePerfection 8 місяців тому

      @@nirlichtman Yeah, but I am talking about modern (still supported) Windows.

  • @rasputindasilva858
    @rasputindasilva858 8 місяців тому +2

    Linux sucks.

    • @mrkubax10
      @mrkubax10 8 місяців тому +8

      Just like you

    • @shlokbhakta2893
      @shlokbhakta2893 8 місяців тому +7

      Skill issue lol

    • @Liphi
      @Liphi 8 місяців тому +2

      fr, too bloated

    • @xtan-io
      @xtan-io 8 місяців тому +1

      Skill issue

    • @CtrlAltFumble
      @CtrlAltFumble 8 місяців тому +1

      Skill issues

  • @xtan-io
    @xtan-io 8 місяців тому

    Really cool 😮