Gentoo Archives: gentoo-user

From: Nils Larsson <nisselarsson@××××.se>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] activating swap by udev event
Date: Thu, 01 Jul 2010 14:28:13
Message-Id: 1277993156.10569.21.camel@growl
In Reply to: [gentoo-user] activating swap by udev event by SpaceCake
1 tor 2010-07-01 klockan 15:49 +0200 skrev SpaceCake:
2 > Hi,
3 >
4 >
5 > I would like to increase the speed of my machine by putting some swap
6 > on a fast pendrive. It is working manually by starting a script
7 >
8 > swapon -s
9 > swapon -p -1 /dev/sdb1
10 > swapoff /dev/sda6
11 > swapon -p -2 /dev/sda6
12 > swapon -s
13 >
14 > but, I would like to make it automatic by creating an udev rule, so
15 > when I plug in that device the swap space is automatically activated
16 > and the priority is changed. I've tried to google for a solution like
17 > this, but I did not find. Maybe you already have some script at
18 > hand :) can you please share this with me?
19 >
20 > Thanks
21 > Laszlo
22 >
23
24 I tried doing something like this awhile ago. The problem I encountered
25 was that I couldn't disable the swap once the the device was removed,
26 swapoff couldn't find the device path(as it wasn't there anymore) but
27 the system thought the swap was still there. So plugging and unplugging
28 the swap stick got my system thinking it had loads of swap.
29
30 But I didn't experiment all that much, maybe there's a way. Tricking
31 udev to hold on to the device node until swap is disabled might be
32 possible.