Author Topic: swap drive on SD-card ?  (Read 16012 times)

Leven2e

  • Guest
Re: swap drive on SD-card ?
« Reply #30 on: April 21, 2009, 10:07:03 PM »
How can I add it Mijzelf? What do I need to add?
just a  line like this? :  swapon /SD/SD_1/swapfile    ?

Mijzelf

  • Guest
Re: swap drive on SD-card ?
« Reply #31 on: April 22, 2009, 07:58:54 AM »
Assuming you use a swappartition, which is the 2nd partition on the sd card, you must run
Code: [Select]
mkswap /dev/mmc0p2 once. Then add the line
Code: [Select]
/dev/mmc0p2 swap swap defaults 0 0to /etc/fstab.

When it's the first partition you must use /dev/mmc0p1.

Unhban

  • Guest
Re: swap drive on SD-card ?
« Reply #32 on: April 22, 2009, 09:27:28 AM »
Sorry guys, can we start from the beginning? It's all getting a bit too fragmented to me.

Let's say I have a 2GB SD card which is proved to work in the LLL, but I already have some stuff on it I wish to keep. So say I'm willing to give up 1GB of the SD card to a partition.... (is 1GB too much?)

Could someone please run us through the full process from partitioning, to it actually working with the LLL (including it automatically switch swapon on)? I'm certain a number would be interested and would help the machine itself a lot! :)

Unh.
« Last Edit: April 22, 2009, 09:29:02 AM by Unhban »

Leven2e

  • Guest
Re: swap drive on SD-card ?
« Reply #33 on: April 22, 2009, 09:52:47 AM »
Assuming you use a swappartition, which is the 2nd partition on the sd card, you must run
Code: [Select]
mkswap /dev/mmc0p2 once. Then add the line
Code: [Select]
/dev/mmc0p2 swap swap defaults 0 0to /etc/fstab.

When it's the first partition you must use /dev/mmc0p1.

I don't think I got a swap=partition,I just used the mkswap command and the other things those were published earlier in this thread.
Uhban, think it'd would be quite important to have  a step-by-step guide in the How-to topic for clarification and explanations.

Unhban

  • Guest
Re: swap drive on SD-card ?
« Reply #34 on: April 22, 2009, 10:20:44 AM »
Exactly, Leven2e. Anyone wish to take the challenge for a simply-worded guide?  ;)

Unh.

Mijzelf

  • Guest
Re: swap drive on SD-card ?
« Reply #35 on: April 22, 2009, 11:18:24 AM »
Well, I've got no LLL here, but I'll try off the top of my head.

-Plugin the SD card.
-Unmount it
Code: [Select]
umount /dev/mmc0p1-Use fdisk to create a swap partition. (This will destroy all data on SD card, so copy it to a safe place first)
Code: [Select]
fdisk /dev/mmc0Don't remember the exact commands, 'm' is help. I think.
-- Delete all partitions
-- Create a primary partition of (sizeof(SD card) - sizeof(intended swapsize))
-- Create a primary partition of remaining space (which is sizeof(intended swapsize) 128~256MB)
-- Change the partition type of the second partition to swap.
--- If you want the SD card to be readable in a Windows system, you should change the partition type of the first partition to FAT16 or FAT32.
-- Save changes and exit fdisk

-Create filesystems (ext3 on P1, swap on P2):
Code: [Select]
mke2fs -j /dev/mmc0p1
mkswap /dev/mmc0p2
I'm not sure in which distro mke2fs is available (*if* it's available). I think you can format a FAT partition in a Windows machine. The Linux command would be
Code: [Select]
mkdosfs /dev/mmc0p1but I'm almost sure this command isn't available.

-Add the line
Code: [Select]
/dev/mmc0p2 swap swap defaults 0 0to /etc/fstab
-Reboot.


Mijzelf

  • Guest
Re: swap drive on SD-card ?
« Reply #36 on: April 26, 2009, 09:23:30 AM »
It looks like I was wrong. I didn't add a line to /etc/fstab, instead I added a line at the top of /etc/init.d/rcS:
Code: [Select]
swapon /dev/mmc0p2

Unhban

  • Guest
Re: swap drive on SD-card ?
« Reply #37 on: April 26, 2009, 10:29:14 AM »
Hi Mijzelf. Thanks for the instructions, however I'm just confused a little by the following part:

I think you can format a FAT partition in a Windows machine. The Linux command would be
Code: [Select]
mkdosfs /dev/mmc0p1but I'm almost sure this command isn't available.

Is this part just for our info, or should we try to do this command on the LLL?

