Results 1 to 10 of 10

Thread: Is it possible to have a swap file on another hard drive other than the OS disk

  1. #1
    Join Date
    Oct 2020
    Beans
    3

    Is it possible to have a swap file on another hard drive other than the OS disk

    Hi!


    I am more or less a beginner in Ubuntu.
    I am in the process of setting up an Ubuntu 18.04 server where I want a swap file on another hard drive one where Ubuntu is installed on.
    The Ubuntu server will be installed on a Kingston A400 240GB disk and swap file on a Seagate FireCuda 520 SSD 2TB M.2 NVMe and intends to use the entire nvme disk as a swap file if possible.
    I wonder if it is possible to do as I have thought or not.
    Have googled but can not find what I am looking for. Probably me who does not search for the right word.
    If there is anyone who can tell me how to do it or refer to the link to the website, I would be super happy.


    Please


    Sharkey97

  2. #2
    Join Date
    May 2013
    Location
    Galiza
    Beans
    2,941
    Distro
    Ubuntu

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Yes, the swap partition can be anywhere, a swapfile can't.
    You can use a partition instead but why do you think you need so much swap anyway?

  3. #3
    Join Date
    Aug 2011
    Location
    51.8° N 5.8° E
    Beans
    5,547
    Distro
    Xubuntu 20.04 Focal Fossa

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    A swap partition can be on any device you want. I think a swapfile can be anywhere you want in your filesystem, but giving a device a filesystem for the sole purpose of making a swapfile there seems needlessly complicated.

    Why do you think you need 500 times more swap space than everybody else?

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

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Swap size is connected to the amount of memory in the machine. It is when the system begins to run out of available memory that the OS has to start paging data out of memory and on to a disc.

    Tradition says swap space should be twice the size of memory. That came from the days when memory costs were very high and amounts of memory were very low. With large amounts of memory available at almost reasonable prices if we followed tradition we have have an excessively large swap space that might never be used.

    Which is why Ubuntu has moved from a swap partition to a swap file which expands and shrinks as necessary. It seems that it is possible to have a swap file on a separate disc to the operating system

    https://askubuntu.com/questions/1072...on-of-swapfile

    https://serverfault.com/questions/27...-the-swap-file

    Regards
    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


  5. #5
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,612
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Quote Originally Posted by sharkey97 View Post
    and swap file on a Seagate FireCuda 520 SSD 2TB M.2 NVMe and intends to use the entire nvme disk as a swap file if possible.
    Why so much swap??

    One of the bigger single Linux servers I was in charge of during my career was a machine with 64 x CPU cores and 512 GB of RAM and even there the swap was only 128 GB. If at 512 GB of RAM you have to swap more than 128 GB then something is very seriously wrong anyway and no amount of swap space could fix that.

    It's your server, sure, but you're wasting 2 TB of space if you use all that just for swap. Chances are it will never even be used once.

  6. #6
    Join Date
    Mar 2007
    Beans
    745

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    To do what you want use gparted to partition the drive you want to use for swap and set the partition to swap then edit fstab to mount the swap partition on boot.
    As everyone else asked why to you want so much swap?

  7. #7
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    21,702
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Well, as others have said, you can setup lots of swap if you like, but that makes me curious why?
    Within the last 6 months, there was a long thread about swap sizing in these forums with lots of opinions.

    If you are running VMs for clients and want to encourage them to pay for higher-priced plans, then what you intend seems like a reasonable plan. I suspect a hugely popular, well-advertised, domain registrar company does this for all their advertised plans.

    Typically, the point of swap is to provide users with a "slow" feeling for the interface, so they get some indication that the machine is beyond current capabilities. So, with that in mind, using slow swap would provide that feedback better. You could put it on a USB2 HDD to help slow it down.

    For all my desktops, I provide 4.1G of swap.
    For all my servers, I strive to have 0 swap, since RAM is pretty cheap and managing workloads isn't hard.

    Of course, only you know the real reason. It would be interesting to discover if over 2TB of swap causes issues or not. I bet wikipedia has the answer for any size limitations. https://askubuntu.com/questions/1041...e-can-function Looks like 16TB for 1 swap area and up to 32 areas are allowed. Go for it!

  8. #8
    Join Date
    Oct 2020
    Beans
    3

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Oopppsss ...
    Totally forgot my message.
    Many thanks for the reply.
    Question!
    Purely performance wise.
    What is best to have the swap file on?
    A custom hard drive that is a 2TB M.2 NVMe or to put the swap file on the same disk as the OS "Ubuntu Server" and in that case on a 2TB M.2 NVMe.
    Or does it not matter performance in terms of having Ubuntu Server on an SSD disk and the swap file on 2TB M.2 NVMe?
    It should be added that the server should be for a filcoin mining machine that requires a lot of RAM.

  9. #9
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Thread moved to Server Platforms.

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    21,702
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Is it possible to have a swap file on another hard drive other than the OS disk

    Quote Originally Posted by TheFu View Post
    Typically, the point of swap is to provide users with a "slow" feeling for the interface, so they get some indication that the machine is beyond current capabilities. So, with that in mind, using slow swap would provide that feedback better. You could put it on a USB2 HDD to help slow it down.
    Perhaps you missed this above? Swap is there to provide feedback. You don't want to put it onto fast storage or the users won't "feel" the system getting slower before all the virtual memory is used up and the system crashes. If you want fast performance, never let real RAM get used it. RAM is relatively cheap. Buy more. I know ZERO, nothing, nada, about mining on computers. We have to pay for electricity here.

    I'm not a fan of using swap files. I prefer using a swap LV managed by LVM. This is much more flexible than a swap partition, but keeps the swap out of a file system and that overhead.
    Last edited by TheFu; 2 Weeks Ago at 08:38 PM.

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
  •