The slowest part of a computer is the hard drive. So loading program and files from hard drive is really slow. RAM or Random Access Memory stores program data and important machine code that are current being used by your computer. RAM is very fast, hundreds of times faster than hard drives. So you may be thinking, why don’t we use RAM instead of hard drives? Well, firstly RAM is not as cheap as hard drives. So your system has limited amount of RAM. The other major problem is, RAM is a temporary storage device. So when you shutdown your computer or the power goes off, all the data of your computer’s RAM will be erased.
Does that mean we can’t store ordinary data on RAM? Well, we actually can. If you don’t care about your data being lost, then you can use RAM as disk. Which is called RAMDISK. This solution is very effective if your computer has backup power supply that can keep your computer running for a long time even when the power goes off.
This article will help you to create partitions on disk in Linux system and format disk partitions to create a file system. Step 1 – Create Disk Partitions. If you have added a new disk to your system, You can simply format entire disk and create it as a single disk. But it’s a good idea to create smaller partitions on large size disks. The obvious improvement is to create a script that would do this all automatically. This can also be done, but one manual step will still remain: insert the USB pendrive. I am thinking instead of the actual USB disk we could use a block device in RAM. This not only would eliminate the manual step of inserting the USB disk, but would also be faster. The obvious improvement is to create a script that would do this all automatically. This can also be done, but one manual step will still remain: insert the USB pendrive. I am thinking instead of the actual USB disk we could use a block device in RAM. This not only would eliminate the manual step of inserting the USB disk, but would also be faster. In computing (specifically as regards Linux computing), initrd (initial ramdisk) is a scheme for loading a temporary root file system into memory, which may be used as part of the Linux startup process. Initrd and initramfs refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.
There is actually a way to use RAMDISK to store files permanently. Let’s say you have a 4 GB RAMDISK setup. You can store and access files here very fast. Of course, this is temporary storage. To fix that problem, we can use a hard drive and sync all the files and directories of our RAMDISK automatically with specific backup softwares. Even though hard drive is slow, and it may take a while to sync a hard drive with a RAMDISK, at least the data will be stored permanently. So when you shutdown your computer, RAMDISK will be erased. When you start your computer again, all the data will be copied from your hard drive to your RAMDISK. This process will be slow. But after the data is copied, you can again access the data very fast. So basically RAMDISK is used as a cache here.
In this article, I will show you how to create and use RAMDISK on Ubuntu 18.04 LTS. To watch a video of this process see video below:
Creating a RAMDISK on Ubuntu 18.04 LTS is really easy. All the tools required is already pre-installed on Ubuntu 18.04 LTS.
First create a mount point where you will be mounting the RAMDISK with the following command:
Now you can mount the RAMDISK to the /mnt/ramdisk mount point with the following command:
$ sudomount-t tmpfs -o rw,size=2G tmpfs /mnt/ramdisk
NOTE: Here, size=2G means, the RAMDISK will be 2 GB in size. To create RAMDISK of several MB, use M. For example, to create 256 MB RAMDISK, put size=256M
Now to verify whether the RAMDISK is created, run the following command:
As you can see, the RAMDISK is created and mounted on /mnt/ramdisk as expected.
You can use the RAMDISK as you use ordinary hard drive partitions. As you can see from the screenshot below, I copied several files and directories into the RAMDISK. I can even edit text files directly from RAMDISK.
To unmount the RAMDISK, run the following command:
WARNING: All the files in your RAMDISK will be lost.
Mounting RAMDISK Automatically on System Boot:
You can use the /etc/fstab file to automatically mount the RAMDISK on system boot.
First, make a backup of /etc/fstab file with the following command:
A copy of the file /etc/fstab is saved to /etc/fstab.backup. Now If anything goes wrong on the way, you can just restore the /etc/fstab file. Ilife 11 toast download free.
Now open /etc/fstab file with the following command:
/etc/fstab file should be opened.
Now go to the end of the file and add the following line:
NOTE: Here size=2G means, the size of the RAMDISK will be 2 GB. To specify the size in MB, use M instead of G.
Now press <Ctrl> + x and then press y and then press <Enter> to save the file.
Now reboot your computer with the following command:
The RAMDISK should be mounted as you can see from the marked section of the screenshot below.
Persisting RAMDISK Data:
In this section, I will show you how to save RAMDISK data to hard drive on system shutdown and load data from hard drive to RAMDISK on system boot.
For this to work, the directory where the RAMDISK will be mounted and where the backup data will be saved must have the same file permission set. I will show you an easy trick. Stay tuned.
First create a directory where RAMDISK data will be saved on system shutdown with the following command:
Permute 3 1 9 esv. If you’ve followed this article from the start, then the RAMDISK should be mounted on /mnt/ramdisk
Now create a system service file with the following command:
Create Ram Disk Linux Installer
$ sudonano/lib/systemd/system/ramdisk-sync.service
Now type in the following lines and replace shovon as marked in the screenshot below with your login username. Don’t forget this step as it won’t work otherwise. Now save the file.
Now enable the ramdisk-sync service with the following command:
The ramdisk-sync service is enabled. Now it will start automatically on system boot.
Cornette 1 9 – launch tasks automatically join. Now reboot your computer with the following command:
Once your computer starts, check whether the ramdisk-sync service is running with the following command:
As you can see, the service is running correctly.
As you can see, both the /mnt/ramdisk and /mnt/ramdisk_backup directories are empty.
Now I am going to copy some files to /mnt/ramdisk RAMDISK.
Now reboot your computer.
Create Ram Disk Linux Usb
As you can see, once my computer boots, the files are available in my RAMDISK /mnt/ramdisk
Also the /mnt/ramdisk and /mnt/ramdisk_backup contains the same files.
That’s how you create and use RAMDISK on Ubuntu 18.04 LTS. Thanks for reading this article.
In my previous project, I developed a real-time system, so faster speed for read/write temporary data is necessary. After setting, when Raspberry Pi starts up, a small ramdisk will auto-create.
What is Ram Disk?
A RAM disk is a portion of RAM which is being used as if it were a disk drive. RAM disks have fixed sizes, and act like regular disk partitions. Access time is much faster for a RAM disk than for a real, physical disk. However, any data stored on a RAM disk is lost when the system is shut down or powered off. RAM disks can be a great place to store temporary data.(online material)
A RAM disk is a portion of RAM which is being used as if it were a disk drive. RAM disks have fixed sizes, and act like regular disk partitions. Access time is much faster for a RAM disk than for a real, physical disk. However, any data stored on a RAM disk is lost when the system is shut down or powered off. RAM disks can be a great place to store temporary data.(online material)
Actually, it’s very easy to set up ram disk, I list the steps.
I want to mount the smallest ramdisk in /mnt/rd.
1. Create a folder
It means that you want to create a ramdisk here. Go to Terminal and type following command
I want to mount the smallest ramdisk in /mnt/rd.
1. Create a folder
It means that you want to create a ramdisk here. Go to Terminal and type following command
2. Edit /etc/rc.local file
I use nano as editor
I use nano as editor
Mount Ramdisk
Copy all in the red box to the file before “exit 0” (ignore other lines)
3. Reboot Pi and check ramdisk
After reboot your pi, you type “df -h” to check disk status, you will see ram0, size is 7.8mb.
Yes, you can use it to boost your project.
3. Reboot Pi and check ramdisk
After reboot your pi, you type “df -h” to check disk status, you will see ram0, size is 7.8mb.
Yes, you can use it to boost your project.