Linux Commands

Increase tmp partition size on CentOS

Increase tmp partition
Increase tmp partition

Increase tmp partition size on CentOS

The following steps will help you to increase tmp partition. First you need to stop the Apache and MySQL services.

 
/etc/init.d/httpd stop
/etc/init.d/mysql stop

Once the services are stopped please ake a backup of /tmp

 
cp -pr /tmp /tmp_bak

Then create a partition of 4GB using the following command

 
dd if=/dev/zero of=/usr/tmpDSK bs=2M count=2048

Then you can create a file system on it using the following command.

 
mke2fs -j /usr/tmpDSK

You need to unmount the current /tmp partition, once you created the file system.

 
umount /tmp

Then mount the new /tmp filesystem using the below command

 
mount -t ext3 -o rw,loop /usr/tmpBSK /tmp

Set the correct permission for /tmp

 
chmod 1777 /tmp

Please run the following command to verify the partition:

 
mount

Then you need to restore the content of old /tmp directory

 
cp -rp /tmp_bak/* /tmp

Start Apache and MySQL services.

 
/etc/init.d/httpd start
/etc/init.d/mysql start

Edit the /etc/fstab and replace /tmp entry line with the following line to make sure the new partition is mounted automatically after every reboot.

 
/usr/tmpDSK /tmp ext3 rw,loop 0 0

That’s it!

If you like this post and wish to receive more articles from us, please like our FB page: Grepitout

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at info@grepitout.com

Topics