Turn on my /swap partition?


Grench

Forum Addict!
Joined
Oct 3, 2008
Messages
6,629
I'm trying to trace down why the Chromium browser randomly crashes on my Pandora.


So, after reading:





I tried out the top command to find out:


SWAP: 0k total, 0k used, 0k free, 73820k cached


gparted reports


unallocated 2.00MiB


/dev/mmcblk0p1 ext2 /media/PandOS PandOS 4.88 GiB 740.82 MiB 4.16 GiB


/dev/mmcblk0p2 linux-swap Swap 1.95 GiB -- --


/dev/mmcblk0p3 ext2 /media/PanData PanData 116.13 GiB 22.07 GiB 94.05 GiB


It is a Lexar 128GB SDXC card.


So - is my swap file on and working?


gparted acknowledges the partition on the card as Swap.


top says my Swap is 0k total.


So, I opened up the Chromium browser - takes it to Mem: 251020k total, 2112336k used then try to open anything else which should start hitting the /swap file.


/Swap in top stays at 0k and I get an error: Mounting the PND failed. The application won't start. Please have a look at ....etc...


So - I don't think it's working - even though the system acknowledges that the partition is /swap.


Any ideas? Is there something I should do to 'activate' the /swap partition on my Pandora?
 
Type 'free' at a terminal, and let us see the output. It should quickly be visible whether swap is on or not.


I don't think Linux systems will automatically detect a swap partition and use it as swap. Usually that is defined in /etc/fstab. But for us, when running swap on an SD card, it just depends when things occur in the boot process.


I think 'sudo swapon /dev/mmcblk0p2' may need to be run after you boot. You could even make a little PND script that starts and stops the swap for you from the MiniMenu.
 
Gparted is only telling you that the file system on that partition is the right kind to use as swap. However, according to top, your pandora hasn't been told to actually use that swap partition.


Typically you'd add the partition to your fstab, but then typically you'd have the swap partition on a medium that's firmly attached to your machine. I'm afraid I'm not sure how this works with pandoras and SD cards -- still waiting for mine.


For a workaround, see wizardstan's suggestion in that thread you linked to. He's using a swap file, but the swapon command also works with partitions.
 
Try swapon followed by the full path of your swappartition.
 
Type 'free' at a terminal, and let us see the output. It should quickly be visible whether swap is on or not.
The swap line read all 0s.

I think 'sudo swapon /dev/mmcblk0p2' may need to be run after you boot. You could even make a little PND script that starts and stops the swap for you from the MiniMenu.
That was the key - thank you!


The 'free' command now lists 2047992 0 2047992


Now to play around with it...


Does someone have more information on including this in /etc/fstab?


Thank you!
 
Does someone have more information on including this in /etc/fstab?
Add the following line into your /etc/fstab file.



Code:
/dev/mmcblk0p2 none swap sw 0 0


The above is how swap is defined on my workstation, using your mountpoint.


Like I said, it all depends on when things occur in the boot process. If you system tries to mount swap before it bothers to check for SD cards, the above will fail.
 
Last edited by a moderator:
Hmm - not anxious to make my Pandora fail to boot at the moment - I'll try that suggestion, just not today (travel).


Is there a good way on our Pandoras (or linux in general) to duplicate the effects of the old Windows "Startup" folder? In this case since I was able to activate the /swap post-boot, wouldn't the effect be the same if it ran as some form of bash script?
 
Failure to activate swap will not cause the boot to halt. But /etc/rc.d would be the folder with boot-scripts. The two-digit number at the start decides priority. The bigger, the later in the boot process will it run. /etc/rc.local is runned when the system has booted up (that is, all scripts in /etc/rd.d has been runned and exited.)
 
Last edited by a moderator:
Have you tried taking it out to dinner? Dancing might help, too. Seductive whispering is an advanced technique that could yield results but risks the swap partition leaving you with a restraining order if applied incorrectly.
 
Which is why I usually use a swap file instead of a partition. That thing gets out of line, rm it and dd a new one.


I don't like buying engagement rings for my partition table.
 
I found a particularly annoying bit to booting off of an SDXC card with the OS, Swap and data on the same drive under a peculiar circumstance.


Please note - like all pending disasters, this sounded like a good idea at the time...


