Difference between revisions of "Creating a Ramdisk tmp"

From CBLFS
Jump to navigationJump to search
(Changed the last line so that it is reworded and has no spelling errors.)
 
(10 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
|-
 
|-
 
!Download Patch:
 
!Download Patch:
| http://svn.cross-lfs.org/svn/repos/patches/mountfs/mountfs-0.1-RAMDISKTMP-1.patch
+
| http://svn.clfs.org/svn/repos/patches/mountfs/mountfs-0.1-RAMDISKTMP-2.patch
 
|}
 
|}
  
Line 24: Line 24:
 
=== Add the process to the bootscripts ===
 
=== Add the process to the bootscripts ===
  
  cd /etc/etc/rc.d/init.d/
+
  cd /etc/rc.d/init.d/
  patch -Np1 -i ~/mountfs-0.1-RAMDISKTMP-1.patch
+
  patch -Np1 -i ~/mountfs-0.1-RAMDISKTMP-2.patch
 
+
ln -sf /tmp /var/tmp
Now you just need to reboot and sit back. Enjoy!
 
 
 
=== What is added to you boot scripts /etc/rc.d/init.d/mountfs ===
 
 
 
Adds a Boot Mesg to the screen during the boot process.
 
boot_mesg "Creating, Formating and Mounting Ramdisk tmp..."
 
  
Formats the ramdisk, We use ext2 because a journal is not needed.
+
=== Add /tmp and /var/tmp to /etc/fstab ===
mkfs.ext2 -q -m 0 /dev/ram0
 
  
We mount the newly formated ramdisk /dev/ram0 as /tmp
+
Edit your /etc/fstab and add /tmp
mount /dev/ram0 /tmp
 
  
We correct the permissions of /tmp to the correct ones.
+
  /dev/ram0      /tmp   ext2    defaults        0      0
  chmod 1777 /tmp
 
 
 
We use a simple symlink to a add /var/tmp to the same mount
 
ln -sf /tmp /var/tmp
 
  
Print to the boot screen, [OK] when completed without error.
+
You are now done creating a Ramdisk. Restart your system and enjoy!
evaluate_retval
 

Latest revision as of 10:34, 3 February 2015

Download Patch: http://svn.clfs.org/svn/repos/patches/mountfs/mountfs-0.1-RAMDISKTMP-2.patch

This page will detail how to have /tmp and /var/tmp run under a mounted RAMDISK /dev/ram0. This is done for several reasons. First, if /tmp and /var/tmp are mounted under root /, they can cause large amounts of disk fragmentation due to the creation/deletion of a large amount of files. Second there is a noticeable performance gain, especially when dealing with large programs, (ie, KDE, gnome, OpenOffice, Etc) that use /tmp and /var/tmp to store/interact with information. I would not recommend this process for systems with a small amounts of ram.

Ensure kernel has Ramdisk Support

--- Block devices 
       <*>   RAM block device support                                                
       (16)    Default number of RAM disks                                           
       (4096)  Default RAM disk size (kbytes)

Tell the kernel to make the Ramdisk at boot

You will need to edit which ever boot loader menu you have {IE:grub, lilo} and add ramdisk_size=56000 to the kernel boot parameters. It should resemble the following. This tells the kernel to create a ramdisk 56Mb in size.

title CLFS YOUR_VERSION
root (hdX,X)
kernel /boot/clfs_YOUR_KENREL root=/dev/{XXX} ramdisk_size=56000

Add the process to the bootscripts

cd /etc/rc.d/init.d/
patch -Np1 -i ~/mountfs-0.1-RAMDISKTMP-2.patch
ln -sf /tmp /var/tmp

Add /tmp and /var/tmp to /etc/fstab

Edit your /etc/fstab and add /tmp

/dev/ram0       /tmp    ext2    defaults        0       0

You are now done creating a Ramdisk. Restart your system and enjoy!