FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 06-10-2008, 06:01 PM
Dexter Filmore
 
Default script makes kernel panic

Got a laptop here (Samsung X22), WinXP Pro and data partition in /dev/sda[23].
Wrote this script to backup both partitions 1:1 to an external USB disk.
Teh script itself works absolutely as intended.

BUT: I added an entry to GRUB's menu.lst like that:

title Windows XP Backup
root (hd0,4)
kernel /boot/vmlinuz-2.6.18-6-686 root=/dev/sda5 rw init=/sbin/windows_backup
initrd /boot/initrd.img-2.6.18-6-686
savedefault

When I select that entry, kernel comes up, script is executed alright, but after the script called
"halt" it just sits there and eventually throws a kernel panic - and I have no clue why.

If someone has pointers?
(Messages partly in german but I added comments. If anything is unclear just ask.
But not about that it's newbie-ish, I know that )

Dex





################################################## ##################
#!/bin/bash
#kernel message to tty10
CONSOLE=10
openvt -c "$CONSOLE" -- /bin/true || true
setlogcons "$CONSOLE" || true

#...
/usr/bin/clear


#wait a couple of seconds so the kernel sees usb disks
echo Warte, bis alle Platten da sind....
sleep 5

# Variables
BACKUP_DST=/mnt/backup #set backup dest
GREP=/bin/grep
MOUNT=/bin/mount
UMOUNT=/bin/umount
BKP_PART_MNTPOINTS="/mnt/daten /mnt/windows" #mount points to partitions to backup
BKP_PART[0]=/dev/sda2 #backup src 0
BKP_PART_NAME[0]="windowsxp" #name for src 0
BKP_PART[1]=/dev/sda3 #and so on
BKP_PART_NAME[1]="daten"
BKP_MBR_DISK=/dev/sda #disk that hold the mbr to backup
HALT=/sbin/halt

#i18n
not_mounted="ist nicht angeschlossen oder eingehängt"
error_msg="Fehler"
STILL_MOUNTED="Kann Quellpartitionen nicht aushängen."
RETRY="Nochmal versuchen"
SHUTDOWN="Abbrechen und herunterfahren."
UNKN_OPT="Unbekannte Option"
ATTACH_OR_BUST="Schliessen Sie die Platte an oder fahren Sie herunter"


function chk_backup_disk { # check if the destination disk is mounted
$UMOUNT $BACKUP_DST >/dev/null 2>&1 #umount backup disk to avoid stale mounts (greetings to USB subsys)
sync
$MOUNT $BACKUP_DST >/dev/null 2>&1 #mount backup disk again

$MOUNT | $GREP "$BACKUP_DST" > /dev/null 2>&1

if [ $? -eq 1 ]; then
echo "$error_msg: Backupmedium $not_mounted"
chk_backup_menu
fi
}

function chk_backup_menu { # called if the backup disk isn't attached
echo $ATTACH_OR_BUST
echo
echo "1. "$RETRY
echo "2. "$SHUTDOWN
read choice

case $choice in

1)
sync #just retry
chk_backup_disk
;;

2) #quit and pack it in
sys_shutdown
;;

*) #user entered bull
echo $error_msg : $UNKN_OPT
chk_backup_menu
;;
esac
}

function chk_src_not_mounted {
MOUNTED=0 #helper var. if 1 sources are still mounted
for i in $BKP_PART_MNTPOINTS; do #try and umount all sources
$UMOUNT $i > /dev/null 2>&1
done

for i in $BKP_PART_MNTPOINTS; do #now check if they are released
$MOUNT | $GREP $i > /dev/null 2>&1
if [ $? -eq 0 ]; then
MOUNTED=1
fi
done

if [ $MOUNTED -eq 1 ]; then #nag if not...
echo $error_msg : $STILL_MOUNTED
src_menu
fi
}


function src_menu { #...and ask what to do about it
echo
echo "1. "$RETRY
echo "2. "$SHUTDOWN

read choice
case $choice in
1)
sync
chk_src_not_mounted #check sources again
;;

2)
sys_shutdown #call it a day
;;

*) #user nutty
echo $error_msg : $UNKN_OPT
src_menu
;;
esac
}


function sys_shutdown {
echo Fahre System herunter...
$HALT
exit 0
}


function backup_win { # mainly what this is all about
TESTBETRIEB="-m 1M" # only a meg for testing
for i in `seq 0 10`; do # check and remove old backups
if [ -f $BACKUP_DST/${BKP_PART_NAME[$i]} ]; then
rm -f $BACKUP_DST/${BKP_PART_NAME[$i]}
fi
if [ ! ${BKP_PART[$i]} == "" ]; then # only those that exist
dd_rescue $TESTBETRIEB ${BKP_PART[$i]} $BACKUP_DST/${BKP_PART_NAME[$i]}
fi

done
sync

save_mbr # save the boot sector
sync

$UMOUNT $BACKUP_DST
sys_shutdown

}

function save_mbr {
i=1
while [ -f $BACKUP_DST/mbr$i ]; do (( i++ )); done # check available file names
dd if=$BKP_MBR_DISK of=$BACKUP_DST/mbr$i bs=512 count=1
}


################
#MAIN PART
chk_backup_disk
chk_src_not_mounted
backup_win

################### END ####################


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 06-10-2008, 08:42 PM
Cameron Hutchison
 
Default script makes kernel panic

Dexter Filmore <Dexter.Filmore@gmx.de> writes:

>Got a laptop here (Samsung X22), WinXP Pro and data partition in /dev/sda[23].
>Wrote this script to backup both partitions 1:1 to an external USB disk.
>Teh script itself works absolutely as intended.

>BUT: I added an entry to GRUB's menu.lst like that:

>title Windows XP Backup
>root (hd0,4)
>kernel /boot/vmlinuz-2.6.18-6-686 root=/dev/sda5 rw init=/sbin/windows_backup
>initrd /boot/initrd.img-2.6.18-6-686
>savedefault

>When I select that entry, kernel comes up, script is executed alright,
>but after the script called "halt" it just sits there and eventually
>throws a kernel panic - and I have no clue why.

By default, halt calls shutdown(8), which signals init(8) to shutdown
the system. Since you are not running a standard init, that signal is
never received by anything, so halt effectively does nothing. When your
script exits, since it is running as process 1 (init) you get a kernel
panic when it exits. Init should never exit.

Try using "halt -f". Check the man page for halt to see if there are any
other options you want to use.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 04:00 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org