Adding a separate /tmp

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 :-

[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.

/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.

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.

/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.

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.

1 Like

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

/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 ?

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!

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.

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.