<SOLVED> Move temp tmp folder and swap file to a different drive
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
<SOLVED> Move temp tmp folder and swap file to a different drive
Hi forum,
My main motivation is to move certain things to a spinning disk HDD
in order reduce read/write operations to the main OS linux mint SSD drive.
Is there a way to:
1. move the 'tmp' folder to a different drive.
2. move swap file to a different drive.
3. Any other heavy read/write locations / folders / files I should know of? And if so, is there a way to move those to a different drive?
Thanks!
My main motivation is to move certain things to a spinning disk HDD
in order reduce read/write operations to the main OS linux mint SSD drive.
Is there a way to:
1. move the 'tmp' folder to a different drive.
2. move swap file to a different drive.
3. Any other heavy read/write locations / folders / files I should know of? And if so, is there a way to move those to a different drive?
Thanks!
Last edited by LockBot on Sun Feb 12, 2023 11:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
- Pjotr
- Level 23
- Posts: 19886
- Joined: Mon Mar 07, 2011 10:18 am
- Location: The Netherlands (Holland) 🇳🇱
- Contact:
Re: Move temp tmp folder and swap file to a different drive
I doubt whether that's a good idea. This might cause slowdowns because of the lesser speed of the spinner.
Instead, I recommend to reduce swappiness (making it being used less often) and perhaps to move some temporary files into the RAM. See:
https://easylinuxtipsproject.blogspot.c ... -mint.html
Instead, I recommend to reduce swappiness (making it being used less often) and perhaps to move some temporary files into the RAM. See:
https://easylinuxtipsproject.blogspot.c ... -mint.html
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Re: Move temp tmp folder and swap file to a different drive
This is no longer an issue for SSDs, their life expectancy is at least as good as an HDD if not better. You don't need to do anything.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Re: Move temp tmp folder and swap file to a different drive
As AndyMH said.
from https://www.easeus.com/storage-media-re ... espan.html, there exist countless others.The lifespan of an SSD is significantly longer than that of an HDD. While HDDs tend to last around 3-5 years, SSDs can last up to 10 years or more. This is because SSDs have no moving parts, whereas HDDs have spinning disks that can wear down over time.
Re: Move temp tmp folder and swap file to a different drive
You do not mention the SSD or the machine. If the SSD is a good brand and less than about 5 years old, the only problem is heat build up from continuous writes. That is a rare problem with desktops and a good heatsink.
In my notebook, the first SSD has cooling vents and the second does not. I never have heat problems with the main SSD. The second SSD often slows down due to heat. I am removing the second SSD and will double the size of the first SSD.
If you do not have heat roadblocks, I doubt paging or temp could break a modern SSD in less than 10 years. That only happens in servers running 24/7 and after many years.
Writes can be slow if you work on big video files. You might want to reduce writes by moving the tmp into ram, as mentioned in another post. How much memory do you have?
In my notebook, the first SSD has cooling vents and the second does not. I never have heat problems with the main SSD. The second SSD often slows down due to heat. I am removing the second SSD and will double the size of the first SSD.
If you do not have heat roadblocks, I doubt paging or temp could break a modern SSD in less than 10 years. That only happens in servers running 24/7 and after many years.
Writes can be slow if you work on big video files. You might want to reduce writes by moving the tmp into ram, as mentioned in another post. How much memory do you have?
Re: Move temp tmp folder and swap file to a different drive
I also want to chime in here to say SSDs (at least modern ones) usually no longer need constant babysitting to avoid unnecessary writes. You'd have to repeatedly seriously hammer an SSD for it to be a problem. That being said, I get the need to tweak and tinker, so have at it, just know that it's likely going to make a negligible difference. Anecdotally speaking, I have used the same old 128G SSD as my main OS drive for around a decade, with Linux and once upon a time with Windows, through many reinstalls and software changes; it still seems as good as it was when I got it, and it was second hand at the time!
If you have a swap file, you'll need to recreate one where you want, enable it, then update '/etc/fstab' to make it and its new location permanent. There are guides for this out the wazoo on here and elsewhere online, so have a quick search with your favorite search engine. As for moving '/tmp', it's doable, but a bad idea, because some software assumes it's '/tmp' and not elsewhere. Moving it would be a case of setting up a separate partition for it, once again involving '/etc/fstab' and some more advanced knowledge. There'll probably be guides for all that, too.
As others have suggested, if you have enough RAM, I recommend using TMPFS for '/tmp', to store '/tmp' stuff into RAM, but as you have an SSD, there's not too much point in it. I have an SSD with a 6G TMPFS (and 14G of total RAM) for '/tmp' set up, but I'll begrudgingly admit that it's unnecessary. Here's my '/etc/fstab' entry for that:
Feel free to use it, although it is more restrictive than it ordinarily is, due to how I have my system set up, but it should be usable. That's for 6G, so just edit accordingly.
If you have a swap file, you'll need to recreate one where you want, enable it, then update '/etc/fstab' to make it and its new location permanent. There are guides for this out the wazoo on here and elsewhere online, so have a quick search with your favorite search engine. As for moving '/tmp', it's doable, but a bad idea, because some software assumes it's '/tmp' and not elsewhere. Moving it would be a case of setting up a separate partition for it, once again involving '/etc/fstab' and some more advanced knowledge. There'll probably be guides for all that, too.
As others have suggested, if you have enough RAM, I recommend using TMPFS for '/tmp', to store '/tmp' stuff into RAM, but as you have an SSD, there's not too much point in it. I have an SSD with a 6G TMPFS (and 14G of total RAM) for '/tmp' set up, but I'll begrudgingly admit that it's unnecessary. Here's my '/etc/fstab' entry for that:
Code: Select all
none /tmp tmpfs mode=1777,nodev,nosuid,size=6G,relatime 0 0
I'm also Terminalforlife on GitHub.
Re: Move temp tmp folder and swap file to a different drive
I can see this sort fo thing for some users doing seriously high power things like heavy duty NLE use, which is going to generate big temp files. But for the vast majority of us, no, not really.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
Re: Move temp tmp folder and swap file to a different drive
If this should really be judged as needed, it would be enough to create a new swap file, the old one gets automatically overwritten (just as any case of 2 files with the same name). Changing fstab is not needed in this case. But the file should get in any case chmoded, so that only root can read and write (sudo chmod 0600 /swapfile).
Re: Move temp tmp folder and swap file to a different drive
I have been using this for temp to ram:Termy wrote: ⤴Fri Aug 12, 2022 8:16 am
As others have suggested, if you have enough RAM, I recommend using TMPFS for '/tmp', to store '/tmp' stuff into RAM, but as you have an SSD, there's not too much point in it. I have an SSD with a 6G TMPFS (and 14G of total RAM) for '/tmp' set up, but I'll begrudgingly admit that it's unnecessary. Here's my '/etc/fstab' entry for that:
Feel free to use it, although it is more restrictive than it ordinarily is, due to how I have my system set up, but it should be usable. That's for 6G, so just edit accordingly.Code: Select all
none /tmp tmpfs mode=1777,nodev,nosuid,size=6G,relatime 0 0
sudo cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
sudo systemctl enable tmp.mount
How does using the fstab entry differ?
Everything in life was difficult before it became easy.
Re: Move temp tmp folder and swap file to a different drive
I've surprisingly never heard of that method, but from looking at the service file, I see it uses TMPFS and has an
Options
parameter, where you can specify various mount options for TMPFS.However, I couldn't find anything in the file regarding size. I assume you can provide the usual
size=
mount option to specific a size, but if you've not got the size of the RAM drive set, I'd be a little concerned, because the kernel documentation states that it defaults to half of your RAM.I have a separate '/boot' partition, a separate '/var' partition; a tweaked '/proc', '/run/shm', and '/dev/shm'; a tweaked separate '/home' partition, and of course the '/tmp' entry, so having all that in one place is a bonus for me, as it's simply far more convenient. If you already work with '/etc/fstab', then I'd just go ahead with my approach, but to each their own. I get the convenience of the service file already being present but disabled.
BTW, as the service file already exists, you should be able to forgo the copy and instead simply run:
Code: Select all
sudo systemctl enable --now tmp.mount
IIRC, SystemD does the copying anyway, so I think you essentially did the same thing twice, but take that with a pinch of salt, as I'm not familiar with the old way of enabling services, short of faffing about with OpenRC in Gentoo that one painful time, and hearing things from fellow nerds.
I'm also Terminalforlife on GitHub.
Re: Move temp tmp folder and swap file to a different drive
Thank you guys for all the replies,
I'll try to use the RAM disk instead
And basically not worry too much about SSDs, as suggested.
And thank you I'll try to tinker a bit with the ram tmp.
I'll try to use the RAM disk instead
And basically not worry too much about SSDs, as suggested.
Thanks yeh you're right I'll reduce swappiness, read that article you sent, quite interesting!Pjotr wrote: ⤴Fri Aug 12, 2022 6:18 am I doubt whether that's a good idea. This might cause slowdowns because of the lesser speed of the spinner.
Instead, I recommend to reduce swappiness (making it being used less often) and perhaps to move some temporary files into the RAM. See:
https://easylinuxtipsproject.blogspot.c ... -mint.html
I have 32GB RAM, and the SSD is modern not old, so I should probably leave it alone as suggested.
Wow, you've convinced me to never worry about SSDs ever againTermy wrote: ⤴Fri Aug 12, 2022 8:16 am I have used the same old 128G SSD as my main OS drive for around a decade, with Linux and once upon a time with Windows, through many reinstalls and software changes; it still seems as good as it was when I got it, and it was second hand at the time!
As others have suggested, if you have enough RAM, I recommend using TMPFS for '/tmp', to store '/tmp' stuff into RAM, but as you have an SSD, there's not too much point in it. I have an SSD with a 6G TMPFS (and 14G of total RAM) for '/tmp' set up, but I'll begrudgingly admit that it's unnecessary. Here's my '/etc/fstab' entry for that:
Code: Select all
none /tmp tmpfs mode=1777,nodev,nosuid,size=6G,relatime 0 0
And thank you I'll try to tinker a bit with the ram tmp.