I was using an AC to USB mobile phone adapter - to a USB to OTG cable (maintenance charge while playing Vulture's Eye) and my wife wanted me to plug in her phone, a Samsung Galaxy S with a then dead battery - so she could play a game on it. So I plugged her USB to micro USB cable into my USB port to charge her phone - daisy chaining everything together.


That was fine for about 45 minutes or so. Then suddenly the Pandora threw up a 'battery low system shutdown in 24 seconds' warning - then died about 3 seconds later.


I removed the phone charger cable from the USB and hit the power switch. At that point the Pandora would boot up to XFCE, but could not launch a terminal prompt (I had terminal running at crash). Vulture's eye would not start either. The battery was reading 45%.


Recovery took re-formatting the PandOS partition and the /swap partition on the 128GB SDXC card, re-copying the OS over from NAND, removing the application data for Vulture's eye (corrupted the whole directory) - then re-launching from the PND file. No additional ill-effects have been found.


What I think happened: Because her phone was pulling the full 500ma through the USB port AND I was using the Pandora - I was using considerably more juice than the ~500ma that the charger plug was able to provide through the OTG port. So - charging her phone was pulling current directly from my battery at a rapid rate. When a battery is discharged rapidly it can bungee to less charge than it really has - the cells need a chance to catch up. After the additional draw was removed and the battery had a chance to recover, things were fine.


On the 128GB SDXC front, any program that was open and running at the time of the crash was corrupted. So, Terminal and Vulture's Eye were toast - as well as the /swap partition.


So - the lesson learned is to be careful when using high draw devices through the USB port for extended periods of time. It can crash your system rather dramatically. Having a backup OS on the NAND and booting off of the SDXC at least gave me a short path to recover the device.


Your mileage may vary.
 
Yeah, sounds like the filesystem was corrupted when the system died. Advantage goes to a journaled filesystem, but that does eat up the life of the card quicker.
 
Is there a good way to scan the filesystem for errors? I'd like to know if I got 'everything' or if I missed something that can be fixed.
 
File this under 1001 ways to do something in Linux.


In /etc/init.d/bootmisc.sh I added one line to just before the end of it. Last two lines now look like:


swapon /dev/mmcblk0p2


: exit 0


My swap now 'turns on' at boot.


Now counting the seconds until someone tells me I shouldn't do it that way...
 
Is there a good way to scan the filesystem for errors? I'd like to know if I got 'everything' or if I missed something that can be fixed.

Assuming your card is FAT32...


On a Windows box, you can use chkdsk: http://support.microsoft.com/kb/315265


Linux: fsck.vfat (I don't know of our Pandora's have that installed by default).


Assuming your card is Ext2


Linux: fsck.ext2 (I don't know of our Pandora's have that installed by default).


On a Windows box: Curse Redmond for not supporting other filesystems.

File this under 1001 ways to do something in Linux.


In /etc/init.d/bootmisc.sh I added one line to just before the end of it. Last two lines now look like:


swapon /dev/mmcblk0p2


: exit 0


My swap now 'turns on' at boot.


Now counting the seconds until someone tells me I shouldn't do it that way...
Looks like a fine solution to me.
 
Is there a good way to scan the filesystem for errors? I'd like to know if I got 'everything' or if I missed something that can be fixed.

Assuming your card is FAT32...


On a Windows box, you can use chkdsk: http://support.microsoft.com/kb/315265


Linux: fsck.vfat (I don't know of our Pandora's have that installed by default).


Assuming your card is Ext2


Linux: fsck.ext2 (I don't know of our Pandora's have that installed by default).


On a Windows box: Curse Redmond for not supporting other filesystems.

File this under 1001 ways to do something in Linux.


In /etc/init.d/bootmisc.sh I added one line to just before the end of it. Last two lines now look like:


swapon /dev/mmcblk0p2


: exit 0


My swap now 'turns on' at boot.


Now counting the seconds until someone tells me I shouldn't do it that way...
Looks like a fine solution to me.

I own no Windows machines - no Apple either. No fat :).


I looked through the docs on fsck - big important step - boot from NAND if you need to do this to an SD card - boot from SD card if you need to do this to NAND. Don't fsck a mounted volume. (Yes - you could do this using two SD cards.. etc...)


Booted from NAND - running fsck.ext2 on mmcblk0p1 now (OS partition on SD card).


An interesting bit - it didn't shut down cleanly. I suspect that I'll need to unmount the /swap before/during the shutdown process. Hmm...
 
Interesting. I now get an ASCI ANGSTROM black and white boot screen with a machine named prompt: that won't accept my user ID.


Time to reboot, reformat, recopy the OS, etc...


I'm starting to wonder if my card (Lexar 128GB SDXC) is having difficulties.
 
^ If it's Class 6 or Class 10, that's probably contributing to it.


Ever since the first units shipped, certain types have cards - usually of those speeds - have had issues (usually relating to poor controller chips in the cards - as is advised about for some cards on the wiki's SD Compatibility List), especially if formatted with one of the ext* filesystems, which go as far as preventing the machine from shutting down properly, even if you're running from the NAND.
 
Last edited by a moderator:
^ If it's Class 6 or Class 10, that's probably contributing to it.


Ever since the first units shipped, certain types have cards - usually of those speeds - have had issues (usually relating to poor controller chips in the cards - as is advised about for some cards on the wiki's SD Compatibility List), especially if formatted with one of the ext* filesystems, which go as far as preventing the machine from shutting down properly, even if you're running from the NAND.

"If it's Class 6 or Class 10, that's probably contributing to it"


I'm firmly convinced that is a myth started by people with class 2 and 4 cards (jealousy) and perpetuated by people who buy cards from disreputable sources trying to get "a deal" (cheap). Putting a class 2 or even 4 card in a Pandora is like tying kids shoes together because it's 'safer' to go slower.


I used Patriot LX 32GB Class 10 SDHC cards in my Pandora for nearly a year - no issues or complaints. All of them are formatted EXT2. No issues there. The SD compatibility list is simply wrong on the Patriot LX cards. EXT2 works fine on them.


Right now I'm using a single Lexar 128GB class 10 & 133x SDXC card. It worked flawlessly for over a month. The only drawback I've found is that if you're using it for OS, /swap, applications and music all at the same time, the music winds up chopping occasionally as the other needs hit the card too much - that and my catastrophic oops.


The 128GB card is now having issues. Of course I was running the OS, a 2GB /swap partition and music playback and a game and drawing max current through the USB port simultaneously when I had a system power failure - so I'm not as apt to simply blame the card. I'm pretty sure that a good re-partition and format should fix the issues that I've put on it. Frankly I'm surprised that it held together as well as it did after what I'd done to it.


So - I'm re-setting up the machine. I plan to put one of the Patriot 32GB SDXC cards back in as OS, /swap and applications. Then I'll have the 128GB card in the 2nd slot dedicated to music, movies and the like.


It's just finding the time to do it.
 
Back
Top