Wie belbel im ursprünglichen Artikel richtig angemerkt hat, macht es wenig Sinn, eine SWAP-Datei auf einer normalen Partition zu benutzen. Sinnvoller ist eine SWAP-Partition.
Für diejenigen, die bereits den Weg mit der SWAP-Datei gegangen sind, beschreibe ich hier, wie man dies entsprechend ändert.
Nachdem man sich per SSH mit dem FR verbunden hat, wird fdisk gestartet: fdisk /dev/mmcblk0 und der Typ der bisherigen ersten Partition geändert. Mit dem Kommando t lässt sich die system id ändern, der hex code für Linux/SWAP ist 82 (die verfügbaren Codes lassen sich an dieser Stelle mit dem Kommando L anzeigen, im normalen fdisk-Modus mit dem Kommando l). Diese Änderung wird mit dem Kommando w gespeichert.
debian-gta02:/# fdisk /dev/mmcblk0
The number of cylinders for this disk is set to 17792.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/mmcblk0: 510 MB, 510132224 bytes
8 heads, 7 sectors/track, 17792 cylinders
Units = cylinders of 56 * 512 = 28672 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 4465 125016+ 83 Linux
/dev/mmcblk0p2 4466 17792 373156 83 Linux
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/mmcblk0: 510 MB, 510132224 bytes
8 heads, 7 sectors/track, 17792 cylinders
Units = cylinders of 56 * 512 = 28672 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 4465 125016+ 82 Linux swap / Solaris
/dev/mmcblk0p2 4466 17792 373156 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.Die Änderung steht allerdings erst nach einem Neustart zur Verfügung. Zuvor wird die SWAP-Partition aktiviert:
mkswap /dev/mmcblk0p1
Nun deaktiviert man noch die alte SWAP-Datei, indem man die Datei fstab editiert: nano /etc/fstab. Die beiden letzten Zeilen werden gelöscht und die neue SWAP-Partition wird eingetragen:
Alte fstab:
rootfs / auto defaults,errors=remount-ro,noatime 0 1 /dev/mtdblock6 /mnt/flash jffs2 defaults,noatime,noauto 0 2 proc /proc proc defaults 0 0 tmpfs /tmp tmpfs defaults,noatime 0 0 tmpfs /var/lock tmpfs defaults,noatime 0 0 tmpfs /var/run tmpfs defaults,noatime 0 0 tmpfs /var/cache/apt tmpfs defaults,noatime 0 0 /dev/mmcblk0p2 /home ext2 defaults,noatime 0 0 /dev/mmcblk0p1 /mnt/msd ext2 defaults,noatime 0 0 /mnt/msd/swapfile none swap sw 0 0
Neue fstab:
rootfs / auto defaults,errors=remount-ro,noatime 0 1 /dev/mtdblock6 /mnt/flash jffs2 defaults,noatime,noauto 0 2 proc /proc proc defaults 0 0 tmpfs /tmp tmpfs defaults,noatime 0 0 tmpfs /var/lock tmpfs defaults,noatime 0 0 tmpfs /var/run tmpfs defaults,noatime 0 0 tmpfs /var/cache/apt tmpfs defaults,noatime 0 0 /dev/mmcblk0p2 /home ext2 defaults,noatime 0 0 /dev/mmcblk0p1 none swap sw 0 0
Jetzt erfolgt der reboot und im Anschluss überzeugt man sich mit dem Befehl free, dass alles geklappt hat:
debian-gta02:~# free
total used free shared buffers cached
Mem: 120808 118596 2212 0 396 45916
-/+ buffers/cache: 72284 48524
Swap: 125008 0 125008Abschließend kann noch das Verzeichnis /mnt/msd gelöscht werden:
rm -R /mnt/msd



