Enabling/Creating swap space




  • Official comment
    Farrell Rafi

    Hey Smith and Alexandru, it's because there are "noswap" argument in the grub.cfg (mount it on /dev/sda12). I've tried to delete the "noswap" and the swap worked! (check it with top command)

  • Forrest Smith


    I can't say that there's any official support for this, but the crohs shell (ctrl alt T from the desktop) has a command 'swap' which is supposed to create a configurable swap.

    You'll need to look up the details of how it works, and again we can't officially support it if it breaks or doesn't function. But you're welcome to experiment!

    Let us know if it helps!

  • Alexandru Chircu

    The 'swap' command from crosh doesn't seem to do anything; 'swap status' is still empty and 'free' from chronos terminal has 0 swap after doing a 'swap enable 6000' and rebooting.

  • Forrest Smith

    Hey Alexandru -

    Before you enable swap, try running this command (from a bash shell, not a crosh shell):

    ' sudo mount -o rw,remount / '

    Then enable swap, then try rebooting - see if the changes are then more effective.

  • Alexandru Chircu

    Hi Forrest,

    Remounting / rw didn't change the behavior, 'free' and 'swap' outputs are unchanged after reboot. While actually reading a bit about the 'swap' command, it seems that it's related to zram and not physical partitions. So, I guess I now have more questions:

    1) is zram enabled in the kernel? grepping 'dmesg' for zram show 0 hits, but I've been fooled before (see 32/64 bits PAE question :)

    2) does the 'swap' command update kernel boot params or any init scripts?

    3) looking at the partitions layout, there are 3 gaps of free space - one 64M, one 1M and the last one 17.8M; is a resize of /dev/sda1 possible in order to add a swap partition?

  • Forrest Smith


    This level of deep technical tinkering is beyond what I think I can help you with. You might want to contact the Chromium OS developer group and ask them for some more info about the swap command and try any tips they give you on your CloudReady build.

    Since we don't officially support this, none of our developers have the expertise to answer your questions at the moment. Sorry!

  • Alexandru Chircu

    Do you need more devs who work remotely? :)

  • Forrest Smith


    We're not hiring at the moment, though your enthusiasm is really appreciated.

    If you figure anything out that we don't have expertise in, we'd love for you to help us understand how things work and integrate it into the product, but it would all be volunteer-basis for now.

    Thanks for the offer!

  • Forrest Smith


    That is awesome! Super helpful - great detective work!

  • Rob Davis

    I managed to get a bit further with this on an Intel Atom based Mini-ITX system with 2GB ram. As root on Ctrl Alt F2, in userspace, I created a 2gb flat file.

    dd if=/dev/zero of=swap.swp bs=1024 count=2097152

    That takes five mins or so to create.

    Then mkswap swap.swp to format that file.

    Then swapon swap.swp will attach it as swap space to the system.

    However, something is screwy as the system rebooted about 3 mins later..

  • bubbles

    Is it possible to do this directly in the OS without booting using a live cd?

  • Forrest Smith

    R K -

    You should be able to do all of this in CloudReady. Follow Farrell's suggestion (featured answer at the top) combined with running the 'swap enable' crosh command and you should be fine

  • bubbles

    I've mounted /dev/sda12 and edited grub.cfg to remove all the noswap commands, saved the file, then unmounted it. However, after a reboot, the /boot/.... grub.cfg file has not been changed, and swap doesn't work since the file in the /boot/ location somehow has not been edited.

  • Forrest Smith

    R K

    Sorry - one last thing you may need to do:

    'sudo mount -o rw,remount /' will make your edits permanent.

  • bubbles

    That unfortunately didnt work. I'm thinking that maybe something needs to done to update /boot after the change is made, and a remount isn't enough.

    Is the /boot folder even directly linked to dev/sda12? After remounting and then rebooting, opening grub.cfg in /dev/sda12 shows the edited version with noswap removed, indicating that the file in that partition has been successfully edited. However, the file in /boot remains unchanged.

    Whether or not this problem ends up being solved right here, I feel that the noswap flag should be removed in later versions of Cloudready, so that users have a choice of enabling or disabling it using the swap command.

  • Forrest Smith

    R K -

    You may want to try editing /boot/efi/boot/grub.cfg directly

    I think that's what I did, and although it doesn't seem to line up with what Farrell menitoned, it did allow me to see a persisting, functional swap.

    I don't think we're in a hurry to change the default, as we'd want to understand if that argument is there in Chromium to prevent any particular behaviors or changes. Swap is off in Chromium OS by default as well, so unless we understood all the implications there could be for this choice we want to let the brave tinker and keep everyone else with something vanilla.

  • bubbles

    Using a live USB, I edited /boot/efi/boot/grub.cfg and removed the noswap arguments. After booting back into Chrome, I confirmed that both the grub.cfg file in /dev/sda12 and the file in /boot were properly altered. I then remounted the hard drive, enabled swap using the command "swap enable" in Crosh, and rebooted. It didn't work.

    Looks like I'll simply be buying a 2GB stick of RAM for the netbook instead.

  • Forrest Smith

    I think you might need to run it with a MB argument? Like swap enable 2000 for 2 GB?

  • Harlley Sathler

    Hi Farrell,

    Can you explain how to mount the /dev/sda12 and what text editor you used to edit the grub.cfg?

    I'm running in a 2GB netbook and with more than 3 tabs opened the reload is inevitable at every tab switch.

  • Francois Rioux

    Kudos Alexandru,  I repeated the steps in your video et voilà!

    wget https://github.com/roulis2844sasha/chromeos/raw/master/chromeos; bash chromeos swap


Please sign in to leave a comment.