psriv
Posts: 2
Joined: Wed Jan 01, 2014 9:13 pm

Swap partition on hard disk on raspbian

Wed Jan 01, 2014 9:20 pm

I am running memory intensive file transfers on Raspbian and I keep getting memory errors. I had switched off swap file to save my SD Card ( and anyways that small swapfile would have been insufficient for my purpose). I have a 2TB HDD connected permanently to RPi via USB. I want to create a 10GB swap partition on that disk. I tried it but I must be doing something wrong because it is not working.

My disk setup is as below:

Code: Select all

/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="2654-BFC0" TYPE="vfat"
/dev/mmcblk0p2: UUID="548da502-ebde-45c0-9ab2-de5e2431ee0b" TYPE="ext4"
/dev/sda1: LABEL="mybook" UUID="621cad43-68d7-4ffa-9373-67bd6f711cd5" TYPE="ext4"
/dev/sda2: UUID="bc2449be-fa7b-4c82-adfb-dbfa1d908921" TYPE="swap"
Here is what I did:

1. created a 10GB partition /dev/sdb2 using parted

2. created swap via "sudo mkswap /dev/sda2"

3. Added swap partition to fstab: cat "UUID=bc2449be-fa7b-4c82-adfb-dbfa1d908921 swap swap sw,nofail" >>/etc/fstab

4. started swap: "sudo swapon /dev/sda2"

5. reboot

After reboot, I check swap status via "swapon -s" and it shows no swap active. What step am I missing?
Last edited by psriv on Thu Jan 02, 2014 5:30 am, edited 1 time in total.

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Swap partition on hard disk on raspbian

Thu Jan 02, 2014 12:21 am

Try this in fstab

Code: Select all

UUID=986ce07c-dcc5-41fc-82c0-5bbc160f5e2e none            swap    sw              0       0
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

psriv
Posts: 2
Joined: Wed Jan 01, 2014 9:13 pm

Re: Swap partition on hard disk on raspbian

Thu Jan 02, 2014 5:34 am

That solved the issue. Thank you very much!
Further, I realized that I had an error while copying UUID as well.
Changing both solved the issue.

Return to “Troubleshooting”