Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: alexo on January 05, 2016, 07:05:15 AM

Title: swap file
Post by: alexo on January 05, 2016, 07:05:15 AM
Hello,
I have TC 6.4.1 installed on a 2GB USB stick running and booting from machines with linux mint installed on them. No virtual machine used. The TC installation was set up to install on the USB flash drive.
Is there a way to tell TC to use the swap partition on the hard drive of the notebook or PC which I boot from?

thank you


Title: Re: swap file
Post by: nitram on January 05, 2016, 07:32:22 AM
Quote
tinycore swapfile{=hda1}            Scan or Specify swapfile
http://www.tinycorelinux.net/faq.html

Never had to use it as TC scans at boot for existing swap partitions.

After booting TC, check /etc/fstab to see if it found it,
and run  free -m  to confirm, should show swap:
Code: [Select]
tc@box:~$ free -m
             total         used         free       shared      buffers
Mem:           500          421           78            0           56
-/+ buffers:                365          134
Swap:          729            0          729
Title: Re: swap file
Post by: Misalf on January 05, 2016, 07:50:01 AM
Note that a swap FILE is not the same as a swap PARTITION.
Title: Re: swap file
Post by: alexo on January 05, 2016, 09:50:35 AM
to Misalf
could you please explain me in few words what is a swap file?

In my post I was referring to the swap partition, the one normally created during an installation on almost all the linux distros.
If I have well understood the words by nitram there's no need to have a swap partition in the usb stick because with the bootcode indicated I can say to use the swap partition on hda1.
What should I do if I decided to install TC on the hard disk instead of the stick?
In the installing procedure there's no option to create one.

Title: Re: swap file
Post by: Misalf on January 05, 2016, 10:13:55 AM
All swap partition will be used automatically. Tiny Core does  /sbin/swapon -a  at boot, which activates any swap partition that can be found.
The only configuration regarding swap partitions which can be done at boot, is to not activate them, via boot code  noswap .
A swap partition needs to be created manually if none exists already.

BTW, Tiny Core uses compressed swap in ram, so if you have plenty of ram you might have enough swap even without a swap partition. Can be disabled via boot code  nozswap  so there is more ram usable.

A swap file can be created with Tiny Core's  Swapfile tool (f.e. /mnt/sda1/tc.swp). This swap file will then be used (also across boots if specified via  swapfile=  boot code) like Windows uses a swap file (pagefile.sys).
Title: Re: swap file
Post by: alexo on January 05, 2016, 01:17:48 PM
to Misalf

Quote
All swap partition will be used automatically. Tiny Core does  /sbin/swapon -a  at boot, which activates any swap partition that can be found.

have I have to say swapfile{=hda1} as boot code or is it not necessary?

Quote
A swap partition needs to be created manually if none exists already.

So say I buy a new HD drive and I want to install TC on it, how do I create a swap partition?
Which tool should I have to use?

Quote
A swap file can be created with Tiny Core's  Swapfile tool (f.e. /mnt/sda1/tc.swp). This swap file will then be used (also across boots if specified via  swapfile=  boot code)

 
Title: Re: swap file
Post by: Misalf on January 05, 2016, 01:38:21 PM
Quote
have I have to say swapfile{=hda1} as boot code or is it not necessary?
Not necessary. Only if you're actually using a swap file instead of a swap partition.

What is the output of  free -m  on one of your Mint boxes?

Quote
So say I buy a new HD drive and I want to install TC on it, how do I create a swap partition?
Which tool should I have to use?
I use GParted for such things. After a short web search it should be easy with  fdisk  too.
Title: Re: swap file
Post by: alexo on January 05, 2016, 04:25:34 PM
Code: [Select]
$ free -m
             total       used       free     shared    buffers     cached
Mem:          2006       1536        469        105         84        697
-/+ buffers/cache:        754       1251
Swap:         2053        103       1950

strictly speaking mine is not a Mint box. It'a a laptop on which runs Mint.
Title: Re: swap file
Post by: Misalf on January 05, 2016, 05:55:53 PM
So you have 2GB of swap. I'd say things look good.
Title: Re: swap file
Post by: alexo on January 06, 2016, 06:43:24 AM
On TC, I had up to now set a noswap bootcode option because I wrongly thought that swap was to be on the flash drive.
And for they have a limited life cycle that seemed to me the most reasonable choice.
Now to be sure I enabled the swap{=hda1} option and removed the noswap.

This is the output of free -m

Code: [Select]
tc@box:~$ free -m
             total         used         free       shared      buffers
Mem:          2015          545         1470            0           63
-/+ buffers:                481         1533
Swap:         2546            0         2546

I don't know why but swap partition in bigger than that seen from the Mint distro.
Title: Re: swap file
Post by: Misalf on January 06, 2016, 07:37:49 AM
About 20% of available RAM are used for compressed swap in RAM. If swap partitions are the same size on both systems, one probably has more RAM installed than the other.

There is no  swap=  boot code.

http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes
Title: Re: swap file
Post by: alexo on January 06, 2016, 09:49:18 AM
Oh mama, I mispelled the bootcode. What I'm actually using is tinycore swapfile{=hda1}
Now the question is: how do I create a swap file?
 
The machine upon which was executed the free -m test is the same. Is for this reason that I asked you.

Title: Re: swap file
Post by: bmarkus on January 06, 2016, 10:06:24 AM

Now the question is: how do I create a swap file?


Use Google. If you can't, read

http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
Title: Re: swap file
Post by: Misalf on January 06, 2016, 10:14:48 AM
Maybe you was using the boot code  nozswap  instead of  noswap  (note the z)?

The GUI app for creating a swap file is located in  Xprogs.tcz  and can be run from terminal via
Code: [Select]
swapfile
or from wbar's  "Control Panel"  icon  ->  "Swapfile Tool" .

The  swapfile  tool just creates the file  tc.swp  using  dd , thus I wouldn't feel too save guessing the correct dd command in case you're not using X and a window manager. In that case do a web search as bmarkus says.

However, even though a lot of swap probably won't hurt, I don't see a reason for you to create a swap file unless you really need/want a huge amount of swap.
Title: Re: swap file
Post by: Rich on January 06, 2016, 10:31:50 AM
Hi alexo
Quote
I don't know why but swap partition in bigger than that seen from the Mint distro.
Unless you use the  nozswap  boot code Tinycore sets aside a block of RAM to use as compressed swap space.
From:
http://www.linfo.org/free.html
Quote
The third row, which begins with Swap, shows the total swap space as well as how much of it is currently in use and how much is still available.
That would be the sum of all swap partitions, swap files, and any RAM being used for swap. With the 2GByte swap
partition you already have I see no reason to add any more.
Title: Re: swap file
Post by: Misalf on January 06, 2016, 10:39:11 AM
Quote
... bigger than that seen from the Mint distro.
Ah, I didn't noticed you checked from Mint and from TC.
Yeah, TC uses zram swap by default so there is more combined swap.