Also, just to cross the t s and dot the i s, it's awhile since I've used fdisk as I use Partition Manager now! :) I'm sure when I get to the fdisk part it'll become plainly obvious again, but.... as it is an important part is there a chance you can give examples of the command needed on the following lines:

-- Delete all partitions
-- Create a primary partition of (sizeof(SD card) - sizeof(intended swapsize))
-- Create a primary partition of remaining space (which is sizeof(intended swapsize) 128~256MB)
-- Change the partition type of the second partition to swap.
--- If you want the SD card to be readable in a Windows system, you should change the partition type of the first partition to FAT16 or FAT32.
-- Save changes and exit fdisk


This may also help those who've never used fdisk before (and it can be quite daunting!) :)

Ta for all the work, Unh.



« Last Edit: April 26, 2009, 10:30:49 AM by Unhban »

Mijzelf

  • Guest
Re: swap drive on SD-card ?
« Reply #38 on: April 26, 2009, 03:29:16 PM »
Is this part just for our info, or should we try to do this command on the LLL?
It's just for info. And I can confirm now mke2fs is not available too. (At least not on MX3),
which makes it hard to create an ext3 partition without another linux box.
I used a chrooted debian for it.

Quote
Also, just to cross the t s and dot the i s, it's awhile since I've used fdisk as I use Partition Manager now! :) I'm sure when I get to the fdisk part it'll become plainly obvious again, but.... as it is an important part is there a chance you can give examples of the command needed on the following lines:

-- Delete all partitions
-- Create a primary partition of (sizeof(SD card) - sizeof(intended swapsize))
-- Create a primary partition of remaining space (which is sizeof(intended swapsize) 128~256MB)
-- Change the partition type of the second partition to swap.
--- If you want the SD card to be readable in a Windows system, you should change the partition type of the first partition to FAT16 or FAT32.
-- Save changes and exit fdisk

It's not that hard:
fdisk /dev/mmc0
type 'm' for help, which tells you to:
- type 'p' to view the partition table
- type 'd' for each partition. fdisk will ask for a number start with 1, then 2 ...
   In most cases there's only one partition
- type 'n p' for a new primary partition. fdisk will ask for a starting and ending cylinder
   'p' gave you the current partition table, and the size of the device in cylinders.
   since you know the size in MB, you can calculate the size of a cylinder.
   the starting cylinder is 1, choose an ending cylinder so you've about 200 MB left.
- type 'n p' to create a second partition, Assing all space left.
- type 't 1 b<enter> to flag the first partition FAT32 (it still needs to be formatted, fdisk won't do it)
- type 't 2 82<enter> to flag the second partition swap.
- type 'w' to write the changes and exit.

terrykiow

  • Guest
Re: swap drive on SD-card ?
« Reply #39 on: August 03, 2009, 08:56:33 PM »
Well, Mijself, that froze my operating system.  I have had to reload the OS.  So what's next?

terrykiow

  • Guest
Re: swap drive on SD-card ?
« Reply #40 on: August 03, 2009, 08:59:57 PM »
Muffe - where did you get that German program?

Mijzelf

  • Guest
Re: swap drive on SD-card ?
« Reply #41 on: August 06, 2009, 08:01:29 AM »
Well, Mijself, that froze my operating system.  I have had to reload the OS.  So what's next?
What exactly froze your OS? Can you describe as exactly a possible what you were doing?

terrykiow

  • Guest
Re: swap drive on SD-card ?
« Reply #42 on: August 06, 2009, 11:02:57 AM »


Miself:  I followed your instructions in #41:

 It looks like I was wrong. I didn't add a line to /etc/fstab, instead I added a line at the top of /etc/init.d/rcS:
Code:
swapon /dev/mmc0p2

jimux

  • Guest
Re: swap drive on SD-card ?
« Reply #43 on: August 06, 2009, 12:12:43 PM »
Just a small footnote to reply 37 above.  The instructions will give you a swap partition as the first partition.  If you intend to use the same card to load recovery software (Power on +F3, etc) then the recovery software should be on the first partition.
Its a very small point, but could save a lot of frustration.
I would also add that Linux desktop machine owners can just resize the existing partition without loss of data using gparted.

Mijzelf

  • Guest
Re: swap drive on SD-card ?
« Reply #44 on: August 06, 2009, 12:29:23 PM »
So you added a line to /etc/init.d/rcS, and after a reboot your box didn't get alive anymore? Hmm. Could be a typo. rcS is a script which is executed on boot to bring up the desktop, so a typo could stop the script, and leave you with a partial booted system.

First try executing
Code: [Select]
swapon /dev/mmc0p2in a terminal. If that freezes your box just switch it off (keep the button pressed untill it's off) and on again. If it generates an error please post it here. If it works the command 'free' should show the swapspace.