Results 1 to 8 of 8

Thread: Size of swap directory

  1. #1
    Join Date
    May 2014
    Beans
    36
    Distro
    Ubuntu 20.04 Focal Fossa

    Question Size of swap directory

    Hi, I'm about to do an install of ubuntu onto a laptop with 64gb ram. I am using the (almost)-full disk encryption method specified here:

    https://help.ubuntu.com/community/Fu...ion_Howto_2019

    Regarding size of the swap space, the guide indicates:

    I am also creating a 4GiB LV device for swap which, as well as being used to provide additional memory pages when free RAM space is low, is used to store a hibernation image of memory so the system can be completely powered off and can resume all applications where they left off. The size of the swap space to support hibernation should be equal to the amount of RAM the PC has now or is is expected to have in the future.
    For this device (which will have a 2TB M.2 flash drive for storage, so swap can be big), I am wondering how large to make the swap space. I would like to use the hibernation feature.

    Since the machine will have 64gb, according to the guide swap should be 64gb. However, what if the swap space is already being used for something else? I plan to run several VMs simultaneously which is why the machine needs 64gb ram. Maybe swap should actually be 70 gb, in case 6 gb of swap are being used for other things, plus I hibernate?

    Also I would hesitate to make the swap space exactly 64GB as these days, there could be differences in how a "GB" is calculated that I fear might lead to it being slightly smaller than the actual amount of ram, even if both "Swap" and "RAM" are nominally 64 in the category of "GB", or maybe some overhead is needed on top of the actual memory in RAM, who knows, seems like it would be prudent to pad it just a little bit to be sure.

    Any tips?

    Thanks

  2. #2
    Join Date
    Jun 2020
    Beans
    38

    Re: Size of swap directory

    laptop with 64gb ram


    from what iv'e gathered reading through numerous posts,is that it is advisable not to create a swap partition manually.
    just do the install and let it create the swap automatically.

    EDIT:scratch that , only see now you mention "I would like to use the hibernation feature." and "I plan to run several VMs simultaneously"

    note to self...read posts properly before jumping on..
    Last edited by 3nd; June 14th, 2020 at 08:44 AM.
    xubuntu 20.04 LTS (focal fossa)

  3. #3
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    469
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: Size of swap directory

    Your swap partition should be a bit larger than your RAM.
    But ask yourself if you really need this feature. If you need to preserve the machine state indefinitely, go ahead. But be aware that a resume from hibernate takes longer than a cold boot.

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    20,527
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Size of swap directory

    Don't use hibernation if you use whole drive encryption. it drastically reduces the security.

    i use standby for days with my laptop, but never when it gets moved. During movement, the system is completely off, for security reasons. Data encrypted at rest. i figured I’d not be able to predict a car accident or a random theft walking between buildings on a college campus.

  5. #5
    Join Date
    May 2014
    Beans
    36
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Size of swap directory

    Quote Originally Posted by TheFu View Post
    Don't use hibernation if you use whole drive encryption. it drastically reduces the security.

    i use standby for days with my laptop, but never when it gets moved. During movement, the system is completely off, for security reasons. Data encrypted at rest. i figured I’d not be able to predict a car accident or a random theft walking between buildings on a college campus.
    I don't really need hibernation, I just have historically used it in the past. Not a big deal to give it up.

    But, if the swap area is encrypted, how does hibernation reduce system security? When you say it reduces security, are you assuming the swap area is unencrypted?

  6. #6
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Size of swap directory

    The evidence is hard to find but I remember talk of Ubuntu switching to swap files instead of swap partitions for new installations of Ubuntu. An already existing installation that is using a swap partition when upgrade to the latest Ubuntu will continue using a swap partition.

    My install of 18.04 upgraded from 16.04 has this;

    graham@sdb1-sdb8:~$ sudo swapon --show
    [sudo] password for graham:
    NAME TYPE SIZE USED PRIO
    /dev/sdb5 partition 2G 23.3M -2
    The swap partition size of 2GB is twice the RAM that I had in this machine when I first installed this Ubuntu. I now have 4 GB RAM.

    I will edit this post in a few minutes after I have run that command on a 20.10 install upgraded from 20.04

    Edit: @CatKiller. Thanks.

    My 3 Ubuntu installs are all using the swap partition.

    Regards.
    Last edited by grahammechanical; June 15th, 2020 at 12:49 AM.
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  7. #7
    Join Date
    Jan 2006
    Location
    Sunny Southend-on-Sea
    Beans
    7,835
    Distro
    Kubuntu 18.04 Bionic Beaver

    Re: Size of swap directory

    Quote Originally Posted by grahammechanical View Post
    The evidence is hard to find but I remember talk of Ubuntu switching to swap files instead of swap partitions for new installations of Ubuntu.
    https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes

    Other base system changes since 16.04 LTS

    For new installs, a swap file will be used by default instead of a swap partition.

  8. #8
    Join Date
    May 2014
    Beans
    36
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Size of swap directory

    Here's some screenshots and an excerpt from the install guide I linked to, which I will be following with my new install coming up. In this setup, two encrypted partitions containing encrypted volume groups are created. One contains /boot. The other contains the swap area, and the root file system.

    So the swap area is encrypted in this setup.

    /dev/mapper/ is the path to encrypted volumes that are created within

    code creating the encrypted root and swap area:

    Code:
    # pvcreate /dev/mapper/${DM}5_crypt
      Physical volume "/dev/mapper/sda5_crypt" successfully created.
    # vgcreate ubuntu-vg /dev/mapper/${DM}5_crypt
      Volume group "ubuntu-vg" successfully created
    # lvcreate -L 4G -n swap_1 ubuntu-vg
      Logical volume "swap_1" created.
    # lvcreate -l 80%FREE -n root ubuntu-vg
      Logical volume "root" created.


    Last edited by Ranbunta_Bantubunt; June 15th, 2020 at 04:17 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •