How to make a temporary /home into the RAM memory

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
kukamuumuka

How to make a temporary /home into the RAM memory

Post by kukamuumuka »

1. Edit /etc/rc.local file.

Code: Select all

#!/bin/sh -e
#
# rc.local
#
mount -t tmpfs -o size=1024M tmpfs /home
mkdir /home/username
rsync -av /etc/skel/ /home/username
chown username -R /home/username

exit 0
2. Copy your home folder contents excluding .bash_logout .bashrc and .profile to /etc/skel

3. Edit /etc/fstab file commenting out (adding # in the front of the line) /home line and adding a new line.

Code: Select all

tmpfs       /home   tmpfs defaults,size=1024M   0 0
PS. Set the proper size for fitting your files into RAM.

Edit: An intresting thing with ramdisk
http://forums.linuxmint.com/viewtopic.p ... 5#p1058355
sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs -o size=2048m tmpfs /mnt/ramdisk

Add a permanent entry in /etc/fstab (this creates a 2gb Ramdrive that persists after reboots.)

tmpfs /mnt/tmpfs.ramdisk tmpfs nodev,nosuid,noexec,nodiratime,size=2048M 0 0

You can move all /tmp to ram by adding this to fstab (sets an upper limit of 3GB, but you can leave that out or change it):

tmpfs /tmp tmpfs nodev,nosuid,noatime,size=3G,mode=1777 0 0
kukamuumuka

Re: How to make a temporary /home into the RAM memory

Post by kukamuumuka »

For a Kiosk-computer, a temporary user can use a temporary /home the next way.

1. Make an user and delete its home directory after creating

Code: Select all

sudo adduser guest  ### guest = username
sudo rm -rf /home/guest
2. Edit /etc/rc.local file adding the lines

Code: Select all

#!/bin/sh -e
#
# rc.local
mkdir /tmp/guest
rsync -av /etc/skel/ /tmp/guest
chown guest -R /tmp/guest
ln -s /tmp/guest /home

exit 0
Now temporary home-directory resets in every reboot.
Post Reply

Return to “Tutorials”