bergman on 24 Aug 2009 11:30:57 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Swap on SD



In the message dated: Mon, 24 Aug 2009 14:08:57 EDT,
The pithy ruminations from Art Alexion on 
<Re: [PLUG] Swap on SD> were:
=> --nextPart2061723.12B2IP0AzF
=> Content-Type: text/plain;
=>   charset="iso-8859-1"
=> Content-Transfer-Encoding: quoted-printable
=> Content-Disposition: inline
=> 
=> On Sunday 16 August 2009 15:03:25 bergman@merctech.com wrote:
=> > In the message dated: Sun, 16 Aug 2009 14:42:58 EDT,
=> > The pithy ruminations from Casey Bralla on
=> > <Re: [PLUG] Swap on SD> were:
=> > =3D> To create a swap:
=> 
=> > =3D> 4. Edit /etc/fstab to point to /dev/SDHC1
=> 

	[SNIP!]

=> 
=> But I have questions on the script syntax suggested below.

What I suggested below was pseudo-code, not valid shell syntax, and shouldn't 
be taken literally. 

=> 
=> >
=> >
=> > Given that you're talking about swapping onto a removable device, I'd
=> > suggest not mounting swap via /etc/fstab. In case the SD card is removed
=> > before boottime, the machine may be unbootable. However, if you do
=> > something like this in /etc/rc.local (or the moral equivalent for whatever
=> > distro you're using), it's a bit more resiliant:
=> >        =20
=> >         check if the /dev/SDHC1 card is available (ie. check files in
=> > /proc, use lspci, use dmidecode, etc.)

Use some method, appropriate to your distro & hardware to make sure that there 
is an SD card in the slot. Possible methods include:
	checking entries in /proc
	the commands "lspic", "dmidecode"


=> >
=> >         if [ /dev/SDHC1 ] ; then
=> >                 swapon /dev/SDHC1
=> >         fi
=> 
=> OK, my /etc/rc.local now only contains comments and the line
=> 
=> 	exit 0
=> 
=> The card/partition is /dev/sdc1
=> 
=> Do I just add the lines (literal)

Nope.

=> 
=> 	if [ /dev/sdc1 ] ; then
Not valid.

=> 		swapon /dev/sdc1
=> 	fi
=> 
=> and leave "exit 0" at the end?
Yes.

=> 
=> Can I use UUID syntax, something like
Sure.

This is a better approach. Possible commands to get the UUID and determine if 
it's available are:

	tune2fs
	findfs
	vol_id (/lib/udev/vol_id)

=> 
=> 	if [ UUID=3Daeiou334455 ] ; then
=> 		swapon -a

I'd also add some error checking at this point, like:

		if [ $? != 0  ] ; then
			echo "Failed to activate swap on device with UUID $UUID"
		fi
=> 	fi
=> 
=> in case a different removable drive grabs sdc1?
=> 

Good plan.

Mark

=> Thanks.
=> 
=> --nextPart2061723.12B2IP0AzF
=> Content-Type: application/pgp-signature; name=signature.asc 
=> Content-Description: This is a digitally signed message part.
=> 
=> -----BEGIN PGP SIGNATURE-----
=> Version: GnuPG v1.4.9 (GNU/Linux)
=> 
=> iJwEAAECAAYFAkqS1zkACgkQQsb+hggjRi7JSAP8Cdkm03iiuT25oMiZphYXhy4c
=> uJSNurUO3tC99ITrMgMhk3yFktW+uXz57Kund/hmlKAhLY/uK7505yE9L6g5IJER
=> lmSahXZAdNetCDhtT3qT8ephbqyDLMqvwlGCu8mGLyWHi1yXeYm8f8nw+3tx0ft/
=> kSklmrc5BZUcYvNh3UI=
=> =kuEP
=> -----END PGP SIGNATURE-----
=> 
=> --nextPart2061723.12B2IP0AzF--
=> 



-----
Mark Bergman    Biker, Rock Climber, Unix mechanic, IATSE #1 Stagehand

http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=bergman%40merctech.com

I want a newsgroup with a infinite S/N ratio! Now taking CFV on:
rec.motorcycles.stagehands.pet-bird-owners.pinballers.unix-supporters
15+ So Far--Want to join? Check out: http://www.panix.com/~bergman 


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug