I have already run through the tutorial on expanding the Linux partition as described in this link. All we well and I now have the following setup when I run df in the root of a terminal session
It shows plenty of space available on the rootfs portion of the build. I have been able to install node by entering
opkg install node
However, when I run the command
npm install twit
The terminal waits for a minute then returns the following message
FATAL ERROR: Evacuation Allocation failed - process out of memory
Aborted
Can someone please help me determine where my issue with installing this node package, as I am kind of stuck dead in the water until I am able to get the twit package installed on my Yun.
That was good detective work. Yes, you expanded the disk space using the flash memory on an SD card, but your error was running out of RAM - a different type of memory. There isn't any provision for adding more RAM to the Linux processor.
You can enable a swap partition, as you discovered, and that uses some of the SD card's flash memory as temporary space to swap out portions of RAM that have not been used recently, to make space for more virtual RAM. On a fast desktop computer with fast hard drives, that is a viable solution. But on the Yun's embedded Linux processor, it has some significant limitations: writing to an SD card is much slower than a typical hard disk drive, and the flash memory used by SD cards has a limited write cycle life: unlike mechanical rotary hard disks, flash memory has an endurance that is limited by the number of write cycles. You can read as much as you want, but it will wear out based on write cycles: typical flash memory lifespans are 100,000 to 1,000,000 writes - that sounds like a lot, but the Linux system can be writing to the swap partition very frequently, and that could significantly reduce the SD card's lifespan. (That's one of the reasons to expand the Yun's system storage to an SD card: do all of the system writes to the replaceable SD card rather than the non-replaceable internal flash storage.)
As you found, enabling the swap partition can be made to work, but the YunDiskExpander sketch doesn't do that - probably due to these limitations. Add in that most people don't need it, and it doesn't make sense to add that function to the sketch - it would just cause confusion to most people.
Node is a large package that makes significant demands on the processor. It really strains the Yun's small embedded Linux system. It can be made to work, as you found out, but it requires significant work and compromises.
I also had similar problems when I tried to install modules using npm command.
The way out was to install the module on local machine (mine is mac) and copy the contents of node_modules(from mac) directory to Yun's node_modules directory. It works and is very fast approach.
e.g:
If you need to install "express", then:
Install "node" on your desktop / laptop
Run following command on laptop / desktop to install express
npm install express --save
If you have not configured your profile directory for node to execute, then the "node_modules" directory is typically located in your home directory (of user you logged in on your computer). The "express" package gets installed inside the "node_modules" directory.
Copy the "node_modules" directory contents to Yun's "node_modules" directory (it should be again in your home directory if you have not configured node) and everything should work normally.
ShapeShifter:
...
You can enable a swap partition, as you discovered, and that uses some of the SD card's flash memory as temporary space to swap out portions of RAM that have not been used recently, to make space for more virtual RAM. On a fast desktop computer with fast hard drives, that is a viable solution. But on the Yun's embedded Linux processor, it has some significant limitations: writing to an SD card is much slower than a typical hard disk drive, and the flash memory used by SD cards has a limited write cycle life: unlike mechanical rotary hard disks, flash memory has an endurance that is limited by the number of write cycles. You can read as much as you want, but it will wear out based on write cycles: typical flash memory lifespans are 100,000 to 1,000,000 writes - that sounds like a lot, but the Linux system can be writing to the swap partition very frequently, and that could significantly reduce the SD card's lifespan. (That's one of the reasons to expand the Yun's system storage to an SD card: do all of the system writes to the replaceable SD card rather than the non-replaceable internal flash storage.)
...
Two work around:
Plan A:
External USB hard drive.
Plan B:
RAID 1 (redundant array of independent disks), multiple USB flash drives.