Reputation: 147
I have created a monitoring system which restarts the VM when it becomes unresponsive or has crashed internally. I want to simulate the VM crashing, so I can test my monitoring setup. I tried the fork-bomb but it did not crash it. I also tried calling processes in an infinite loop.
Need a clean way of crashing the VM successfully, without any later consequences.
Upvotes: 2
Views: 8959
Reputation: 31
First enable SysRq in your vm, and type the following and system will crash.
echo c > /proc/sysrq-trigger
Here's link! for details.
When the magic SysRq key combination is pressed with the command "c", it causes a kernel panic.
Upvotes: 3
Reputation: 1290
This would cause a kernel panic. Linux :
echo c > /proc/sysrq-trigger
More info here
On Linux, you might have to echo 1 > /proc/sys/kernel/sysrq
before you are able to
echo c > /proc/sysrq-trigger
I know you already used a fork bomb i just write it again for reference, or maybe you could also try that again:
:(){ :|:& };:
Compile the following code into a module and insmod it, sure you should get a panic:
`
static int crash_module_init(void){
printf("crash module starting\n");
int *p = 0;
printk("%d\n", *p);return 0;
}
static void crash_module_exit(void){
printf("crash module exiting\n");
}
module_init(crash_module_init);
module_exit(crash_module_exit);
`
Upvotes: 5
Reputation: 20980
As OP mentioned, he is using ping $VM_IP
to test if the VM has crashed. So, if ping
fails, it would be considered as VM crash. So, the least intrusive change to trigger failure recovery would be to disable the network.
service networking stop # Or maybe
service network stop # or
ifconfig eth0 down # Or whatever your interface's name is... eth1/eno1 etc...
Upvotes: 1