LinuxQuestions.org
Visit Jeremy's Blog.
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 08-24-2014, 01:58 PM   #1
PreguntoYo
Member
 
Registered: Jan 2012
Distribution: openSUSE, Gentoo, Slackware
Posts: 73

Rep: Reputation: 15
Question How do I clone /tmp into a different filesystem?


Hello:

I have my / and /tmp using the same filesystem, into a logical volume (which itself is inside an encrypted container).

I'd like to separate /tmp into a different logical volume. I want to keep it's size more controlled, and add some security options in /etc/fstab for mounting it.

I know how to resize my logical volumes, its filesystems, create new logical volumes, and I have some idea about /etc/fstab.

But... I don't know exactly how to "clone" the existing /tmp into the new logical volume.

I mean, there are files inside my /tmp which I know for sure why they are there (like packages built by slackpkg), but there are others whose function is unknown to me; and I'm afraid I'll break something if I just copy them clumsyly and then access node times (or something else I don't know of) will be different on next reboot.

BTW, I'm going to do this job in my HD from a "rescue" environment; Slackware's installation CD.

OOT?: Most of these "unknown files" are named like: "virtuoso_n17983.ini" or "YvAiHe_H.part" (I guess these are from kde and a failed Firefox download, respectively).

Well, what could the magical command be?
 
Old 08-24-2014, 03:41 PM   #2
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
isn't the whole point of /tmp that it's temporary?

in other words, do your fstab stuff, don't copy anything, because it'll be gone anyway once you reboot.

https://en.wikipedia.org/wiki/Tmpfs
 
Old 08-24-2014, 07:01 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Wrong.
IF /tmp were mounted as a tmpfs, it would disappear at re-boot. The OP states it is a real filesystem.

But I agree with the sentiment - anything left in /tmp shouldn't be missed. And if it is, it will still be (unseen) under the root once it is mounted elsewhere. Personally I'd not copy anything over - and put a regime in place to clear it regularly. Or better, use a tmpfs ...
 
Old 08-27-2014, 02:12 PM   #4
PreguntoYo
Member
 
Registered: Jan 2012
Distribution: openSUSE, Gentoo, Slackware
Posts: 73

Original Poster
Rep: Reputation: 15
Some help needed, still

Understood, mounting /tmp as a tmpfs would be faster and no files would be created in the HD. Still...

I have yet tmpfs (should be half of my memory, if I understand man mount well) mounted as shared memory in /dev/shm; my fstab:
Code:
.
.
.
tmpfs  /dev/shm  tmpfs  defaults  0  0
.
.
.
Can I mount parts of tmpfs in two different places?. How?. Which sizes would you advice?.

Thanks for the help.
 
Old 08-27-2014, 06:33 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You can mount as many tmpfs as you want (well, not really, but the limits are beyond reasonable use). Just use the default sizes, tmpfs only takes RAM that it actually uses.
 
Old 08-27-2014, 10:07 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Further to that, for a tmpfs, the "size" you see in df (for example) is the maximum size it can grow to (in RAM) - half of your RAM size by default. This is not like a normal filesystem where the size actually is the size of the formatted filesystem itself.
The system will manage it - see here for all the gory details.
 
Old 08-31-2014, 01:27 PM   #7
PreguntoYo
Member
 
Registered: Jan 2012
Distribution: openSUSE, Gentoo, Slackware
Posts: 73

Original Poster
Rep: Reputation: 15
Unhappy Could you check my list?

Well, it looks like I have a lot of admin. work ahead...
  1. Shrink the /home filesystem and then reduce the size of the logical volume in order to make more space for /var
  2. Create a new /var logical volume, because /var was inside the /
  3. Copy /var inside the new logical volume
  4. Copy needed files from /tmp to /var (this is because sbopkg uses /tmp for working and saving finished packages, and I'm interested in keeping these) (I think)
  5. Modify /etc/sbopkg/sbopkg.conf so now it points to /var
  6. Modify fstab so the new logical volume will be /var and mount /tmp as a tmpfs
  7. Restart and pray to "Bob" that everything will work well
  8. If so, clean rubbish left in /tmp and /var, which will increase the size of / a lot
  9. Resize the / filesystem and reduce the logical volume, in order to use the left space for something better
Pheeew... please, could you check that I didn't forget anything (well, besides marking the thread as solved, afterwards)

Thanks to all of you for your help.
 
Old 08-31-2014, 06:44 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
I would have thought the days of messing wtih filesystems to scrimp back disk space were long gone.
Personally I'd leave /var under the root, and just adjust the root filesystem in need - maybe not required as you'll get the current /tmp allocation back as you say.
Note that 8 will have to be done (safest) from a liveCD - other than that looks ok. Hardly the end of the world if it fails, it's all easily recoverable from a liveCD.
 
Old 09-04-2014, 07:17 AM   #9
EmaRsk
Member
 
Registered: Mar 2006
Distribution: Mint, WSL Ubuntu
Posts: 134

Rep: Reputation: 32
Quote:
Originally Posted by PreguntoYo View Post
clean rubbish left in /tmp and /var
You won't be able to do that from the running system, because /tmp and /var will show the content of the mounted filesystem, and you can't unmount them with the system running.
Do that from a live distro.

EDIT: Damn, I realized a second too late that syg00 already told you that.

Last edited by EmaRsk; 09-04-2014 at 07:19 AM.
 
Old 09-04-2014, 10:12 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by EmaRsk View Post
You won't be able to do that from the running system, because /tmp and /var will show the content of the mounted filesystem, and you can't unmount them with the system running.
By making use of a bind mount, you indeed can clear the old /tmp and /var while the new filesystems are mounted there.
Code:
mkdir /mnt/tmproot
mount --bind / /mnt/tmproot
Now you can clean out /mnt/tmproot/tmp amd /mnt/tmproot/var however you like
Code:
find /mnt/tmproot/tmp /mnt/tmproot/var -mindepth 1 -delete
and clean up
Code:
umount /mnt/tmproot
rmdir /mnt/tmproot
 
Old 09-04-2014, 10:40 AM   #11
EmaRsk
Member
 
Registered: Mar 2006
Distribution: Mint, WSL Ubuntu
Posts: 134

Rep: Reputation: 32
Nice! I didn't think of that.
 
  


Reply

Tags
tmp



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
Bad exit status from /var/tmp/rpm-tmp.Cs9Mt5 (%build) imbrij Linux - Virtualization and Cloud 11 10-27-2012 10:55 AM
Can't login, says tmp directory full but tmp file is empty! Could be linked to MySQL? bethanlowder Fedora 7 09-25-2009 07:17 AM
Filesystem management - /tmp full Jinouchi Linux - Newbie 6 05-21-2009 11:12 PM
help on /tmp filesystem squirrel001 Linux - Newbie 1 06-19-2006 06:23 AM
which is the best filesystem for /tmp ? alexand Linux - Newbie 5 03-15-2006 08:39 PM

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

All times are GMT -5. The time now is 04:04 AM.

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