LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-03-2017, 08:32 AM   #1
haywire
LQ Newbie
 
Registered: Aug 2017
Location: Bretagne
Distribution: Raspbian
Posts: 8

Rep: Reputation: Disabled
Swap file on external hard drive connected to Raspberry Pi 3


Hello one and all
I just want to know the best way to have a swap file on an already in use 1Tb hard drive on my Raspberry Pi 3.
 
Old 08-03-2017, 08:44 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,251

Rep: Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159
Start with How_To_Ask_a_Question then we might all get somewhere.
 
Old 08-03-2017, 09:15 AM   #3
haywire
LQ Newbie
 
Registered: Aug 2017
Location: Bretagne
Distribution: Raspbian
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thank you for responding. I use a rpi3 with raspian pixel installed on a 64Gb micro sd. Also attached via usb a one terabyte external hard drive with much data mainly raw .dv files that I am gradually converting to .mp4 files using ffmpeg. I do not have any means to back it up at present. That is not the problem. The problem is mainly when using Chromium web browser. If I open too many tabs my Rasperry Pi hangs and I have to unplug it and re start. I know this is not good. I think if there is some way to be able to have a swap file on the external hard drive may solve my problem.
 
Old 08-03-2017, 09:19 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,193

Rep: Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087
You might want to read some threads on the subject as it depends on what distribution your running on the Pi.

http://raspberrypimaker.com/adding-s...e-raspberrypi/
https://raspberrypi.stackexchange.co...wap-space#1605

To create swap file:

Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.

At a shell prompt as root, type the following command with count being equal to the desired block size:
dd if=/dev/zero of=/path/to/swapfile bs=1024 count=65536

Setup the swap file with the command:
mkswap /path/to/swapfile

To enable the swap file immediately but not automatically at boot time:
swapon /path/to/swapfile

To enable at boot see the first link.

If the system is using lots of swap i.e. check the output of the free command then adding more may not help.

Last edited by michaelk; 08-03-2017 at 09:20 AM.
 
Old 08-03-2017, 12:27 PM   #5
haywire
LQ Newbie
 
Registered: Aug 2017
Location: Bretagne
Distribution: Raspbian
Posts: 8

Original Poster
Rep: Reputation: Disabled
Many thanks for your reply.
I have been trying to understand this but the output I get is "dd: failed to open ‘/media/pi/exttosh/swapfile.img’: Is a directory" and yes I do have root. It does not seem to matter if the name is swap.file, swapfile or swapfile.img.
I don't know where I'm going wrong and got to take a break now.
 
Old 08-03-2017, 12:34 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,193

Rep: Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087Reputation: 6087
If it helps you can change to that specific directory on the USB drive i.e.

cd /media/pi/exttosh

And then just create the file.

dd if=/dev/zero of=swapfile bs=1024 count=65536
 
1 members found this post helpful.
Old 08-03-2017, 01:56 PM   #7
haywire
LQ Newbie
 
Registered: Aug 2017
Location: Bretagne
Distribution: Raspbian
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thank you michaelk.
Success at last I now have a large swap file on my external drive and I can open many tabs in the Chromium browser without my Pi hanging. I will now try this on my Pine64. I am grateful thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot get Iomega external hard drive to mount with Raspberry Pi, running Debian. Dougski Linux - Newbie 47 01-05-2013 07:58 AM
Installing Debian on external (connected through USB) hard drive dannte Linux - Newbie 3 04-24-2011 07:40 AM
external hard drive and flash disk connected to usb doesn't show algerinbeijing Linux - Newbie 8 11-07-2010 04:56 AM
Installing Linux on External hard drive connected by USB port omidiora Linux - Newbie 1 04-29-2006 09:51 AM
How to open external hard drive when connected to USB??? kingslax Linux - Hardware 1 09-22-2004 06:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration