2 # Filename: mkdosswapfile
3 # Purpose: create GRML swapfile on an existing DOS partition
4 # Authors: (c) Klaus Knopper Mar 2001, (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Fre Apr 20 00:40:15 CEST 2007 [mika]
8 ################################################################################
10 PATH="/bin:/sbin:/usr/bin:/usr/sbin"
13 # XDIALOG_HIGH_DIALOG_COMPAT=1
14 # export XDIALOG_HIGH_DIALOG_COMPAT
16 [ "`id -u`" != "0" ] && exec sudo "$0" "$@"
18 #TMP="/tmp/mkdosswapfile.tmp$$"
27 # [ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
32 [ -r /etc/default/locale ] && . /etc/default/locale
36 # Find all DOS partitions
37 if [ -f /proc/partitions ]
40 for p in $(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $4}}}' /proc/partitions); do
42 hd?|sd?) partitions="$partitions /dev/$p"; ;;
46 if [ -n "$partitions" ]
48 foundp="$(LANG=C LC_ALL=C fdisk -l $partitions 2>/dev/null)"
49 for p in `echo "$foundp" | awk '/^\/dev\//{if(/FAT/){print $1}}'`
52 if mount -o ro -t vfat $p $d 2>/dev/null; then
53 [ ! -f $d/grml.swp ] && DOSPARTITIONS="$DOSPARTITIONS $p"
60 if [ -n "$DOSPARTITIONS" ]; then
62 for p in $DOSPARTITIONS; do
63 # Language-dependent Messages
66 MESSAGE1="Moechten Sie eine SWAP-Datei 'grml.swp' fuer GRML auf Ihrer bestehenden DOS-Partition $p anlegen? Eine solche SWAP-Datei ermoeglicht es Ihnen, trotz geringem Hauptspeicher Programmpakete wie KDE zu benutzen. Sie koennen diese Datei nach Beendigung Ihrer GRML-Session gefahrlos wieder loeschen."
67 MESSAGE2="Bitte geben Sie an, wieviel MB Sie als SWAP verwenden wollen. Empfohlen: 60 - 128. Frei: "
68 MESSAGE3="Erzeuge swapfile 'grml.swp' auf $p..."
69 ERROR1="Leider ist nicht genug Platz auf dieser Partition ($p), es sollten mindestens 60 MB frei sein."
70 SUCCESS="Das Einrichten des Swapfiles 'grml.swp' auf $p war erfolgreich."
73 MESSAGE1="¿Quiere crear un fichero de memoria virtual (swap) 'grml.swp' en su partición DOS existente $p? Un fichero swap le permite utilizar grandes aplicaciones como KDE incluso si su ordenador tiene poca memoria. Puede borrar tranquilamente el fichero swap una vez haya finalizado su sesión con GRML."
74 MESSAGE2="Por favor, especifique la cantidad de espacio en disco que quiere utilizar como SWAP. Recomendado: 60 - 128. Libre: "
75 MESSAGE3="Creando archivo de memoria virtual 'grml.swp' en $p..."
76 ERROR1="Lo siento, no hay suficiente espacio libre en $p. Son necesarios al menos 60 MB."
77 SUCCESS="Archivo swap 'grml.swp' en $p creado satisfactoriamente."
80 MESSAGE1="Do you want to create a swapfile 'grml.swp' on your existing DOS partition $p? A swapfile allows you to use huge application packages like KDE even if your computer is low on memory. You can safely delete the swapfile after finishing your GRML session."
81 MESSAGE2="Please specify the amount of diskspace that you want to use as SWAP. Recommended: 60 - 128. Free: "
82 MESSAGE3="Creating swapfile 'grml.swp' on $p..."
83 ERROR1="Sorry, not enough free space on $p. At least 60 MB required."
84 SUCCESS="Swapfile 'grml.swp' on $p successfully created."
90 if mount -o umask=000,rw -t vfat $p $d; then
91 if $DIALOG --yesno "$MESSAGE1" 11 62; then
92 AVAIL=$(df -m $d | awk '/^\/dev\//{print $4}')
93 if [ "$AVAIL" -lt 60 ]; then
94 $DIALOG --msgbox "$ERROR1" 10 45
98 $DIALOG --inputbox "$MESSAGE2 $AVAIL" 8 62 "60" 2>"$TMP" || { umount "$d" ; bailout; }
100 [ "$IN" -ge 60 -a "$IN" -le "$AVAIL" ] 2>/dev/null || IN="60"
102 dd if=/dev/zero of="$f" bs=1000k count="$IN" && \
103 mkswap -v1 "$f" && swapon -v "$f" 2>/dev/null && \
104 echo "$f swap swap defaults 0 0" >>/etc/fstab
105 [ "$?" = "0" ] && { sleep 2 ; $DIALOG --msgbox "$SUCCESS" 10 45; } || umount "$d" 2>/dev/null
106 mount -o remount,ro $d
116 ERROR2="Leider sind auf Ihrem System keine geeigneten DOS-Partitionen zum Einrichten eines Swapfile vorhanden."
119 ERROR2="Lo siento, no se han encontrado particiones disponibles de tipo DOS para el fichero swap de memoria virtual."
122 ERROR2="Sorry, no DOS partitions available for swapfile."
126 $DIALOG --msgbox "$ERROR2" 10 45
131 ## END OF FILE #################################################################