WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: swap "file"  (Read 3782 times)

Offline vinceASPECT

  • Hero Member
  • *****
  • Posts: 799
swap "file"
« on: October 30, 2020, 11:50:18 PM »
hello forum,

is it possible to create a swap "file" in the following coditions below.

1) Loading  Tcl from a CD boot..... and running it..
2) The machine in 1)above has a single hard drive that contains a single ntfs
partition containing you know what OS.
3) after boot , tcl reads and writes to that drive via
ntfs-3g tool(i mount the drive)
4) Is it possible to use the desktop tcl "swapfile tool" from the control panel
to make a 1 gig swap "file" on that ntfs partition and use it via
ntfs-3g each time i boot up and i mount the drive? (via swapON and swapOFF commands?)
(the tool won't try to wipe the whole partition will it?, while then only using
1 gig of it?)

thx
V




Offline polikuo

  • Hero Member
  • *****
  • Posts: 715
Re: swap "file"
« Reply #1 on: October 31, 2020, 01:28:20 AM »
Short answer: Yes, it's possible.
BUT not recommended cause it may greatly impact your performance.
I never try it, so you have to try it yourself, it won't delete your partition.

TC has a boot code for that. (Read the book)
However it is designed for a FAT32 partition.
Quote
10.4. swapfile - swap in a file
In normal use, you would use a regular Linux swap partition.
However, if the system is installed to a fat32 partition, and you cannot create a swap partition, you may use a swap file.
It is created with the GUI tool, and the bootcode is used to tell the system to use it.
Examples:
•   swapfile
•   swapfile=sda1
The first form will scan for a swap file, the second will scan for it only in the specified drive.

To do that on NTFS, you'll need ntfs-3g.tcz onboot for read and write access.
(you'll probably need to modify /opt/bootlocal.sh to mount -o rw)
Assume you mount it on /mnt/sda1
Code: [Select]
dd if=/dev/zero of=/mnt/sda1/swapfile.img bs=1M count=1024
mkswap /mnt/sda1/swapfile.img
swapon /mnt/sda1/swapfile.img

Offline vinceASPECT

  • Hero Member
  • *****
  • Posts: 799
Re: swap "file"
« Reply #2 on: October 31, 2020, 09:10:20 AM »
polikuo,

thanks and that is a great answer.

i was worried because of the confusion about terminology's used.

For example, the tcl desktop "swapfile" tool in the control panel asks you for the name of a "mounted  *partition* ".......... where-as my computer here just has a mounted "drive" which contains one whole partition.
(a bit confusing)

i see your point on performance, but i figure that in some circumstance it would not be worse than not having a swap file.

thanks

v

ps....is your script  referring to a 1 megabyte swap file?....not 1 gigabyte?....or is that a writing block size?


https://serverfault.com/questions/333046/ntfs-3g-poor-write-speed
« Last Edit: October 31, 2020, 09:21:50 AM by vinceASPECT »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 715
Re: swap "file"
« Reply #3 on: October 31, 2020, 12:47:40 PM »
ps....is your script  referring to a 1 megabyte swap file?....not 1 gigabyte?....or is that a writing block size?

Read dd manual and you'll understand.

block size = 1M
count = 1024
Total = 1M X 1024 = 1G

Offline Leee

  • Full Member
  • ***
  • Posts: 119
Re: swap "file"
« Reply #4 on: November 05, 2020, 02:09:52 AM »
I'm using a setup that is somewhat similar to what you described:

1) Loading  tcl CorePure64 from a CD boot USB stick..... and running it..
2) The machine in 1)above has a single hard drive an SSD that contains a single ntfs
partition containing you know what OS
all the BS related to a Win10/UEFI installation.
3) after boot , tcl reads and writes to that drive via
ntfs-3g tool(i mount the drive) ntfs3g.gz which is loaded alongside core.gz
4) Is it possible to use the desktop tcl "swapfile tool" from the control panel
to make a 1 gig swap "file" on that ntfs partition and use it via
ntfs-3g each time i boot up and i mount the drive? (via swapON and swapOFF commands?)
(the tool won't try to wipe the whole partition will it?, while then only using
1 gig of it?) I created an 8GB swap file on the NTFS partition on the SSD using the "Swapfile Tool" on the control panel.

- I wasn't ready to blow away the Windows 10 installation so I decided to just boot Core from a USB stick.
- But I needed to be able to remove the USB stick after booting so the tce directory had to live on the SSD,
- which called for using ntfs3g as an extra initrd instead of as an extension.
- Once -that- was in place, having the swap file on the NTFS partition seemed like the logical next step.
- Given the specs of this machine (it was a gaming laptop in a former life) and
-- the current usage profile (-not- gaming nor anything else that would noticeably tax it),
-- it probably never even uses the swap file so
--- I have no idea if there would be a performance hit from having it on an NTFS partition.

( using CorePure64 11.1 )
core 15.0 x86_64

Offline vinceASPECT

  • Hero Member
  • *****
  • Posts: 799
Re: swap "file"
« Reply #5 on: November 05, 2020, 03:47:27 AM »
yes Leee,

i followed the advice of the polikuo in  this thread.  The advice worked and has created the swap file in the said way. 

There seemed to be an instance where it actually began using the swap.....and while it is slow,  it does complete things....(there are some extra switches that perhaps could be used to improve the speed of swapping such as "big writes").

yes this is the latest TcL version here on 32 bit.  (11.1)
SSE only cpu chip.......(Amd athlon 1500+..... cpu)     512 megs ram
1999 Laptop machine.

V


« Last Edit: November 05, 2020, 03:56:44 AM by vinceASPECT »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 715
Re: swap "file"
« Reply #6 on: November 05, 2020, 04:19:37 AM »
Hi, it looks like there's something I forgot to mention.

Add ntfs-3g.tcz to your onboot.lst

It is recommended to name the swap file "tc.swp"

Add "swapfile=sda1" in your boot code so it can be used automatically.
(check tce/boot/extlinux/extlinux.conf if you installed with tc-install)