LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-13-2021, 05:33 PM   #1
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 117

Rep: Reputation: Disabled
Practical questions for having /tmp and /var on same partition


Hi.

I just installed MX Linux onto a computer, and tough the installer does provide an option to have separate / /root /home and swap partitions, it does not natively offer the user to specify partitions to put /var and /temp.

Therefore, I have set aside 25BG free space for this purpose. I also want to put /var and /tmp on same one partition.

On this page - unix.stackexchange.com/../why-put-things-other-than-home-to-a-separate-partition it says:
Quote:
var and /tmp can be filled up by user programs or daemons. Therefore it can be safe to have these in separate partitions that would prevent /, the root partition, to be 100% full, and would hit your system badly. To avoid having two distinct partitions for these, it is not uncommon to see /tmp being a symlink to /var/tmp.
The first practical question - what steps are necessary to do this? According to last post in this askubuntu forum thread:
Quote:
if you provide an existing directory instead of the link name, ln will create a link inside that directory
I've made symlinks before, but this confuses me.


Thanks in advance
 
Old 01-13-2021, 06:42 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
You will probably have to do these steps from a rescue DVD. If you try them on a live system the system will probably crash part way through the rearrangement.

Format the new partition.

Move the contents of /var to the new partition leaving /var as an empty directory on /.

change /etc/fstab to mount the new partition on /var

delete /tmp on / and recreate /tmp on / as a symbolic link to /var/tmp

The only possible problem I see with what you are attempting is if the boot process uses /tmp before /var is mounted through /etc/fstab. I don't think that is what actually happens so I think it should work.

--------------------------
Steve Stites

Last edited by jailbait; 01-13-2021 at 06:43 PM. Reason: format
 
1 members found this post helpful.
Old 01-13-2021, 06:56 PM   #3
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 117

Original Poster
Rep: Reputation: Disabled
Thanks a lot #jailbait, that make sense. See if I got time to test this tomorrow.

If it get problems with this, it's a newly OS installed so not much time wasted anyway.
 
Old 01-13-2021, 08:15 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,345
Blog Entries: 28

Rep: Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145
The practice of putting /var and /tmp on separate partitions dates back through the mists of time when hard drives were still relatively new and extremely small. With today's hard drives, it should not be necessary.

I common allocate 25-30GB for my root partition, which contains everything except /home, and have never experienced any issues related the /var and /tmp. (Before I started doing that, I would have just one root partition containing everything, and also never encountered any issues.)
 
Old 01-14-2021, 03:16 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,806

Rep: Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207
Quote:
The only possible problem I see with what you are attempting is if the boot process uses /tmp before /var is mounted through /etc/fstab. I don't think that is what actually happens so I think it should work.
Good point!
systemd places files in /tmp
If these are overmounted, it might misbehave.

EDIT
I think it uses the /tmp later, not before mounting, so it is likely not a real problem.

Last edited by MadeInGermany; 01-14-2021 at 03:19 AM.
 
Old 01-14-2021, 10:55 AM   #6
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,143

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
Quote:
Originally Posted by MadeInGermany View Post
I think it uses the /tmp later, not before mounting, so it is likely not a real problem.
The new idea is to use /run.

Putting /tmp and /var on their own partition(s) is only useful for servers. There a lot of users may create a lot of data on /tmp, while databases typically make use of /var to keep track of things.
 
Old 01-15-2021, 01:42 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
FWIW, /tmp is a tmpfs (aka RAM disk) on my system.
Major distros seem to disagree about what exactly /tmp should be, but I think that's the right way.
There's more:
Code:
$> grep -w tmpfs /etc/mtab
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,size=3538532k,nr_inodes=409600 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=707704k,nr_inodes=176926,mode=700,uid=1000,gid=1000 0 0
 
Old 01-16-2021, 12:22 AM   #8
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
FWIW, /tmp is a tmpfs (aka RAM disk) on my system.
tmpfs, AKA “a symlink to /dev/shm” or just any kind of ramdisk for temporary data should be a natural choice. I do not know if my use of the temp-directory qualifies me as a security-freak. But knowing that wiping RAM is quite different from wiping a hard-disk has its charms. – Knowing that not doing anything at all is enough for a RAM-disk, too.

Last edited by Michael Uplawski; 01-16-2021 at 12:25 AM.
 
Old 03-30-2021, 11:33 AM   #9
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 117

Original Poster
Rep: Reputation: Disabled
Thumbs down

Ok - I've made an attempt, this is as far I got:
  • I moved the contents of the old /var and /tmp to the new location.
  • I've made a symlink to the new locations (/sda/mx_var/ and /sda/mx_tmp/ ) (not sure if I should have used "/dev" before).

However the editing of /etc/fstab file I don't know how to proceed further from this. From what I read, fstab can only deal with volumes and not folders within.

