it is called an iPod.
Running an OS in memory is a really fragile task.
Get a SSD or buy a $40 12V>>120V power inverter.
What you are asking is possible - but it is one of those "if you have to ask you can't (afford, understand, pull it off, etc.)" type things.
Do you have a reason for wanting this other than not draining your laptop battery?