Welcome! Log In Create A New Profile

Advanced

SWAP problem

Posted by davidnewton 
SWAP problem
February 20, 2011 07:58PM
I have installed debian on my dockstar without problem. It works well with samba and asterisk. I have partitioned the flash drive with 256MB swap space on partition 2 as instructed by Jeff. Today I tried to plug an hard disk to the dockstar and share it with samba. It looks working fine, but when I use top to check free memory, it shows that the swap is not available anymore. After checking with fdisk -l, I found that the device labels are changed: the flash drive is /dev/sdb instead of /dev/sda when it is the only drive connected. The hard disk now is /dev/sda. It can stil boot from the flash drive though. Can anyone tell me if this is a way to keep the bootable flash drive as /dev/sda? Is this related to the swap disappearing? Thanks.
Re: SWAP problem
February 21, 2011 04:26PM
Yes, your swap vanished due to the label change. I have the same issue if I plug in my Free Agent Go drive along with my USB stick that is always there, because the hard drive always get's the lower device letter. If you check your fstab file, you can change the swap to the correct /dev/sdX and after a reboot you'll have your swap back.

BTW, the simpler solution that I used because this is annoying is to not make a swap partition at all. I created a swapfile instead and it will now work no matter what get's mounted and it's much easier to change the size as needed (I had to increase it to 512 when attempting some compiling). You can google for the exact command needed, but it's simply a dd write and then adding it to fstab.
Re: SWAP problem
February 22, 2011 08:40PM
Thanks a lot. I found the commands to activate the swap file from http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/. It works for me now.

BTW, I have another question about the device label: if I have 2 hard disks or 2 flash drives connected to the dockstar, how does it assign the device label? Now I understand that the hard disk will get the lower label than the flash drive, but if both are hard drive or both are flash drives, what rule is to sign the label? Does it do randomly, or there is an order for the 4 usb ports? Thanks.



Edited 1 time(s). Last edit at 02/22/2011 09:09PM by davidnewton.
John Doe
Re: SWAP problem
February 23, 2011 01:36AM
The device labels of devices which are attached at boot time are assigned in the order of the USB ports: The first port is the mini-USB on top, the second is the one next to the Ethernet port, the third is next to the second port and the fourth is on the right side.
ecc
Re: SWAP problem
February 23, 2011 10:35AM
You can use UUIDs instead of device names to avoid this problem.
  1. Find the UUID of your swap partition:
      # blkid -p -u other /dev/sda2
    (substitute the device currently used for the swap partition)
  2. Change /etc/fstab to use the UUID instead of the device name:
      UUID=01234567-abcd-0123-abcd-0123456789ab none swap sw  
  3. Profit!
Re: SWAP problem
February 23, 2011 07:58PM
ecc Wrote:
-------------------------------------------------------
> You can use UUIDs instead of device names to avoid
> this problem.
>
> [*] Find the UUID of your swap partition:
>
> # blkid -p -u other /dev/sda2
> (substitute the device currently used for the swap
> partition)
>

Thanks. I tried to use "blkid -p -u other /dev/sda2", and this is what I get:

/dev/sda2: VERSION="2" TYPE="swap" USAGE="other"

The UUID did not show with the blkid command.
Re: SWAP problem
February 23, 2011 08:16PM
John Doe Wrote:
-------------------------------------------------------
> The device labels of devices which are attached at
> boot time are assigned in the order of the USB
> ports: The first port is the mini-USB on top, the
> second is the one next to the Ethernet port, the
> third is next to the second port and the fourth is
> on the right side.


Thanks a lot. This information is very useful for me. I have another dockstar using optware with the pogoplug updated firmware (to my.pogoplug.com to share files). I need to add "mount /dev/sda1 /opt" in the rcS file to automatically mount the flash drive to /opt to use the optware packages. When I use additional flash drive and hard disks, this command can not work since the flash drive label is changed. Now, with this order of USB ports in mind, I can change this command to mount the right flash drive to /opt.
ecc
Re: SWAP problem
February 24, 2011 07:40AM
davidnewton Wrote:
-------------------------------------------------------
> I tried to use "blkid -p -u other /dev/sda2", and this is what I get:
>
> /dev/sda2: VERSION="2" TYPE="swap" USAGE="other"
>
> The UUID did not show with the blkid command.

I'm guessing you did not format the swap partition yet. First you need to do:
# mkswap /dev/sda2

(Make sure /dev/sda2 is really the partition you want to use for swap, since this command will destroy whatever data is on there.)
Re: SWAP problem
February 24, 2011 11:35AM
ecc Wrote:
-------------------------------------------------------

> I'm guessing you did not format the swap partition
> yet. First you need to do:
>
> # mkswap /dev/sda2
>
>
> (Make sure /dev/sda2 is really the partition you
> want to use for swap, since this command will
> destroy whatever data is on there.)

The /dev/sda2 is formatted and works fine as swap when only 1 flash drive is plugged in. When I use blkid commend, the /dve/sda2 is already used as swap. Probably that is why the UUID did not show.

UPDATE: when I plug another hard disk to the dockstar and reboot, the flash drive becomes /dev/sdb, then use mkswap /dev/sdb2, the UUID shows up. Thanks a lot.



Edited 1 time(s). Last edit at 02/24/2011 10:13PM by davidnewton.
Re: SWAP problem
February 25, 2011 07:13AM
ecc Wrote:
-------------------------------------------------------
> You can use UUIDs instead of device names to avoid
> this problem.
>
> [*] Find the UUID of your swap partition:
>
> # blkid -p -u other /dev/sda2
> (substitute the device currently used for the swap
> partition)
> [*] Change /etc/fstab to use the UUID instead of
> the device name:
>
> UUID=01234567-abcd-0123-abcd-0123456789ab none swa
> p sw
>
> [*] Profit!
>


Sorry, but I couldn't help thinking of the Southpark episode featuring the underpants gnomes, when reading your posting. :-D

-------------------------------------------------------

>1. Steal underpants.
>
>2. ???
>
>3. Profit!

-------------------------------------------------------

Thank you very much for a good laugh. I don't know if this was intended, but it sure was funny.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: