To set up the ramdisk, you will need to create a directory in the folder /mnt/ramdisk and also set the permission to allow full access:
sudo mkdir /mnt/ramdisk sudo chmod 777 /mnt sudo chmod 777 /mnt/ramdisk
Then, you will need to create a new ramdisk, make sure that your PC should have at least 4GB RAM:
sudo mount -t tmpfs -o size=1GB myramdisk /mnt/ramdisk
To unmount the ramdisk, just type this command below:
sudo umount /mnt/ramdisk
If you're wanting to automount the ramdisk, put these lines in /etc/fstab file:
myramdisk /mnt/ramdisk tmpfs nodev,nosuid,noexec,nodiratime,defaults,size=1G,x-gvfs-show 0 0
Ok...what about saving and loading the ramdisk data? Well, you can do it by using tar compression to save and load the ramdisk data.
To save the ramdisk data, just run the command below:
tar -czvf ~/ram-backup.tar.gz /mnt/ramdisk
To load the ramdisk data, you will need to run bunch of the command lines here, assuming that you're using /home/username directory:
tar -xvf ram-backup.tar.gz cd mnt/ramdisk cp -r * /mnt/ramdisk rm -rf ~/mnt
If you want to make it much more simpler without needing to run the command manually every time, just create the script file and put these command like these below under designated files:
i) save as ramdisk-backup.sh
tar -czvf ~/ram-backup.tar.gz /mnt/ramdisk
ii) save as ramdisk-restore.sh
tar -xvf ram-backup.tar.gz cd mnt/ramdisk cp -r * /mnt/ramdisk rm -rf ~/mnt
Then, apply both script files to enable execution:
chmod 777 ramdisk-restore.sh chmod 777 ramdisk-backup.sh
Finally, put the script command under designed bash profiles
i) Put into .bash_profile
./ramdisk-restore.sh
ii) Put into .bash_logout
./ramdisk-backup.sh
No comments:
Post a Comment