# Adding a separate /tmp

**URL:** <https://community.unix.com/t/adding-a-separate-tmp/340676>\
**Category:** Red Hat\
**Created:** [March 13, 2014, 11:04pm UTC](https://community.unix.com/t/adding-a-separate-tmp/340676 "2014-03-13T23:04:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![solaris\_1977](https://community.unix.com/letter_avatar/solaris_1977/32/6_449c533f586939b6e5f246632a46421f.png) [@solaris\_1977](https://community.unix.com/u/solaris_1977)\
**Post date:** [March 13, 2014, 11:04pm UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/1 "2014-03-13T23:04:27Z")

</div>

I have RHEL 6.5 VM. Its default /tmp is small and I have given a extra lun from storage team (/dev/sdc) to create a separate /tmp.  
I have option to take small downtime for 30 minutes, so I wanted to make sure, if I am following correct steps. here is current setup :-

```nohighlight
[root@VMTBESP11 ~]# df -h | grep -i tmp
tmpfs 3.9G 0 3.9G 0% /dev/shm
[root@VMTBESP11 ~]# cat /etc/fstab | egrep -i "tmp|swap"
/dev/sda2 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
[root@VMTBESP11 ~]# cd /tmp
[root@VMTBESP11 tmp]# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 6.4G 8.4G 44% /

```

Just replacing /dev/sda2 to /dev/sdc in /etc/fstab and reboot will work ? Do I need to write file-system also on this new device ? Current file-system is ext4 for all other file-system.

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_449c533f586939b6e5f246632a46421f.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [March 13, 2014, 11:36pm UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/2 "2014-03-13T23:36:09Z")

</div>

/tmp is a filesystem mounted on root (/). What has this to do with "sda2" (swap), downtime or rebooting?

If you need more space in /tmp, just add the LUN you got from storage to the root VG and extend /tmp as you would any other filesystem.

---

<div class="post-metadata">

**Author:** ![solaris\_1977](https://community.unix.com/letter_avatar/solaris_1977/32/6_449c533f586939b6e5f246632a46421f.png) [@solaris\_1977](https://community.unix.com/u/solaris_1977)\
**Post date:** [March 13, 2014, 11:43pm UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/3 "2014-03-13T23:43:00Z")

</div>

Scott, I have been asked to create a new and separate file-system (instead of part of root). Current root is 16 GB and /tmp to be created with that new lun of 250GB.

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_449c533f586939b6e5f246632a46421f.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [March 13, 2014, 11:50pm UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/4 "2014-03-13T23:50:51Z")

</div>

/tmp has not a lot to do with swap, and as /tmp is only a directory off /, there's nothing in /etc/fstab about it.

Take the 250GB LUN, create an fdisk LVM partition with it, create a VG, LV and ext4 fs of it and mount it under /tmp, remembering to add it to /etc/fstab.

Ideally you'd want some downtime to clean out /tmp under / before mounting the new FS, so if you could get that, great! A reboot isn't strictly required, either way.

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [March 14, 2014, 12:31am UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/5 "2014-03-14T00:31:52Z")

</div>

Well, it looks like he currently is not using LVM since / is mounted from /dev/sda3. Given that, I don't see a lot of reason to setup a PV only for /tmp. The resulting config would seem a bit strange.

I have only recently convinced my company to switch to LVM. Corporate inertia can be a pain sometimes.

---

<div class="post-metadata">

**Author:** ![solaris\_1977](https://community.unix.com/letter_avatar/solaris_1977/32/6_449c533f586939b6e5f246632a46421f.png) [@solaris\_1977](https://community.unix.com/u/solaris_1977)\
**Post date:** [March 14, 2014, 12:54am UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/6 "2014-03-14T00:54:08Z")

</div>

We are not using LVM for root. But for application file-systems, they are always in LVM.  
Scott, should I create a simple /dev/vg\_tmp/lv\_tmm then mkfs.ext4 on that and have a entry in /etc/fstab as below

```nohighlight
/dev/vg_tmp/lv_tmm /tmp ext4 noexec,nosuid,loop 1 1

```

After this a simple reboot should be able to put everything in place ?

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_449c533f586939b6e5f246632a46421f.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [March 14, 2014, 1:10am UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/7 "2014-03-14T01:10:52Z")

</div>

Yes, if you want to go down the LVM route, that sounds fine. (otherwise just partition it using fdisk and mkfs.ext4 that!)

The most compelling reason to reboot is to ensure that processes stop writing to the old FS and start writing to the new one. If you could do that without rebooting (i.e. by restarting applications) then try that. But most VMs these days are likely bastion systems, so it's as well to reboot the VM if you can get away with it!

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [March 14, 2014, 8:31am UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/8 "2014-03-14T08:31:13Z")

</div>

In RHEL /tmp is a really for system temporary files. See tmpfs for more information. /var/tmp is for application and user temporary files. You can actually slow down your system slightly if you switch /tmp to be a separate fileystem.

---

<div class="post-metadata">

**Author:** ![solaris\_1977](https://community.unix.com/letter_avatar/solaris_1977/32/6_449c533f586939b6e5f246632a46421f.png) [@solaris\_1977](https://community.unix.com/u/solaris_1977)\
**Post date:** [March 14, 2014, 2:29pm UTC](https://community.unix.com/t/adding-a-separate-tmp/340676/9 "2014-03-14T14:29:19Z")

</div>

fpmurphy, it is their application which writes file in /tmp.  
2 days back, application filled up /tmp (which was part of root and it was only 16GB) and that became a outage, so it was decided to separate /tmp and give it bigger space.  
I am able to complete it. Thanks to all.
