If I want 8GB swap, am I supposed to select 8000MB or 8192MB when selecting size?
TL;DR: It does not really matter.
RAM is universally measured in powers of 2. This is often written as GiB, so 8GiB is 8*1024=8192MiB RAM.
If you look at physical RAM chips they'll always come in powers of two, e.g. 1024MiB, 2048, 16384MiB etc.
Hard drives are typically measured in powers of ten, using SI prefixes, for instance, 80GB = 80*1000MB.
So 8GiB of RAM is 8192MiB of RAM. For swap, you typically want a swap space that is big enough to hold all of RAM for suspension, so 8192MiB would be the safe option. Note that it really doesn't matter, as Linux will almost never use 100% of RAM anyway; a lot will be used for caching and so on, which will not be saved when you hibernate.
Related videos on Youtube
Mason
Updated on September 18, 2022Comments
-
Mason over 1 year
When selecting the partition to use manually, you can enter the size of the partition. So my question is, if I want 8GB swap size for my 8GB ram (yes I know the FAQs about the size of the swap etc) , am I supposed to select 8000MB as in 1GB = 1000MB or 8192 as in 1GB = 1024MB?
-
Admin over 6 yearsI do not think you are going to see much difference between those options. If you have the space go slightly larger.
-
Admin over 6 yearsMy question is just if 8000MB is enough for my RAM of 8GB or if I have to enter 8129 to "fully" support the size of my RAM
-
Admin over 6 yearsDoesn't make a notable difference. For a home computer probably even 4 or 2 GB would be enough.
-
Admin over 6 yearsOr do you want to enable hibernating?
-
Admin over 6 years8000 will be enough even for hibernating.
-
Admin over 6 yearsThe 8000 vs 8192 involves two different measurements of bits. The binary form is XiB, with X being a size (K, M, G, T, etc), and each size being the previous * 1024, thus 8192MiB for 8GiB. Decimal is the same, but each size is the previous * 1000, and is expressed in _B instead of _iB. If your computer reports 8GiB of RAM in a terminal, do 8192MiB. If it reports some other odd number, do 7629MiB.
-
Admin over 6 years@firefaced this looks like an answer to me...
-
Admin over 6 yearsIt depends how your system are counting your RAM, If it is a labtop, and you want to be able to hibernate - choose the larger one! If not and it is not a server try looking at the Swap usage in top, - - if you often are using more than 4GB of your swap go for 10 or 12 GB, else you can probably get quite good results with only 4 to 6 GB..
-
Admin over 6 yearsIt depends whether you want 8000MB or 8192MB of swap.
-
Admin over 6 yearsUbuntu and the whole Linux world has fortunately gotten pretty thorough in distinguishing between SI prefixes and binary prefixes. If a Linux tool writes 8 GB you can be relatively certain that it really is 8*1000 MB, otherwise they’d write 8 GiB. The “8 GB” on the package of your RAM is probably 8 GiB (i.e. 8*1024 MiB) though.
-
Admin over 6 yearsPeople still use swap??
-
Admin over 6 years@chx: Ubuntu still defaults, and still has the 1970's rule of 1:1. Surprised me last week when it decided to create a 66 GB swap partition on my 240 GB SSD - the whole point of getting 64 GB RAM was to avoid swapping.
-
Admin over 6 years@MSalters that's a good point. But Linux used to behave quite unstably if you don't have any swap at all — like invoking OOMK every now and then even when you have plenty of free RAM. At least I observed this about 5 years ago. They might have fixed it by now, but I try to avoid this configuration after that.
-
Admin over 6 years
-
-
Alexis Wilke over 6 yearsThere are also hardware reasons for some of the RAM to get used up. The first Kb of data, tables used for the MMU, also we could include the Kernel, etc.
-
MSalters over 6 years8192 MiB is rather unhelpful. Yes, 8 GiB is 8192 MiB, but harddisks don't use GiB or MiB. 8 GiB is 8590 MB.
-
vidarlo over 6 yearsHard drive vendors do not use MiB, but software most commonly does.
-
hvd over 6 years@vidarlo From my experience, software most commonly still does not.
df -h
anddu -h
useG
. Nautilus/Caja (GNOME/MATE) usesGB
. MS Windows usesGB
too, FWIW. But there certainly is software that does useGiB
too, such as Dolphin (KDE) andncdu
. -
Admin over 6 yearsI really wish they hadn't confused things by introducing gibibytes and redefining gigabytes.
-
12431234123412341234123 over 6 years@hvd windows use GiB but write GB.
-
hvd over 6 years@12431234123412341234123 Good point and Windows isn't alone in that, that's the bit that's missing from this answer and the comment I responded to.
-
MSalters over 6 yearsThe Linux weirdness comes from mixing SI prefixes with non-SI units (Formally, SI measures information/entropy in Joules but expressing a harddisk size in attoJoules is even less helpful). The very first memory chips were 4 kilobits, i.e. 4096 bits, not 4000, and that convention stuck until HD vendors looked for an excuse to boost their numbers. Things do get weird with modem speeds, which at a certain point were measured in kilobits/second (i.e a non-SI unit divided by an SI unit).
-
vidarlo over 6 yearskilobits per second is actually 1000 bits per second. Kilobytes per second, on the other hand, is 1024 bytes per second... :)
-
pabouk - Ukraine stay strong over 6 yearsThe statement "Linux will almost never use 100% of RAM anyway" is misleading because this fact does not have much to do with the problem being solved here. --- Linux uses virtual memory which means that the running applications can use more memory than what is actually available as physical RAM. Not all of this memory needs to be stored to the swap when we are freeing RAM but it could easily happen that the amount which has to be stored to the swap will higher than the size of the physical RAM.
-
pabouk - Ukraine stay strong over 6 yearsIn fact for 8 GiB of RAM and hibernation function: Ubuntu recommends 11 GiB of swap while Red Hat recommends 12 - 16 GiB of swap. --- See help.ubuntu.com/community/SwapFaq#How_much_swap_do_I_need.3F and access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/… --- Note that even with 16 GiB of swap it could (normally very unlikely) happen that you will not be able to hibernate because of insufficient swap size. Keep on mind that there is almost 24 GiB of virtual memory.