2

I currently have a proxmox host with a failed disk, running a VM hosting a game server in a ram-disk, created using tmpfs. Unfortunately, my backup script seems to not have been working for a number of days so there is currently no recent copy of the files saved to the disk, which would have been recoverable from the RAID array.

The guest is running Debian 10, and the entire system seems to be in read-only. Furthermore i cannot access the proxmox host via ssh (or the web interface)

Most commands fail with -bash: /usr/bin/(program): Input/output error, however i can still read / write to the ramdisk directory itself. I can also establish new ssh connections to the guest.

Things i've tried:

Is there a way to recover the files in the ramdisk directory?

2 Answers 2

1

Using ssh, cat and echo on a remote linux machine you can send / recieve files.

To fetch file (from ramdisk to remote):

ssh username@ramdisk-ip "cat path/to/remote/file.7z" > copy_of_file.7z

To transmit file (from remote to ramdisk):

cat localFile| ssh username@ramdisk-ip "cat > /path/to/destination/file"

I was able to use these commands to send over the binary for 7zip to the ramdisk, allowing the creation of an archive containing all the game files.

From here I was able to use the fetch command to copy the archive across to the remote machine.

1

Sorry to hear about your server. You say that most commands such as netcat and ssh fail with an input/output error but you don't mention which potentially useful commands are working, such as cp, cat, tar, etc. The good news is you have a BASH prompt which has some pretty useful stuff built in.

If we assume you have access to a working tar command and can set up a netcat listener on some other server then you can simply run something like:

$ tar cvf - /my/ramdisk/directory > /dev/tcp/<some.other.server>/<port>

where <some.other.server> is the IP address of the server running the netcat listener and <port> is the port on which it's listening. On that other server you would run something like:

$ netcat -l -p <port> > backup.tar

This works because BASH on Debian has built-in netcat-like functionality using the "/dev/tcp" syntax.

If tar does not work but cat does you can do something similar on an individual file basis:

$ cat /my/ramdisk/directory/some/file > /dev/tcp/<some.other.server>/<port> 

Also if you have cat you can give yourself tar, netcat and a bunch of other useful commands by downloading a statically linked version of busybox to another server and using netcat to send it to your ailing VM. On Debian a statically linked busybox can be found in the "busybox-static" package. On that other server you would run something like this:

$ netcat -l -p <port> < /bin/busybox

and on the VM you'd run something like this:

$ cat /dev/tcp/<some.other.server>/<port> > /my/ramdisk/directory/busybox
$ chmod +x /my/ramdisk/directory/busybox
$ /my/ramdisk/directory/busybox tar ...

If you don't have cat it gets a lot trickier but is still probably doable. Edit your question if that's the case.

Hope this helps and good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.