Idea: In Ubuntu, place the google-chrome browser cache in RamDisk to accelerate web browsing. 1. Background: RamDisk In Ubuntu. For details, visit http://www.linuxidc.com/linux/2010-12/30868.htm?tu=to use half of the memory for ramdiskspace. Mount point:/dev/shm file type: tmpfs
Idea:
In Ubuntu, cache the google-chrome browser to RamDisk to accelerate web browsing.
1. Background: RamDisk in Ubuntu, Reference link: http://www.linuxidc.com/Linux/2010-12/30868.htm
UbuntuBy default, half of the memory is used as ramdisk space. Mount point:/dev/shm file type: tmpfs
/Dev/shm is not entirely RamDisk. If it uses more than half of the computer's RAM, it will start to eat SWAP. In addition, the unused parts are automatically released for use by the system.
How to set the/tmp directory to RamDisk
Basically, you only need to run the following command to bind/tmp to/dev/shm.
mkdir /dev/shm/tmpchmod 1777 /dev/shm/tmpmount --bind /dev/shm/tmp /tmp
※Note: the reason why mount-bind is used instead of ln-s soft link is that the/tmp directory is not deleted.
2. Background: google-chrome User Data Location
The Default User Data Location of chrome in linux is $ HOME/. config/google-chrome. You can enter about: // config in the address bar of the browser to view the default user data.
3. Move chrome user data and create a symbolic connection in the default location
sudo mkdir /dev/shm/google-chromesudo chmod 777 /dev/shm/google-chromecp -r ~/.config/google-chrome /dev/shm/rm -r ~/.config/google-chromeln -s /dev/shm/google-chrome ~/.config/
So far, chrome user data has been moved to RamDisk. Open the Chrome browser and enter about: // config. The following information is displayed:
Profile Path: /dev/shm/google-chrome/Default
The problem is that after the system is shut down or restarted, user data stored in RamDisk will be lost, and chrome will be restored to the initial installation status. To solve this problem, you need to automatically save chrome user data when you exit the system, and automatically restore user data to RamDisk when you enter the system.
4. automatically save and restore chrome user data
4.1 chrome user data is automatically saved when you exit the system.
Create a script in the home directory named backupchrome:
vi ~/backupchrome
The content is as follows:
#! /bin/shtar -cvzf /home/xxx/chrome-data.tar.gz /dev/shm/google-chrome
Grant executable permissions:
chmod 777 ~/backupchrome
Create a symbolic connection to the file in the/etc/rc0.d/(shutdown script) and/etc/rc6.d/(restart script) directories, both of which start with K, run the following command when you exit the system:
sudo ln -s ~/backupchrome /etc/rc0.d/K01backupchromesudo ln -s ~/backupchrome /etc/rc6.d/K01backupchrome
4.2 chrome user data is automatically restored when you enter the system.
Create another script in the home directory named restorechrome:
vi ~/restorechrome
The content is as follows:
#! /bin/shcd /tar -xvzf /home/xxx/chrome-data.tar.gz
By the way, write another script to mount the/tmp folder to RamDisk, named mounttmp:
vi ~/mounttmp
The content is as follows:
#! /bin/shmkdir /dev/shm/tmpchmod 1777 /dev/shm/tmpmount --bind /dev/shm/tmp /tmp
Grant the executable permissions to the two files:
chmod 777 ~/restorechromechmod 777 ~/mounttmp
Now you need to confirm the runlevel of Ubuntu, just enter:
runlevel
Return Value:
N 2
The runlevel of the Ubuntu graphic interface is 2. Therefore, the symbolic connections of these two files are established in the/etc/rc2.d/directory, all starting with S, indicating that they are executed when they enter the system:
sudo ln -s ~/restorechrome /etc/rc2.d/S01restorechromesudo ln -s ~/mounttmp /etc/rc2.d/S02mounttmp
After the configuration is complete, restart the system for verification.
The configuration method in this article has been successfully tested in the Ubuntu 11.04 x86_64 environment.