If I am working on very limited device such as the arduino nano but I want to run LUA from external SD card should I try to remove features from the LUA engine or write a VM that will load a compiled blob that will utilize part of the SD card as RAM and then build the lua binary for the blob so basically two VMs including the lua one run on the arduino? Or is there a way to use the SD card directly as RAM?
I'm not sure if it's possible to use an SD card directly as RAM for Arduino Nano. However, you can write a bootloader that is able to read from the memory card and change the flash contents of your Atmega. This essentially means that you have to write an OS level program for your Arduino Bootloader and use the memory card like a hard-disk and the rest of your Arduino flash as the program RAM¹. 

Alternatively, you can use an SD card without a file system but it is not very convenient. It is better to use the FAT16 or FAT32 format to work with Arduino². 

You can also control the arduino interface using lua by writing your own lua script that asks by serial the reading to the atmega, then you have to write a sketch on the atmega which reads the serial interpretate the command, execute it and then send it back¹⁵.

I hope this helps! Let me know if you have any other questions.

Source: Conversation with Bing, 3/22/2023(1) Micro SD Card as Arduino "main memory" - Stack Overflow. https://stackoverflow.com/questions/50442588/micro-sd-card-as-arduino-main-memory Accessed 3/22/2023.
(2) SD Card for Arduino: Detailed Tutorial - NerdyTechy. https://nerdytechy.com/sd-card-for-arduino-tutorial/ Accessed 3/22/2023.
(3) How can I control the arduino interface using lua - Stack Overflow. https://stackoverflow.com/questions/22175020/how-can-i-control-the-arduino-interface-using-lua Accessed 3/22/2023.
(4) Micro SD Card as Arduino "main memory" - Stack Overflow. https://stackoverflow.com/questions/50442588/micro-sd-card-as-arduino-main-memory Accessed 3/22/2023.
(5) Micro SD Card Tutorial : 6 Steps - Instructables. https://www.instructables.com/Micro-SD-Card-Tutorial/ Accessed 3/22/2023.
(6) Arduino Nano Memory Upgrade With No Soldering | Hackaday. https://hackaday.com/2021/06/20/arduino-nano-memory-upgrade-with-no-soldering/ Accessed 3/22/2023.
(7) 6 Ways an Arduino Can Store Data (how to use and costs compared). https://chipwired.com/arduino-store-data/ Accessed 3/22/2023.
(8) Using SD Card Module with Arduino | Read/Write/Data Logger. https://how2electronics.com/using-sd-card-module-with-arduino-read-write-data-logger/ Accessed 3/22/2023.
(9) Arduino - Micro SD Card | Arduino Tutorial - Arduino Getting Started. https://arduinogetstarted.com/tutorials/arduino-micro-sd-card Accessed 3/22/2023.
(10) Guide to Arduino & Secure Digital (SD) Storage.. https://docs.arduino.cc/learn/programming/sd-guide/ Accessed 3/22/2023.
(11) How can I control the arduino interface using lua - Stack Overflow. https://stackoverflow.com/questions/22175020/how-can-i-control-the-arduino-interface-using-lua Accessed 3/22/2023.
(12) How to Use an SD Card With Your Arduino | Arduino | Maker Pro. https://maker.pro/arduino/tutorial/how-to-use-an-sd-card-with-your-arduino Accessed 3/22/2023.
(13) Using SD Card Module with Arduino | Read/Write/Data Logger. https://how2electronics.com/using-sd-card-module-with-arduino-read-write-data-logger/ Accessed 3/22/2023.
(14) Arduino - Micro SD Card | Arduino Tutorial - Arduino Getting Started. https://arduinogetstarted.com/tutorials/arduino-micro-sd-card Accessed 3/22/2023.
(15) Guide to Arduino & Secure Digital (SD) Storage.. https://docs.arduino.cc/learn/programming/sd-guide/ Accessed 3/22/2023.
(16) How to Use an SD Card With Your Arduino | Arduino | Maker Pro. https://maker.pro/arduino/tutorial/how-to-use-an-sd-card-with-your-arduino Accessed 3/22/2023.