Discussion:
Is there a way to move a file to a specific place on the disk, like the start?
(too old to reply)
micky
2011-10-03 22:16:14 UTC
Permalink
(Please remember that this is a hobby for me, and I myself know an
easier likely way to get to the final result here, but it won't
involve a question that has intrigued me for years.)

The question is: Is there a way to move a file to a specific place on
the disk or partition, like the start?

Without writing code in Assember. This question has botthered me for
years. Once in a while there is a practical application.

I tthink if the partition were full to overflowing, and I coudl find
out the name of a file that Old was the first in the partition that
was as big as File F, the file I wanted at the start, I could delete
Old, and copy F to the partition, and it would go in the spot that Old
had used.

But what if the partition has loads of empty space? What do MS-DOS
and PC-DOS and various versions of windows do? Lets assume either an
NTFS or FAT32 partition. Does it make a difference?

Will it move it to
1) the next available space (next after the last file moved),
2) the first available space (which is almost the very start of the
parition.) . There is either enough empty space at the start of the
partition for this file to be stored in one piece, or there is loads
of empty space.
3) Or will it try to move the file to be near other files in the same
sub-sub-directory in which this new file will reside,, or at least the
same sub-directory, or at least the same highest level directory?

Option 3 seems to violate all the rules I've heard of, but I can't
help thinking that's what will happen.

Option 2 is what I want. Is it likely I'll get it?
Arno
2011-10-03 23:20:00 UTC
Permalink
Post by micky
(Please remember that this is a hobby for me, and I myself know an
easier likely way to get to the final result here, but it won't
involve a question that has intrigued me for years.)
The question is: Is there a way to move a file to a specific place on
the disk or partition, like the start?
Without writing code in Assember. This question has botthered me for
years. Once in a while there is a practical application.
It depends on the filesystem. With classical FAT, create a
new FAT filesystem and put the files on it. It will fill up
from the start. It may also be possible to use some defraggers
to the same effect. Other placement can then be achived by
filling up to the start where the files should go iwth other
data, writing the data and then remove the other files.

Other than that, you will need to programm. For a modern
filesystem like ext2/3 or NTFS, this will be hugely
complicated.
Post by micky
I tthink if the partition were full to overflowing, and I coudl find
out the name of a file that Old was the first in the partition that
was as big as File F, the file I wanted at the start, I could delete
Old, and copy F to the partition, and it would go in the spot that Old
had used.
Ah, that is easier: Overwrite the old file with the new one
(not cp, file open and then write the data over it from the
beginning). Still requires coding and will not work everywhere,
but is pretty simple to do.
Post by micky
But what if the partition has loads of empty space? What do MS-DOS
and PC-DOS and various versions of windows do? Lets assume either an
NTFS or FAT32 partition. Does it make a difference?
Very much. For FAT, new writes typically go into the first
empty space on disk. That is also why it fragments so badly.
For NTFS, I would guess that it works kind of like ext2/3
and has several pints on the disk that it groups files
around (very rough approximation).
Post by micky
Will it move it to
1) the next available space (next after the last file moved),
2) the first available space (which is almost the very start of the
parition.) . There is either enough empty space at the start of the
partition for this file to be stored in one piece, or there is loads
of empty space.
Here is the kicker: The decision is made _without_ knowing the
file size! The problem is that on file creation you do not
pass a parameter saying "and, hey, this is going to be this large".
You just do file creation and start writing.
Post by micky
3) Or will it try to move the file to be near other files in the same
sub-sub-directory in which this new file will reside,, or at least the
same sub-directory, or at least the same highest level directory?
I think a bit of that is going on in ext2/3, bit it is not
strictly directory orientated.
Post by micky
Option 3 seems to violate all the rules I've heard of, but I can't
help thinking that's what will happen.
Option 2 is what I want. Is it likely I'll get it?
With FAT, maybe. Otherwise no.
Typically you do not want it today though.

