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 ################################################################################
9 PATH="/bin:/sbin:/usr/bin:/usr/sbin"
12 # XDIALOG_HIGH_DIALOG_COMPAT=1
13 # export XDIALOG_HIGH_DIALOG_COMPAT
15 [ "`id -u`" != "0" ] && exec sudo "$0" "$@"
17 #TMP="/tmp/mkdosswapfile.tmp$$"
26 # [ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
31 [ -r /etc/default/locale ] && . /etc/default/locale
35 # Find all DOS partitions
36 if [ -f /proc/partitions ]
39 for p in $(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $4}}}' /proc/partitions); do
41 hd?|sd?) partitions="$partitions /dev/$p"; ;;
45 if [ -n "$partitions" ]
47 foundp="$(LANG=C LC_ALL=C fdisk -l $partitions 2>/dev/null)"
48 for p in `echo "$foundp" | awk '/^\/dev\//{if(/FAT/){print $1}}'`
51 if mount -o ro -t vfat $p $d 2>/dev/null; then
52 [ ! -f $d/grml.swp ] && DOSPARTITIONS="$DOSPARTITIONS $p"
59 if [ -n "$DOSPARTITIONS" ]; then
61 for p in $DOSPARTITIONS; do
62 # Language-dependent Messages
65 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."
66 MESSAGE2="Bitte geben Sie an, wieviel MB Sie als SWAP verwenden wollen. Empfohlen: 60 - 128. Frei: "
67 MESSAGE3="Erzeuge swapfile 'grml.swp' auf $p..."
68 ERROR1="Leider ist nicht genug Platz auf dieser Partition ($p), es sollten mindestens 60 MB frei sein."
69 SUCCESS="Das Einrichten des Swapfiles 'grml.swp' auf $p war erfolgreich."
72 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."
73 MESSAGE2="Por favor, especifique la cantidad de espacio en disco que quiere utilizar como SWAP. Recomendado: 60 - 128. Libre: "
74 MESSAGE3="Creando archivo de memoria virtual 'grml.swp' en $p..."
75 ERROR1="Lo siento, no hay suficiente espacio libre en $p. Son necesarios al menos 60 MB."
76 SUCCESS="Archivo swap 'grml.swp' en $p creado satisfactoriamente."
79 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."
80 MESSAGE2="Please specify the amount of diskspace that you want to use as SWAP. Recommended: 60 - 128. Free: "
81 MESSAGE3="Creating swapfile 'grml.swp' on $p..."
82 ERROR1="Sorry, not enough free space on $p. At least 60 MB required."
83 SUCCESS="Swapfile 'grml.swp' on $p successfully created."
89 if mount -o umask=000,rw -t vfat $p $d; then
90 if $DIALOG --yesno "$MESSAGE1" 11 62; then
91 AVAIL=$(df -m $d | awk '/^\/dev\//{print $4}')
92 if [ "$AVAIL" -lt 60 ]; then
93 $DIALOG --msgbox "$ERROR1" 10 45
97 $DIALOG --inputbox "$MESSAGE2 $AVAIL" 8 62 "60" 2>"$TMP" || { umount "$d" ; bailout; }
99 [ "$IN" -ge 60 -a "$IN" -le "$AVAIL" ] 2>/dev/null || IN="60"
101 dd if=/dev/zero of="$f" bs=1000k count="$IN" && \
102 mkswap -v1 "$f" && swapon -v "$f" 2>/dev/null && \
103 echo "$f swap swap defaults 0 0" >>/etc/fstab
104 [ "$?" = "0" ] && { sleep 2 ; $DIALOG --msgbox "$SUCCESS" 10 45; } || umount "$d" 2>/dev/null
105 mount -o remount,ro $d
115 ERROR2="Leider sind auf Ihrem System keine geeigneten DOS-Partitionen zum Einrichten eines Swapfile vorhanden."
118 ERROR2="Lo siento, no se han encontrado particiones disponibles de tipo DOS para el fichero swap de memoria virtual."
121 ERROR2="Sorry, no DOS partitions available for swapfile."
125 $DIALOG --msgbox "$ERROR2" 10 45
130 ## END OF FILE #################################################################