linux | bash - create and mount ram disk
Bash[Edit]
+
0
-
0
Linux | Bash - create and mount RAM disk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20sudo mount -o size=PUT_SIZE_HERE -t tmpfs none /path/to/mount-directory # Where: # `-o size=PUT_SIZE_HERE` indicates RAM disk size in bytes, kilobytes, megabytes or gigabytes, e.g. x, xK, xM or xG, # `-t tmpfs` indicates used `tmpfs` as file system (it is very fast), # `none` indicates mount device that is not set in this case, # `/path/to/mount-directory` indicates place where RAM disk is mount. # Hint: to unmount RAM disk use `sudo umount /path/to/mount-directory` command. # ---------------------------------------------------------------------------------------- # Practical example (10GB RAM disk mount in /mnt/RAM directory): # ---------------------------------------------------------------------------------------- sudo mkdir /mnt/RAM sudo mount -o size=10G -t tmpfs none /mnt/RAM
[Edit]
+
0
-
0
Linux | Bash - create and mount RAM disk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30sudo modprobe brd rd_nr=1 rd_size=PUT_SIZE_HERE sudo mkfs.ext4 -q /dev/ram0 sudo mount /dev/ram0 /path/to/mount-directory # Where: # `modprobe` creates `/dev/ram0` block device in the above case, # `brd` indicates `block RAM disk` module, # `rd_nr=1` indicates number of created block RAM disks, so only `/dev/ram0` disk will be created, # `rd_size=PUT_SIZE_HERE` indicates size of created block RAM disk measured in kilobytes, # `mkfs.ext4` foramts `/dev/ram0` block device using ext4 file system in the above case, # `-q` indicates quick formatting mode, # `/dev/ram0` indicates used block device, # `mount` mounts `/dev/ram0` block device inside `/path/to/mount-directory` directory in the above case, # `/dev/ram0` indicates used block device, # `/path/to/mount-directory` indicates place where RAM disk is mount. # Hint: to unmount RAM disk use `sudo umount /path/to/mount-directory` command. # ---------------------------------------------------------------------------------------- # Practical example (10GB RAM disk mount in /mnt/RAM directory): # ---------------------------------------------------------------------------------------- sudo modprobe brd rd_nr=1 rd_size=$((10 * 1024 * 1024)) sudo mkfs.ext4 -q /dev/ram0 sudo mkdir /mnt/RAM sudo mount /dev/ram0 /mnt/RAM