想知道如何将你的Linux服务器清空空吗?
作者:网络转载 发布时间:[ 2013/12/9 13:46:06 ] 推荐标签:
#!/bin/bash # # This script will absolutely kill a RHEL/CentOS/Fedora server. Use with extreme caution. # Tested with several CentOS/RHEL versions only. Run as root user. # 10.20.11 Paul Venezia (pvenezia@pvenezia.com) # zeroscript="/var/ramdisk/zeroscript.sh" echo "******************************************************************* ** This will permanently kill this Linux system and erase every ** ** local disk and filesystem. In other words, you better be ** ** REALLY REALLY SURE you want to do this on this system. ** *******************************************************************" echo -n "Are you absolutely sure you want to do this? [yes|no]: "; read yn if [ -z $yn ] || [ $yn != "yes" ]; then echo "Aborting" exit 1 fi echo -n "How many zeroing passes? "; read zeropass if [ -z $zeropass ] || [ $zeropass -lt 1 ]; then echo "Invalid number of passes specified. Aborting." exit 1 fi echo -n "Automatically shutdown? [yes|no] "; read asd echo "Okay, here we go..." echo "Making and populating ramdisk (512MB)..." mkdir -p /var/ramdisk mount -t tmpfs none /var/ramdisk -o size=512m # You may need to adjust this depending on the amount of RAM in the box mkdir -p /var/ramdisk/var/run for f in dev bin lib lib64 sbin etc; do cp -pr /$f /var/ramdisk done cp -pr /var/run /var/ramdisk/var echo "Stopping services, it's probably safe to ignore any errors..." for s in httpd acpid anacron atd auditd autofs avahi-daemon bluetooth cpuspeed crond cups firstboot gpm haldaemon hidd hplip irqbalance iscsi iscsid kudzu lm_sensors lvm2-monitor mcstrans mdmonitor messagebus microcode_ctl netfs nfslock pcscd portmap rawdevices readahead_early restorecond rpcgssd rpcidmapd sendmail smartd sshd syslog vmware-tools xfs yum-updatesd; do service $s stop done echo "Placing zeroing script..." echo "#!/bin/bash" > $zeroscript for i in `fdisk -l | grep Disk | awk '{print$2}' | sed -e s/:// | grep -v /dev/md`; do DU=$DU" "$i DSK=`basename $i` BLKS=$((`grep -w $DSK /proc/partitions | awk '{print$3}'` * 2)) # account for 512/1k blocksizes BS=512 echo "echo "Zeroing $i (dd if=/dev/zero of=$i bs=$BS count=$BLKS) ..."" >> $zeroscript for (( c=1; c<=$zeropass; c++ )); do echo "echo "Pass $c..."" >> $zeroscript echo "dd if=/dev/zero of=$i bs=$BS count=$BLKS" >> $zeroscript done echo "dd if=/dev/zero of=$i bs=512 count=1" >> $zeroscript # Just to make sure done echo "echo "Disk(s)$DU have been zeroed $zeropass times"" >> $zeroscript if [ $asd = 'yes' ]; then echo "echo "Shutting down..."" >> $zeroscript echo "sleep 5 && /sbin/poweroff -n -d -f" >> $zeroscript fi chmod +x $zeroscript echo "Turning off swap..." && swapoff -a echo "Entering chroot..." chroot /var/ramdisk /`basename $zeroscript`
该脚本中尽管存在着一些过于强横的霸王内容,但却确实能帮大家完成任务。它本身是专门用于RHEL(即红帽企业版Linux)及CentOS(即社区企业操作系统)的,但只需经过简单的调整即可奏效于任何类Unix操作系统之上。不过请大家小心,这个脚本存在的目的是追求完全的破坏性。如果破坏不是各位的需求,或者大家不了解自己在做什么,请千万不要尝试。
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。
相关推荐
Linux下开源的DDR压力测试工具曝Linux恶意软件:让树莓派设备挖掘数字货币linux系统中不同颜色的文件夹及根目录介绍软件测试工程师必知必会Linux命令Linux下DNS服务器配置如何成为不可替代的Linux运维工程师?详解Linux进程(作业)的查看和杀死Linux 日志定时轮询流程详解比特币勒索病毒不只Windows系统有,Linux版的来了Linux日志定时轮询流程详解Linux iommu和vfio概念空间解构Linux系统如何低于TCP洪水攻击Linux无损调整分区大小Linux下防火墙配置实例Linux使用Jexus托管Asp.Net Core应用程序Linux中引号的那些事
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11热门文章
常见的移动App Bug??崩溃的测试用例设计如何用Jmeter做压力测试QC使用说明APP压力测试入门教程移动app测试中的主要问题jenkins+testng+ant+webdriver持续集成测试使用JMeter进行HTTP负载测试Selenium 2.0 WebDriver 使用指南