Resizing a tmpfs partition without losing the files

Took me just a few seconds of Googleing, but it seems worth taking a note here.

To resize a tmpfs filesystem without losing the files. Assuming that /tmp is being mounted in a tmpfs.

You can do it so it lasts until next reboot with:

mount /tmp -o size=3000M,remount

Or you can do it so it lasts forever :

  1. Modify /etc/fstab line to look something like this:
    none                   /tmp                tmpfs   size=3g        0 0
  2. Remount the filesystem
    # mount -o remount /tmp
    
  3. Check if it all went OK
    # df -h
    

Note: Increasing too much can cause the system to hang if the amount cannot be allocated.

References (hope at leat one of these links still work):

http://lxr.linux.no/linux/Documentation/filesystems/tmpfs.txt
http://www.xenotime.net/linux/doc/swap-mini-howto.txt
http://wiki.linuxquestions.org/wiki/Tmpfs#ixzz13amAsYk1
http://ihazem.wordpress.com/2011/03/08/increase-size-of-tmpfs-file-system/
http://www.biosplus.com/2012/02/increasing-size-tmpfs-losing-files/

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.