Arno
--
Arno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Email: ***@wagner.name
GnuPG: ID: 1E25338F FP: 0C30 5782 9D93 F785 E79C 0296 797F 6B50 1E25 338F
----
Cuddly UI's are the manifestation of wishful thinking. -- Dylan Evans
Rod Speed
2011-10-04 01:46:31 UTC
Permalink
Post by micky
(Please remember that this is a hobby for me, and I myself
know an easier likely way to get to the final result here, but
it won't involve a question that has intrigued me for years.)
Dont forget what curiosity did to the cat.
Post by micky
The question is: Is there a way to move a file to a
specific place on the disk or partition, like the start?
Yes.
Post by micky
Without writing code in Assember.
Yes.
Post by micky
This question has botthered me for years.
Once in a while there is a practical application.
I'm not convinced that there is.
Post by micky
I tthink if the partition were full to overflowing, and I coudl find out
the name of a file that Old was the first in the partition that was as
big as File F, the file I wanted at the start, I could delete Old, and
copy F to the partition, and it would go in the spot that Old had used.
Yes.
Post by micky
But what if the partition has loads of empty space?
One obvious approach is to fill that space by writing files too it until
it is full, and naming them with an name that allows a wildcard deletion
of all of those files once you have written the file you want to write to
the place you want to write it.
Post by micky
What do MS-DOS and PC-DOS and various versions of windows do?
That varys quite a bit between versions.
Post by micky
Lets assume either an NTFS or FAT32 partition. Does it make a difference?
Yes, the later versions of NTFS do a better job of avoiding framentation
and can write the file into the first free space thats big enough for it.
Post by micky
Will it move it to
1) the next available space (next after the last file moved),
2) the first available space (which is almost the very start of the parition.) .
That varys with the version, how full the partition is,
how long its been since its been booted etc etc etc.
Post by micky
There is either enough empty space at the start of the partition for
this file to be stored in one piece, or there is loads of empty space.
3) Or will it try to move the file to be near other files in the
same sub-sub-directory in which this new file will reside,,
Nope.
Post by micky
or at least the same sub-directory, or at least the same highest level directory?
Nope.
Post by micky
Option 3 seems to violate all the rules I've heard of,
And there isnt any point in doing it that way, so isnt done enough to matter.
Post by micky
but I can't help thinking that's what will happen.
It wont.
Post by micky
Option 2 is what I want. Is it likely I'll get it?
You can do with some versions, particularly if you reboot before
writing to the drive and just delete the file that occupys that place
just before writing the file you want there to that partition, particularly
with non system partitions. Can get messy with system partitions.

It isnt that hard to write a file where you want it to go thats free without using assembler.

You can even do it with some drive utes like Norton's Disk Editor for example.
shawn
2011-10-04 10:19:10 UTC
Permalink
Post by micky
(Please remember that this is a hobby for me, and I myself know an
easier likely way to get to the final result here, but it won't
involve a question that has intrigued me for years.)
The question is: Is there a way to move a file to a specific place on
the disk or partition, like the start?
I haven't done it for a particular file but I have used this method to
move particular directories to certain areas of the disk (though it
should work just as well for a file.) Use a tool like MyDefrag and
write a custom script (it's not that hard since there are already
scripts that reference particular files (system files.)

With MyDefrag you can specify certain types of files, directories or
even a particular file to go into specific zones (and you can define
the zones to be whatever you want. http://www.mydefrag.com/
This is a Windows specific program but there may be something similar
in Linux and other operating systems.
micky
2011-10-14 16:56:02 UTC
Permalink
Post by shawn
Post by micky
(Please remember that this is a hobby for me, and I myself know an
easier likely way to get to the final result here, but it won't
involve a question that has intrigued me for years.)
The question is: Is there a way to move a file to a specific place on
the disk or partition, like the start?
I haven't done it for a particular file but I have used this method to
move particular directories to certain areas of the disk (though it
should work just as well for a file.) Use a tool like MyDefrag and
write a custom script (it's not that hard since there are already
scripts that reference particular files (system files.)
With MyDefrag you can specify certain types of files, directories or
even a particular file to go into specific zones (and you can define
the zones to be whatever you want. http://www.mydefrag.com/
This is a Windows specific program but there may be something similar
in Linux and other operating systems.
Thanks. I dl'd this but haven't had a chance to use it. I figured
since it's been 10 days since you post ed, I should thank you now
instead of waiting. It sounds good.

And thank you also, Arno and Rod. I have a better understanding of
how this all works and what to do.
Richard Bonner
2011-10-24 15:51:53 UTC
Permalink
Post by micky
Is there a way to move a file to a specific place on
the disk or partition, like the start?
*** The way I would move a file to the start of a drive with my present
DR-DOS system would be to rename the file with the first character as `!'
(an exclamation). I would then use Norton's "DS.exe" to sort the files on
the drive by name, and with the "Directories First" option turned off.

The above method places a file first on a drive excluding any system
boot files that must occupy that spot, or possibly certain hidden files
used by DOS that might start with `!'.

To put a file in a specific spot other than first, one could use a
Disk Editor, but I am not versed enough in its usage to give specific
instructions.
--
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
Loading...