Hard links

Off-topic posts of interest to the "Everything" community.
Post Reply
harryray2
Posts: 1104
Joined: Sat Oct 15, 2016 9:56 am

Hard links

Post by harryray2 »

I regularly 'vacuum' my .sqlite files in Firefox with a programme called speedyfox. This works on my .sqlite files in my Firefox profile folder, but not on .sqlite files in other folders.
If I created a hard link in my Firefox profile folder, pointing to a file in another folder, would any action on the hard link, such as 'vacuuming' change the original file?
What is the best and easiest way to create a hard link?

Thanks.
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Hard links

Post by therube »

It appears that Speedyfox is meant to work with a web browsers Profile (folder).
A folder at that, rather then individual files.

I gather it searches for %appdata%/roaming/Mozilla/{browser}/Profiles.ini (which contains a list of [Mozilla] browser Profiles - that were defined via [Mozilla's] Profile Manager), & presents those locations by default.

(I'm guessing that it also relies on the browsers 'sqlite3' program rather then sqlite3.exe itself.)

So to me, it looks like speedyfox will not work on arbitrary .sqlite files.
(I'm not even understanding how to get it to work with a portable Profile location?)


I question the usefulness of speedyfox.
As it is, AFAIK, Mozilla automatically, periodically vacuums its' sqlite files.
As it is, (Mozilla) sqlite files are 'pre-sized' (to some value), so while the file may be 'empty' it may still yet have a 'substantial' size to it. And while speedyfox may reduce the physical size of the file on disk, it has not really accomplished anything, & may even be of a detriment.


SQLITE.vacuum.bat:

Code: Select all

dir  *.sqlite  >  b4.sqlite.vacuum.TXT
echo "-------" >> b4.sqlite.vacuum.TXT

for  %%i in (*.sqlite) do (sqlite3.exe %%i vacuum)

dir  *.sqlite  >> b4.sqlite.vacuum.TXT

pause
exit

:: also if you sqlite3.exe {filename}
::         you can type "VACUUM;"  at
::         the prompt & it will do it
::         interactively
https://www.sqlite.org/


And what are you looking to do, accomplish with the hardlink?
harryray2
Posts: 1104
Joined: Sat Oct 15, 2016 9:56 am

Re: Hard links

Post by harryray2 »

Yes, it does work if I move the files from the relevant storage folder to the main profile folder, I then move the files back to the original storage folder.
The files I want to vacuum relate to various extensions, which place .sqlite files in various sub folders within the main storage folder.

It's necessary to vacuum Firefox every so often, as it does not do it by itself.

I want to place a link in the main profile folder, so as to save me having to move the files around each time.

the 'vacuuming' speeds up Firefox considerably, and brings down the file sizes.

The vacuuming though, isn't the issue, I'm interested in the behaviour and usage of hard links.
void
Developer
Posts: 16770
Joined: Fri Oct 16, 2009 11:31 pm

Re: Hard links

Post by void »

There is only one copy of the file data when using multiple hard links.

Each hard link will point to the same file data.

Deleting a hard link file will delete the filename.
The file data is 'filename reference counted'.
When all filenames are deleted the file data is deleted.



Hard links share the same file data.
Changing the file data from one hard link will change the file data for all hard links.
harryray2
Posts: 1104
Joined: Sat Oct 15, 2016 9:56 am

Re: Hard links

Post by harryray2 »

Thanks David, does that mean that any action taken on a hard link, such as 'vacuuming' a .sqlite file or, for example, defragging, will affect the original file in another directory?

Can you recommend the best way to create the hard link?
void
Developer
Posts: 16770
Joined: Fri Oct 16, 2009 11:31 pm

Re: Hard links

Post by void »

Thanks David, does that mean that any action taken on a hard link, such as 'vacuuming' a .sqlite file or, for example, defragging, will affect the original file in another directory?
Yes, vacuuming and defragging will modify the file data.
All hard links point to the same file data.


Can you recommend the best way to create the hard link?
From a command prompt:
mklink /h <link> <target>

Create file hardlink in PowerShell on Windows 10
harryray2
Posts: 1104
Joined: Sat Oct 15, 2016 9:56 am

Re: Hard links

Post by harryray2 »

Thanks so much for the info...

I managed to find a programme that allows me to create a hard link via the context menu.
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Hard links

Post by therube »

Link Shell Extension ?

So you're going to create a hardlink of /extension-data/ublock0.sqlite (uBlock Origin's data file),
& set it's target to, {Firefox/Profile Folder/} such that speedyfox will see ublock0.sqlite & vacuum it
(where it ordinarily might not, & perhaps, not sure, Mozilla too would ignore that file - because it is not "Mozilla").
harryray2
Posts: 1104
Joined: Sat Oct 15, 2016 9:56 am

Re: Hard links

Post by harryray2 »

I use the Firefox portable app.

I move the UBO sqlite file from its location at profile\data\storage\default\moz-extension************ to the main profile folder, vacuum the profile folder with Speedyfox, then move the file back again to its original location.
I'm doing this with all my extensions that have relatively large sqlite files.

With the hard link, I'm going to create permanent links in the profile folder for the sqlite files, so it will save me mucking around and moving files backwards and forwards each time.

It hasn't caused any problems, and it does speed things up. I also use it with Tor.

Speedyfox is quite a nice little programme, but its limitation for me is the fact that it only vacuums files in the profile folder.
I don't know of any other programme that vacuums Firefox.
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Hard links

Post by therube »

Well, seemingly you should still be able to use speedyfox, but I couldn't make sense of its' command line options, just what it was looking for, so never did get it work other then with explicitly defined Profiles - that it found, automatically (& as defined in profiles.ini).

/<program_name>:<profile_path> - optimize custom profile of program_name located at profile_path
(e.g. for portable versions of supported programs)

My "current" commandline is:
C:\SPEEDYFOX\speedyfox.exe "/SeaMonkey:dumy"

Where SeaMonkey is my browser, & "dumy" is my Profile name (as defined in profiles.ini).

speedyfox itself determined that.

But then, if I have a (portable, if you will) Profile in,
C:\TMP\SEA\dumy
(which is different from above, simply has the same "name"), I have no clue how to get that to work (or at least, anything I have tried has been for not).
Post Reply