bergman on 16 Aug 2009 12:03:35 -0700


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

Re: [PLUG] Swap on SD



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:
=> To create a swap:
=> 
=> 1.  > cfdisk /dev/SDHC (whatever it's called) and create a new partition (you 
=> will probblyhave to erase the current one).  Make sure you set it to the 
=> correct type (type 82)
=> 2.  > mkswap /dev/SDHC1 to make the swap file
=> 3.  > swapon /dev/SDHC1 to activate the new swap
=> 4. Edit /etc/fstab to point to /dev/SDHC1


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:
	
	check if the /dev/SDHC1 card is available (ie. check files in /proc,
	use lspci, use dmidecode, etc.)

	if [ /dev/SDHC1 ] ; then
		swapon /dev/SDHC1
	fi

I'm not at all familiar with the EeePC, or whatever distro you are using, so 
the mechanism for checking the existance of the SD card is left up to you. 
Alternatively, if you format the SD card (jffs?) and make a swapfile on the 
card[1], then you could do:

	mount /dev/SDHC1 /mnt/sd 
	if [ $? != 0 ] ; then
		echo /dev/sdhc1 not mounted
		exit 1
	fi
	if [ -f /mnt/sd/swapfile ] ; then
		# for the really paranoid...
		file /mnt/sd/swapfile | grep -q "swap file"
		if [ $? != 0 ] ; then
			echo /mnt/sd/swapfile is not a swap file
			exit 2
		else
			swapon /mnt/sd/swapfile 
			if [ $? != 0 ] ; then
				echo error using /mnt/sd/swapfile as a swapfile
				exit 3
			fi
		fi

	fi

Mark

=> 
=> 
=> I don't know if SDHC is fast or not, but I think you may be smart to try to 
=> minimize the "gratuitous" writes to the SSD
=> 
=> 
=> 
=> On Sunday August 16, 2009 2:34:05 pm Art Alexion wrote:
=> > I have been configuring EeePCs without swap to minimize wear on the SSD. 
=> > It usually only matters with Firefox.
=> >
=> > The Eee 1000 comes with a built in SD reader.  I figure that I can direct
=> > swap there.  If it fails, the cost of an SD card is minimal (4 GB = $14 at
=> > Target today).
=> >
=> > Two questions:
=> >
=> > 1) does that make sense, or is SDHC too slow for swap?
=> > 2) I have never added swap after an install.  Is there a way to make it a
=> > swap partition, or should I put a swap file there?  If the latter, do I
=> > need to reformat/repartition it for swap file use?  If I am doing that, do
=> > I just make it a swap partition?
=> >
=> > (I guess that's more than 2 questions)
=> >
=> >
=> > ___________________________________________________________________________
=> > 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
=> 
=> -- 
=> 
=> Casey Bralla
=> Chief Nerd in Residence
=> The NerdWorld Organisation
=> 
=> http://www.NerdWorld.org
=> ___________________________________________________________________________
=> 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
=> 



___________________________________________________________________________
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