• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ++wythern++

            X presents Y for a better Z

            [轉]在Linux下如何創建ramdisk

            Refer to How to Easily Create Ramdisk on Linux

            This tutorial will show you how to quickly create a RAM disk in any Linux distro (Debian, Ubuntu, Linux, Fedora, Arch Linux, CentOS, etc). Compared to commercial Windows RAM disk software that costs money, Linux can utilize this cool feature 100% free of charge.

            What is RAM Disk?

            RAM disk is also known as RAM drive. It’s a portion of your RAM that are formated with a file system. You can mount it to a directory on your Linux system and use it as a disk partition.

            Why use RAM disk?

            RAM is ultra-fast compared to even the fastest solid state drive (SSD). As you may know, the main performance bottleneck in today’s computer is the speed of hard drive, so moving programs and files to the RAM disk yields super fast computing experience.

            Pros of RAM disk:

            • Ultra-fast
            • Can sustain countless reads and writes

            Cons of RAM disk:

            • RAM is volatile which means all data in RAM disk will be lost when the computer shutdowns or reboots. However, this can be a pro in some situations, if you use it wisely.
            • RAM is expensive so it has limited capacity. You need to make sure not allocate too much space for RAM disk, or the operating system would run out of RAM.

            You can do a lot of interesting things with RAM disk.

            • RAM disk is best suited for temporary data or caching directories, such as Nginx FastCGI cache. If you use a SSD and there will be a lot of writes to a particular directory, you can mount that directory as a RAM disk to reduce wear out of SSD.
            • I also use RAM disk to temporary store screenshots when writing articles on this blog, so when my computer shut down, those screenshots will automatically be deleted on my computer.
            • You may not believe it, but I use RAM disk to run virtual machines inside VirtualBox. My SSD is about 250G. I can’t run many VMs directly on the SSD and I’m not happy about the speed of my 2TB mechanical hard drive (HDD). I can move the VM from HDD to RAM disk before starting the VM, so the VM can run much faster.  After shutting down the VM, I move the VM files back to HDD, which takes less than 1 minute. This of course requires your computer to have a large capacity RAM.

            How to Create a RAM Disk in Any Linux Distro

            First make a directory which can be anywhere in the file system such as

            sudo mkdir /tmp/ramdisk

            If you want to let every user on your Linux system use the RAM disk, then change its permission to 777.

            sudo chmod 777 /tmp/ramdisk

            Next, check how much free RAM are left on your system with htop command line utility because we don’t want to use too much RAM.

            htop

            easily create ram disk linux

            Then all left to do is to specify the file system typeRAM disk sizedevice name and mount it to the above directory. You can see from the screenshot above that I have plenty of free RAM, so I can easily allocate 1GB for my RAM disk. This can be done with the following one-liner. It will be using tmpfs file system and its size is set to 1024MB. myramdisk is the device name I gave to it.

            sudo mount -t tmpfs -o size=1024m myramdisk /tmp/ramdisk

            To allocate 10G for the RAM disk, run this instead.

            sudo mount -t tmpfs -o size=10G myramdisk /tmp/ramdisk

            If we issue the following command

            mount | tail -n 1

            We can see it’s successfully mounted.

            create linux ramdisk

            Now if I copy my VirtualBox machines file (5.8G) into the RAM disk, my RAM usage suddenly goes up to 9.22G.

            linux automount ramdisk

            If I unmount RAM disk,

            sudo umount /tmp/ramdisk/

            Everything in that directory will be lost and RAM usage goes down to original.

            linux ramdisk file system

            This is how you can test if your RAM disk is working.

            Test RAM Disk Speed

            To test write speed of RAM disk, you can use dd utility.

            sudo dd if=/dev/zero of=/tmp/ramdisk/zero bs=4k count=100000

            Which gave me 2.8GB/s write speed.

            linux ramdisk speed test

            To test read speed, run:

            sudo dd if=/tmp/ramdisk/zero of=/dev/null bs=4k count=100000

            Which gave me 3.1 GB/s read speed.

            I also did a speed test on my SSD. The write speed is 534MB/s and read speed 1.6GB/s.

            Auto-mount on System Boot

            Edit /etc/fstab file.

            sudo nano /etc/fstab

            Add an entry like this:

            myramdisk  /tmp/ramdisk  tmpfs  defaults,size=1G,x-gvfs-show  0  0

            x-gvfs-show will let you see your RAM disk in file manager. Save and close the file. Your Linux system will automatically mount the RAM disk when your computer boots up.

            To mount it immediately without reboot, run the following command.

            sudo mount -a

            posted on 2020-02-26 15:17 wythern 閱讀(1077) 評論(0)  編輯 收藏 引用

            伊人久久综在合线亚洲2019| 亚洲国产美女精品久久久久∴| 97超级碰碰碰碰久久久久| 久久精品综合一区二区三区| 亚洲精品无码久久久| 狠狠88综合久久久久综合网 | 久久精品人妻一区二区三区| 午夜精品久久久久久影视777 | 国产精品久久久久影院色| 久久WWW免费人成—看片| 99精品国产99久久久久久97 | 久久久久亚洲国产| 精品久久久久久久久午夜福利| 久久久久亚洲av成人无码电影| 亚洲国产精品无码久久久秋霞2| 91精品国产91热久久久久福利| 日韩精品无码久久一区二区三| 99久久国产热无码精品免费 | 开心久久婷婷综合中文字幕| 欧美一区二区三区久久综合| 精品久久久久久无码人妻蜜桃| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 漂亮人妻被黑人久久精品| 久久夜色精品国产www| 国产精品一久久香蕉产线看| 伊人久久大香线焦AV综合影院| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 精品久久久无码人妻中文字幕 | 国产欧美久久久精品影院| 精品一久久香蕉国产线看播放| 国产成人久久精品区一区二区| 日产精品久久久一区二区| 性色欲网站人妻丰满中文久久不卡| 欧美大战日韩91综合一区婷婷久久青草 | 国产精品美女久久久久网| 2021精品国产综合久久| 国产V综合V亚洲欧美久久| 精品久久无码中文字幕| 国产99精品久久| 久久无码国产| 91麻豆国产精品91久久久|