As it sits now, the system are not able to boot (see screenshot of the boot error messages)

attempt 1 : the symlinks does not include "/dev" (probably wrong anyway)
attempt 2 : the symlinks does include "/dev" --> "dev/sda5/mx_var/"
So far, the /etc/fstab file are not changed in any way.
Attached Thumbnails
Click image for larger version

Name:	attempt1 boot-error.jpg
Views:	19
Size:	47.6 KB
ID:	35963   Click image for larger version

Name:	attempt2 boot-error.jpg
Views:	15
Size:	61.5 KB
ID:	35964  
 
Old 03-30-2021, 11:46 AM   #10
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid/RPIOS
Posts: 4,887
Blog Entries: 28

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Why not just put /var in tmpfs?

Code:
*grep -w tmpfs /etc/mtab
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
tmpfs /var/spool tmpfs rw,noatime 0 0
tmpfs /var/tmp tmpfs rw,noatime 0 0
tmpfs /tmp tmpfs rw,noatime 0 0
tmpfs /var/log tmpfs rw,noatime,mode=755 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=388636k,mode=700,uid=1000,gid=1000 0 0
My /etc/fstab
Code:
*cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=66b4c1cf-01  /boot           vfat    defaults          0       2
PARTUUID=66b4c1cf-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
# Added 4 lines to use RAM instead of SSD for temp and log files
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
 
Old 03-30-2021, 11:55 AM   #11
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,614
Blog Entries: 19

Rep: Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460
I wouldn't do it with symlinks. I'd just have empty /var and /tmp directories on the root partition and put them into fstab as mountpoints. In most modern distros /tmp is empty anyway and a tmpfs (ramdisk) is mounted there.

re your query about unnamed symlinks:
Quote:
if you provide an existing directory instead of the link name, ln will create a link inside that directory
In creating a symbolic link, the target always comes first, then the link name. If no link name is given, the name will be the same as the target file. Obviously this will not work if you simply type
Code:
ln -s target .
because you can't have two files of the same name in the same directory. However:
Code:
ln -s target /other_directory
will work. It will create a link at /other_directory/target.

Your images show a successful boot though some daemons have failed. The acpi errors are not serious. It might be worth logging in and exploring the system to find out what the /var and /tmp directories actually contain.

Last edited by hazel; 03-30-2021 at 11:57 AM.
 
Old 03-30-2021, 12:05 PM   #12
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 117

Original Poster
Rep: Reputation: Disabled
Post

Thanks @craigevil

Yep - tempfs is an alternative.

However, If I stuck to the plan and have to use fstab, the issue is that the first column of fstab file cannot point to a folder within any partition/volume.
 
Old 03-30-2021, 12:14 PM   #13
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
The whole /var in tmpfs is not a good idea, many setups use data stored there, must survive reboot. First column can have directories, use bind mount for those.
 
Old 03-30-2021, 12:15 PM   #14
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,614
Blog Entries: 19

Rep: Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460Reputation: 4460
Quote:
Originally Posted by Grobe View Post
However, If I stuck to the plan and have to use fstab, the issue is that the first column of fstab file cannot point to a folder within any partition/volume.
So don't use a folder. Make a partition of a suitable size for your /var contents and use that, mounting it on the empty /var directory. As Emerson pointed out, there are important databases stored here so you want it to be permanent.

And set up /tmp as a tmpfs if it isn't that way already.

Last edited by hazel; 03-30-2021 at 12:37 PM.
 
Old 03-31-2021, 01:54 PM   #15
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 117

Original Poster
Rep: Reputation: Disabled
Cool

Ok, so I ended up no being able to restore the MX desktop, despite attempting to copy the contents of /var back again (created the /tmp and /var folder and copied back it's content in order to try to fix the MX desktop issue).

But - no problem, it's a test setup for this purpose anyway.

So for now - lessons learned as following:
  • tempfs are probably the way to go regarding /tmp
  • If /var is removed manually, it may be very hard or impossible to make it work again (for a beginner like me at least). Maybe a workaround here would be to just rename the /var folder and when renamed back it's al good - or maybe the system does something when it doesn't find/accept /var that screw up the desktop regardless to wether I restore it back or not.
  • The original goal of making /tmp and /var physically located in same partition seems impossible at this moment.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it practical to mount swap /var and /tmp on a fast SD card to save the SSD? FiftyOneFifty Linux - Desktop 5 02-10-2012 09:20 PM
mount /home, /var and /tmp to the same partition Kwahab Linux - Software 7 10-14-2009 01:14 AM
how to securing /tmp , /var/tmp and /dev/shm hackintosh Linux - Security 7 10-17-2007 11:26 PM
kde, /tmp, /var/tmp and all that garba Linux - Software 4 06-17-2005 12:31 PM
Newbie question - /tmp /var/tmp Mr happy Linux - Security 3 01-27-2003 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration