Skip to content

Instantly share code, notes, and snippets.

@lambdaverse
Last active November 3, 2020 22:00
Show Gist options
  • Save lambdaverse/37fd892ea9978470dfae3d19ff6c79ad to your computer and use it in GitHub Desktop.
Save lambdaverse/37fd892ea9978470dfae3d19ff6c79ad to your computer and use it in GitHub Desktop.
JDK on ram disk with Ubuntu 14.04
  1. Create RAM disk
  2. Create JAVA squashfs
  3. Mount Java to RAM disk
  4. Set Java to default

make RAMDISK using tmpfs:

$shell > sudo mkdir /media/ramdisk
$shell > sudo mount -t tmpfs tmpfs /media/ramdisk

Mount on Start up edit file /etc/fstab add to last line

tmpfs /media/ramdisk tmpfs defaults,mode=1777 0 0

And reboot System Compressed read-only file system for Linux.

SquashFS compresses files, inodes and directories, and supports block sizes up to 1 MB for greater compression. SquashFS is also free software (licensed under the GPL) for accessing SquashFS filesystems. SquashFS is intended for general read-only file system use and in constrained block device/memory systems (e.g. embedded systems) where low overhead is needed. The standard version of SquashFS uses gzip compression, although there is also a project that brings LZMA compression to SquashFS. Install squasfsh tools

sudo apt-get install squashfs-tools 

Create .sqsh file to be mounted later as RAM disk image.

mksquashfs /usr/lib/jvm/java-8-oracle /home/username/jdk8.sqsh
sudo mount /home/username/jdk8.sqsh /media/ramdisk -t squashfs -o loop 
sudo update-alternatives --install "/usr/bin/java" "java" "/media/ramdisk/bin/java" 1 

Check install java complete

sudo update-alternatives --config java # java in ram disk

Make it permanant on startup. Edit /etc/fstab add following line :

/home/username/jdk8.sqsh /media/ramdisk squashfs ro,defaults,loop 0 0

[Reference|https://prezi.com/xgwyp3reqanc/ubuntu-debian-ramdisk/]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment