How do I create a RAM disk using Node.js? - node.js

I would like to create a RAM disk programmatically using Node.js, no matter what the underlying OS is (OS X, Linux and Windows should be supported).
What is the best way to achieve this?
Of course I can run a command as a child process, but I would need to write this code individually for each OS. For obvious reasons I'd like to avoid this.
Is there a better approach (even a module that does it would be fine)?

In a low level and uncommon operation like this, there is no standartized way to generate a RAM disk, it is platform dependent and hence there is no functionality of this in NodeJS and there won't be likely, you have to write an extension. In Windows, it will call ramdisk.exe (not so familiar with it) and on Linux it is availalbe under /dev/shm , which you can resize by mount options later. So, the best way is to find the best external program for Windows versions, and in Linux just mount and use the /dev/shm like a normal folder.
More Info on /dev/shm

Related

Making partitions and running OSs

So I happen to have a pretty huge USB Thumb Drive (Sandisk 128GB), and I don't make much use of it. I was wondering if I could make partitions to it and run a portable operating system on it. Don't misunderstand me here, I know how to flash OSs on a USB. But I was wondering, if I could flash it on a separate partition. Suppose I want 100GB for storing normal files. And I make a partition in it for 100GB. The rest 14GB, I want to run a Linux distro on. Is it possible to just flash it on that 14GB partition? If yes, what are the challenges I'll be facing?

Can bash be used to communicate directly with hardware?

I am interested in writing my own tool in bash to act in place of my current network controller (wpa_supplicant) if possible. For example if I want to issue commands in order to begin a wps authentication session with a router's external registrar, is it possible, without using any pre-built tools, to communicate with the kernel to directly access the hardware? I have been told that I can achieve what I desire with a bash plugin called ctypes.sh but I am not too certain.
Generally speaking, the Linux kernel can interact with user-space through the following mechanisms:
Syscalls
Devices in /dev
Entries in /sys
Entries in /proc
Syscalls cannot be directly used from Bash but you need at least a binding through a C program.
You can create a Linux kernel driver or module which reads/writes data in an entry under /proc or /sys and then use a bash program to interact with it. Even if technically feasible, my personal opinion is that it is an overkill, and the usual C/C++ user-level programming with proper entries in /dev is much better.
No, this is generally not possible. Shell scripts can mess around in /proc, but they don't have the ability to perform arbitrary IOCTLs or even multi-step interactive IO. It's the wrong tool for the job.

Using ZFS with Embedded Linux

I'm running embedded Linux (Debian on ARM/X86_64). Since it is very much like a full OS, with some hardware differential and a different platform, you may consider it as a regular machine. So, this will be used in the robotics field where the computer will ALWAYS be hard reset by turning off power. It would disqualify me to use a UPS so I would need to make the system infallible.
I'm running some processor-intensive tasks, like OpenCV and OpenNI and OpenKinect. How do I use an uber-powerful filesystem, like ZFS to mirror the entire disk on the SSD for error correction? Does ZFS perform well in Linux? I'm still kinda a newbie in Linux so I don't understand it's internal workings.
My list of possible platforms are:
--Debian#RaspberryPi
--kUbuntu#ODROID-X2
--Ubuntu#PandaBoard
--Ubuntu#NUC-i3/5.
Also, how can I make sure the filesystem doesn't get damaged during reset? I need the computer to start in good time, A.K.A, <3 minutes for the competition.
I will probably be using a 32GB SSD, so I guess a 16GB partition mirrored 2x works or 12 # 3x. I only need to get an OpenCV install working because the code will be downloaded from a SAMBA NFS automatically!
Thanks for your help and good luck ;)!
ZFS is not suited for low memory systems. It do perform well on system with 4GB of RAM and more.

aoe disk as /dev/sda in /proc/partitions

Im using AoE disk for a particular Linux installation.
I need to tell to linux system to see /dev/etherd/e0.0 as a /dev/sda,
im already create a hard link of /dev/etherd/e0.0 to /dev/sda an it works.
But now i need to make system see the /dev/sda (/dev/etherd/e0.0) in /proc/partitions.
There exists a command to do that ?
thank you.
There is no way to do that. The /dev/sda node is reserved for devices which are accessible using the SCSI/SATA/IDE disk driver; AoE devices do not use that mechanism, so they will always show up differently. Creating a hard link will just confuse matters; doing so is inadvisable.
I'm not 100% certain whether it's even possible to boot a machine over AoE. It might be possible to do directly if all the configuration is automatic, or can be performed by setting kernel command line parameters; chances are that you will need to create a custom initrd to initialize the network and bring up the volume.

Real-Time File Mirroring in Linux to a NAS

Can anyone tell how I might best mirror selected files and folders to a NAS, (Network Addrssable Storage) box from a Linux workstation in real-time?
These are very large files, (> 50GB) and are being continually modified, so I would only like to change those portions of the files that have been changed, added or deleted.
FYI: These files are actually Virtual Box virtual hard disk (VDI) files.
I discovered that my Synology DS211J NAS can run an RSync service. So I enabled that and used lsyncd for the live mirror... the VirtualBox VMs... all works very well.
Rsync only synchronises the parts of files that have change and so is very efficient at synchronising large files.
Of the solutions that #awm mentioned, only drbd provides block-level, realtime synchronization. The other tools will meet your goal of only propagating deltas, but they operate asynchronously. In fact, rsync will work just as well in this case, since you're not trying to provide bi-directional synchronization.
For drbd to provide block-level replication, you need need to install the drbd kernel modules and userspace tools on both the workstation on the NAS...which means this solution is only appropriate if your NAS is actually a fairly generic Linux box over which you have a great deal of control.
Before hand I just want to suggest that you don't do this. You can easily bottlenet your network and NAS and cause all sorts of problem on your host.
That being said, these claim they can do it:
Unison can be found at: http://www.cis.upenn.edu/~bcpierce/unison/
PeerSoft can do it too: http://www.peersoftware.com/products/peersync/peersyncserver/overview.aspx
Maybe - http://www.drbd.org/

Resources