# swap error ...



## saperit (Oct 25, 2012)

I have a mistake at computer switching off:

```
swap_pager: I/O error - pagein failed; blkno 262, size 4096, error 5
panic: swap_pager_force_pagein: read from swap failed
cpuid = 0
KDB: stack backtrace:
#0 0xc0a4b157 at kdb_backtrace+0x47
#1 0xc0a186b7 at panic+0x117
#2 0xc0c6f8ac at swapoff_one+0x43c
#3 0xc0c6fd7b at swapoff_all+0x14b
#4 0xc0a181e3 at kern_reboot+0x4b3
#5 0xc0a18788 at sys_reboot+0x88
#6 0xc0d49315 at syscall+0x355
#7 0xc0d32af1 at Xinit0x80_syscall+0x21
```


```
[B]$ uname -a[/B]
FreeBSD res2500 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Oct  9 07:09:21 EEST 2012     root@res2500:/usr/obj/usr/src/sys/GENERIC  i386

[B]$ cat /etc/rc.conf[/B]
hostname="res2500"
keymap="ua.koi8-u.shift.alt.kbd"
ifconfig_rl0="DHCP"
sshd_enable="YES"
moused_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

fusefs_enable="YES"

#hald_enable="YES"
#dbus_enable="YES"

pbid_enable="YES"

swapfile="/mnt/swap0"

cupsd_enable="YES"
devfs_system_ruleset="system"

#fsck_y_enable="YES"
#background_fsck="NO"


[B]$ swapinfo[/B]
Device          1K-blocks     Used    Avail Capacity
/dev/md0          1048576    26632  1021944     3%

[B]$ df -h[/B]
Filesystem      Size    Used   Avail Capacity  Mounted on
/dev/ada0s1a     37G     26G    7.9G    77%    /
devfs           1.0k    1.0k      0B   100%    /dev
linprocfs       4.0k    4.0k      0B   100%    /compat/linux/proc
```

I did installation itself, having only appropriated a root of file system, then thought I will adjust all, but here at installation there is such mistake, it appears when swap was though 1 percent, what else data to show the computer?

connected the pumping file on this statiya
http://www.freebsd.org/doc/ru_RU.KOI8-R/books/handbook/adding-swap-space.html


----------



## wblock@ (Oct 25, 2012)

See PR 168544 for a patch to avoid this.


----------



## saperit (Oct 28, 2012)

the mistake appears I will copy the file and I will show as it is, and it is necessary what to change ?

```
#!/bin/sh
#
# Add additional swap files
#
# $FreeBSD: release/9.0.0/etc/rc.d/addswap 197139 2009-09-12 22:13:41Z hrs $
#

# PROVIDE: addswap
# REQUIRE: FILESYSTEMS
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="addswap"
start_cmd="addswap_start"
stop_cmd="addswap_stop"

addswap_start()
{
	case ${swapfile} in
	[Nn][Oo] | '')
		;;
	*)
		if [ -w "${swapfile}" ]; then
			echo "Adding ${swapfile} as additional swap"
			mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev}
		fi
		;;
	esac
}

addswap_stop()
{
  case ${swapfile} in
   [Nn][Oo] | '')
                ;;
    *)
           mdev=`mdconfig -lv | grep "${swapfile}" | cut -f1`
          swapctl -l | grep -q "/dev/$mdev"
           if [ $? -eq 0 ]; then
                 echo "Dismounting swapfile ${swapfile}"
                     swapoff "/dev/$mdev" && mdconfig -d -u "$mdev"
            fi
            ;;
   esac
}

load_rc_config $name
run_rc_command "$1"
```


yes there still there is a swap1 file, only without connection of a swap of the program could fall, and as connected new that normally, here /etc/rc.d/swap1 file contents

```
#!/bin/sh
#
# $FreeBSD: release/9.0.0/etc/rc.d/swap1 189694 2009-03-11 12:55:12Z guido $
#

# PROVIDE: localswap
# REQUIRE: disks
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="swap1"
start_cmd='swapon -aq'
stop_cmd=':'

load_rc_config swap
run_rc_command "$1"
```


----------



## wblock@ (Oct 28, 2012)

I don't understand post #3.

If a swapfile is used, and there is anything in swap at shutdown, the machine will panic.  It is relatively harmless, because all the filesystems have already been unmounted at that time.  The patch in PR 168544 adds code to /etc/rc.d/addswap which unmounts the swap file before shutdown, preventing the panic.


----------



## Beeblebrox (Oct 28, 2012)

@saperit
Why are you using up your RAM as swap (/dev/md0)? It makes no sense! If you are going to swap to RAM, just disable swap because the purpose of swap is to use a section of the HDD as "virtual RAM".

So essentially your setup reserves (disables) a section of RAM so that it may (or may not) use it as virtual RAM?


----------



## wblock@ (Oct 28, 2012)

md(4) can allocate a disk file as a device.  I do this with swap on an SSD, so that the swap space uses TRIM.  It also lets you easily change the size of swap, just create a bigger or smaller swap file.  (The idea wasn't mine, it was suggested by throAU in http://forums.freebsd.org/showthread.php?t=31500.)


----------



## Beeblebrox (Oct 28, 2012)

Aaah yes, the old "paging file" in windows systems. That has actually been around in FreeBSD for a while and is in the handbook (or was when I started out).

Of course, SSD is a game changer for the whole swap thing and I was not aware (or forgot) that file swap interfaces through /dev/mdx.


----------



## saperit (Oct 29, 2012)

@Beeblebrox
if not to use SWAP that many programs you will not start and they fall

my kompryyuter old p-III 1 GHz, 512 Mb RAM,  32 MB video card ...

I still test yesterday a mistake Ð¿Ð¾Ñ‡ÐµÐ¼ÑƒÑ‚Ð¾ didn't appear though SWAP was used, I checked, such feeling that it for Skype
, well while to speak early


----------



## saperit (Dec 4, 2012)

*thanks for the help*, appeared there was a problem in Skype, I installed Skype through pbi-manager, then Skype 2.1 but the mistake was, established skype-devel-2.2.0.35 everything normally. For all the time the mistake didn't appear

RU: _ÑÐ¿Ð°ÑÐ¸Ð±Ð¾ Ð·Ð° Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒ, Ð¾ÐºÐ°Ð·Ð°Ð»Ð¾ÑÑŒ Ð±Ñ‹Ð»Ð° Ð¿Ñ€Ð¾Ð±Ð»ÐµÐ¼Ð°  Ð² Skype, Ñ ÑƒÑÑ‚Ð°Ð½Ð¾Ð²Ð¸Ð» Skype Ñ‡ÐµÑ€ÐµÐ· pbi-manager, Ð¿Ð¾Ñ‚Ð¾Ð¼ ÑÐºÐ°Ð¹Ð¿ 2.1 Ð½Ð¾ Ð¾ÑˆÐ¸Ð±ÐºÐ° Ð±Ñ‹Ð»Ð°, ÑƒÑÑ‚Ð°Ð½Ð¾Ð²Ð¸Ð» skype-devel-2.2.0.35 Ð²ÑÐµ Ð½Ð¾Ñ€Ð¼Ð°Ð»ÑŒÐ½Ð¾. Ð—Ð° Ð²ÑÐµ Ð²Ñ€ÐµÐ¼Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ° Ð½Ðµ Ð¿Ð¾ÑÐ²Ð¸Ð»Ð°ÑÑŒ_


----------

