menhera.sh/README.md

57 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2019-04-09 16:59:41 +08:00
# menhera.sh
Start a RAM Linux system (Debian for now) without requiring physical access to your server.
2019-04-09 17:16:27 +08:00
With `menhera.sh` you can:
2019-04-09 16:59:41 +08:00
* format your system disk or create RAID
* install a new distro
* do important maintenance or backup with nobody writing to your root filesystem
* ...
with only SSH!
"menhera" is short for "mental healer".
2019-04-09 17:01:37 +08:00
## WARNING
2019-04-09 17:23:26 +08:00
I am not responsible for bricked devices, dead HDDs and SSDs, unreplied tickets, thermonuclear war, or you getting fired because your device is hacked to mine bitcoin. Please do some research if you have any concerns about this script before using it! YOU are choosing to run this script, and if you point the finger at me for messing up your device, I will laugh at you.
2019-04-09 17:01:37 +08:00
2019-04-09 16:59:41 +08:00
## Dependencies
* Linux kernel: overlayfs and tmpfs support
* systemd
2019-04-13 10:44:33 +08:00
* bash
2019-04-09 16:59:41 +08:00
* squashfs-tools
2019-04-09 17:05:54 +08:00
* curl
2019-04-09 17:23:26 +08:00
* ~400MiB RAM in theory
2019-04-09 16:59:41 +08:00
## Usage
2019-04-09 17:23:26 +08:00
1. Save your work
1. Backup all your important files
1. Shutdown as many services and programs you can on the victim
2020-08-09 15:59:12 +08:00
1. If you use SSH to connect to the server, make sure you can log in directly as root using SSH with a password
2019-04-09 17:23:26 +08:00
1. run the script, and follow the instructions
2019-04-09 17:15:03 +08:00
2019-04-09 18:16:55 +08:00
`menhera.sh` will try to download a new rootfs into the memory, replace the old rootfs and kill all processes accessing the old rootfs. The old rootfs will be mounted to `/mnt/oldroot`. An simplified example filesystem structure after running `menhera.sh` on my test VPS:
2019-04-09 17:15:03 +08:00
```
root@localhost:~# findmnt
TARGET SOURCE FSTYPE OPTIONS
/ overlay overlay rw,relatime,lowerdir=/tmp/menhera/newrootro,upperdir=/tmp/menhera/newrootrw,workdir=/tmp/menhera/overlayfs_workdir
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
├─/dev udev devtmpfs rw,nosuid,relatime,size=1014856k,nr_inodes=253714,mode=755
├─/run tmpfs tmpfs rw,nosuid,noexec,relatime,size=205236k,mode=755
├─/mnt/oldroot /dev/md0p1 ext4 rw,relatime,discard,data=ordered
└─/tmp tmpfs tmpfs rw,relatime
└─/tmp/menhera tmpfs tmpfs rw,relatime
└─/tmp/menhera/newrootro /dev/loop0 squashfs ro,relatime
```
2019-04-09 16:59:41 +08:00
## Thanks
* This project is inspired by [marcan/takeover.sh](https://github.com/marcan/takeover.sh)
* The major code came from [a maintenance writeup on my blog](https://blog.swineson.me/debian-9-csm-online-convert-root-partition-to-raid/) (in Simp. Chinese)
2019-04-13 10:44:33 +08:00
* [xTom.com](https://xtom.com/) donated a VPS for my testing