dell 的 Remove Operating System 代码
2009-01-01 xiao H Posted in shell
在公社看到 WeiMingzhi 贴的Dell 预装SLED10机子上提供的删除OS 脚本,觉得蛮好特留一个备份。
title Remove Operating System
root (hd0,2)
kernel /vmlinuz root=/dev/disk/by-label/root ro init=/sbin/remove-os.sh resume=/dev/sda5 splash=silent showopts
initrd /initrdremove-os.sh
dell:/sbin # cat remove-os.sh #!/bin/sh abort() { echo "OS removal ABORTED. System will reboot in 30 seconds." echo "" echo "NO CHANGES HAVE BEEN MADE TO THE HARD DISKS." sleep 30 /etc/init.d/reboot } echo "Initializing keyboard..." export PREVLEVEL=N export RUNLEVEL=S /etc/init.d/earlykbd start CORRECT_ANSWER="REMOVE OPERATING SYSTEM" echo -e "\n\n" echo -e 'WARNING! WARNING! WARNING!' echo -e "" echo -e "This operation will remove the Operating System (OS) from your computer" echo -e "All personal files on this system will be lost." echo -e "The information will not be recoverable." echo -e "" echo -e "ALL DATA ON YOUR HARD DRIVES WILL BE PERMANENTLY AND IRRETRIEVABLY DESTROYED IF YOU CONTINUE.\n" echo -e "" echo -e "To proceed with the Operating System removal, please type: $CORRECT_ANSWER" read -p "Type any other text to abort: " answer if [ "$answer" != "$CORRECT_ANSWER" ]; then abort fi echo echo "Hard Drive erasure begins in 10 seconds. Power off system to abort (last chance)..." sleep 10 # Remove all parts save N1 DRIVE=`fdisk -l | grep -m1 "Disk" | awk '{print $2}' | cut -d':' -f1` echo "DRIVE = "$DRIVE if [ ! -e $DRIVE ]; then break; fi echo "0,0,0,-" | sfdisk -uS -N2 --force --no-reread $DRIVE echo "0,0,0,-" | sfdisk -uS -N3 --force --no-reread $DRIVE echo "0,0,0,-" | sfdisk -uS -N4 --force --no-reread $DRIVE echo "Operating System has been removed. The system is now unbootable. You must reinstall an operating system for the computer." sleep 600000


……..