Caching (Cache) directory in RHEL / CentOS - caching

How to cache a particular directory in RHEL / CentOS ? Suppose I have a directory which contains 10 GB data and I've 48 GB of RAM. How to cache all these data inside the directory(only this specific directory) to my memory for a specific amount of time or indefinitely ?

There's a standard memory device on each Linux system /dev/shm.
When you run the mount command you will see:
tmpfs on /dev/shm type tmpfs (rw)
Generally it's about half the size of the system's memory so if you have 48GB of RAM, its size will be about 24GB. ( you can check this by running df -h )
You can use /dev/shm as if it was a normal hard drive, for example, you can copy a file to it:
cp -r "YOUR DIRECTORY" /dev/shm/
that will do the tirck

Related

Ec2 Storage: can't find which dir is using major chunk of the storage

below are the stats for my EC2 server
Filesystem Size Used Avail Use% Mounted on
/dev/root 146G 135G 11G 93% /
this command sudo du -shc /* gives me output as 33G total
and sudo du -shc /home/ubuntu/* give me output as 2.7G total
where is approx 100GB of disk space is being utilized?
so there is a process which is writing to disk, is more disk I/O the reason.

How to create RAM disk with Golang and in a platform-independent way?

RAM disk can be created in command line with different commands on different operating systems.
For example, to create a RAM disk of 512MB ---
On macOS:
diskutil eraseVolume HFS+ "RAMDisk" `hdiutil attach -nomount ram://1048576`
On Ubuntu:
mkdir /mnt/ramdisk
mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk
Is there any cross-platform method/way to create a RAM disk in Golang?

ddrescue on CygWin creates a zero size image

I try to create an image of a disk (USB flash key) in CygWin with use of the ddrescue command. I do the following:
first, with the command df I look where the disks are in CygWin.
Τhe output is:
C: 30716276 30489824 226452 100% /cygdrive/c
D: 56323856 55794432 529424 100% /cygdrive/d
F: 1953480700 1927260140 26220560 99% /cygdrive/f
H: 7847904 140324 7707580 2% /cygdrive/h
Then, to create the image of the disk h:/ I run the command like this:
ddrescue -v -n /cygdrive/h f:/___buffer/discoH.img discoH.log
The program works some time and is likely reading the disk. Αs a result, the file
f:/___buffer/discoH.img is really created but
its size is zero!
I tried some variations of the command options but with the same result. The disk to be read is fully working and readable, now I only want to learn to create its image.
When using ddrescue under true Linux (Ubuntu), the non-zero-size image of the same disk is created without any problem. What could be the cause for the fail in CygWin?
I still work in Windows XP SP3 32bit, the version of CygWin is
$ uname -r
2.0.4(0.287/5/3)
$ uname -m
i686 (32bit)
On another computer, with Windows 8, the result is the same. Probably, I lack doing something elementary?
PS the disk I want to image is 8GB, and there are 26GB of free space on the disk f:/ where I want to create the image
/cygdrive/h is not a disk image. Try with /dev/sdX
You can identify the X letter, from
$ cat /proc/partitions
major minor #blocks name win-mounts
8 0 976762584 sda
8 1 960658432 sda1 D:\
8 2 16102400 sda2 E:\
8 16 250059096 sdb
8 17 266240 sdb1
8 18 16384 sdb2
8 19 248765440 sdb3 C:\
8 20 1003520 sdb4
Thank you matzeri ! Yours was really the elementary thing I needed but did not know.
So, I use the command cat /proc/partitions instead of df, get the disk reference
sdc1 instead of /cygdrive/h, run the command
ddrescue -v -n /dev/sdc1 f:/___buffer/discoH.img discoH.log
instead of the one I indicated above in my question text, and it works! The image is being recorded

mounting sdb on /mnt using docker and openfoam

I recently found the post entitled "How to mount volumes in docker release of openFOAM" post on this site on October 2016. That post asks about automatically
mounting an already mounted (under bash or csh) volume through the Docker version of openfoam. Hopefully, this is explained below.
I have the situation that under csh, the output from lsblk is:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 1.8T 0 disk /mnt/hdd
sda 8:0 0 111.8G 0 disk
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 7.9G 0 part [SWAP]
└─sda1 8:1 0 103.9G 0 part /
Then I run the script startOpenFOAM+, which is the following Bash shell script:
#!/bin/bash
# this script will
# i) Start OpenFOAM+ container with name 'of_v1612_plus'
# in the the shell-terminal.
# User also need to run xhost+ from other terminal
# Note: Docker daemon should be running before launching script
# PostProcessing: User can launch paraview/paraFoam from terminal
# to postprocess the results
# Note: user can launch script in different shell to have OpenFOAM
# working environment in different terminal
xhost +local:of_v1612_plus
docker start of_v1612_plus
docker exec -it of_v1612_plus /bin/bash -rcfile /opt/OpenFOAM/setImage_v1612+
I am dumped into a Bash shell and the output from lsblk is now:
bash-4.1$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 1.8T 0 disk
sda 8:0 0 111.8G 0 disk
|-sda2 8:2 0 1K 0 part
|-sda5 8:5 0 7.9G 0 part [SWAP]
`-sda1 8:1 0 103.9G 0 part /etc/sudoers.d
I guess the answer to the problem is to add the line docker run -v .... into the startOpenFOAM+ shell script. However, I am not sure what to replace the dots with and where to place the command.
Any help would be much appreciated.
Thanks,
Peter.
If I understand, you need this:
docker run -v /mnt/hdd:/mnt/hdd .....
But you didn't showed where you docker run, if you find it, then add that -v.
Important: you will not see a mount point with lsblk inside container regarding sdb, because docker mount a directory, not a device. You just will see contents in /mnt/hdd

check if ntfs disk is mounted with cygwin

In my computer, I have a ntfs network disk, and with cygwin and bash I have some automatic script (post-commit git hooks) for copy information to the ntfs disk.
with bash (in cygwin), how I can check if the ntfs is enable ?
if mount | grep -q /path/to/device/or/mount/point ; then
# it's mounted
else
# it's not
fi

Resources