Moving home to ram

I had a problem with the pi not booting into the pi user account when I followed the method of moving the /home/pi folder to /tmp (mounted in ram) in this blog:

formatting link

I have solved the problem (I think) but I'm not sure why the problem disappeared. I would like to know what happened in case there are still some hidden issues.

What I did was as follows:

In order to move the contents of the home folder to /tmp, I had the following lines in a script run from rc.local, then renamed /home/pi to /home/base and rebooted.

cd /home rm -f pi # remove old link mv base pi # temporary rename rsync -aR pi /tmp/home # copy pi to tmp/home mv pi base # reverse temporary rename ln -s /tmp/home/pi pi # create link to home in tmp chown -h pi:pi pi # change owner of link to pi

The idea of the temporary rename was just to allow rsync to create /tmp/home/pi using the R option. No particular reason to do it this way, just the first way I tried.

After many hours trying to find why this didn't work I stumbled upon changing the script by removing the temporary renaming of the base folder and adding mkdir -p /tmp/home/pi and then changing the rsync line to : rsync -a /home/base/ /tmp/home/pi

This appears to solve the problem and the pi boots into the LXDE desktop pi user account. Without this change I had to manually log in.

When it wasn't working I assumed it was because some process was run prior to rc.local which was expecting something in /home/pi which it couldn't find because /home/pi didn't exist. I guess there must be some config where pi was mentioned. However this doesn't explain why it would then work with my altered code in rc.local. Any ideas what this could be down to would be most welcome. Also any suggestions as to a better place to put my script.

Reply to
Russell Gadd
Loading thread data ...

/tmp doesn't have to be in RAM, does it? On the RPi, /run/shm is definitely RAM.

Reply to
A. Dumas

Maybe OP really wanted to remove everything from /home by default.

Reply to
Nikolaj Lazic

No it doesn't. One of my Intel Fedora systems has it mounted as tmpfs, the other has it on a disk partition.

However, since /tmp can be quite busy at times (does gcc use it for intermediate files?) it would make sense to put it in tmpfs of you main drive is an SD card.

martin@   | Martin Gregorie 
gregorie. | Essex, UK 
 Click to see the full signature
Reply to
Martin Gregorie

Right it doesn't have to be, but I have made it tmpfs in fstab.

Reply to
Russell Gadd

I didn't explain the motivation for putting home in ram. I am setting up a remote noticeboard system and I'm trying to have as little writing to the SD card as possible, not so much for protecting the life of the card but more for avoiding problems if the power is cut. I don't have the time, nor possibly the expertise, to research and set up a truly read-only system (if someone could provide a version of raspbian or other distro which is read-only, this would be a great service to the community).

Reply to
Russell Gadd

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.