file fragmentation project

Discussion in 'Python' started by Bart Nessux, Jun 2, 2004.

  1. Bart Nessux

    Bart Nessux Guest

    Python may not be suitable for this, but I thought I'd ask the experts:

    I'm doing a summer project that will attempt to measure exactly how file
    fragmentation affects disk drive and OS performance. I'd like to use
    Python for some of this. In particular, I'd like to write a file
    fragmentor in Python that will randomly fragment x% of files on a NTFS
    filesystem into y number of fragments. For example, assuming that we
    start with a 100% defragmented drive, run the program to randomly
    fragment 20% of the drive's files into 7 different fragments (may also
    base the number of fragments on the file's size).

    Anyway, would Python be acceptable for this type of project? Speed is
    somewhat important, but not extremely.

    All comments and advice are welcomed.

    Bart
    Bart Nessux, Jun 2, 2004
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    At 2004-06-02T21:10:02Z, Bart Nessux <> writes:

    > In particular, I'd like to write a file fragmentor in Python that will
    > randomly fragment x% of files on a NTFS filesystem into y number of
    > fragments.


    You may or may not be able to do so, depending on how smart your exact
    version of NTFS decides to be on that given day. Still, the standard
    algorithm to fragment a file m bytes long into n pieces is:

    1) Create n * 2 files, each (m/n) bytes long.
    2) Delete every other file.
    3) Write the file to be fragmented, and hope that the filesystem naively
    shoves it into the empty holes.
    4) Delete the remaining "pad" files.

    A similar algorithm is to replace step 1 with:

    1) Fill the entire drive with files (m/n) bytes long.

    If the filesystem isn't smart enough to rearrange empty blocks, then that
    should to the trick.

    > Anyway, would Python be acceptable for this type of project? Speed is
    > somewhat important, but not extremely.


    You bet. Filesystem speed will be the limiting factor.
    - --
    Kirk Strauser
    The Strauser Group
    Open. Solutions. Simple.
    http://www.strausergroup.com/
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFAvky35sRg+Y0CpvERAkm9AKCOeYJZ3aEbgcFERo8Iy5dxAKD6aQCeMWEO
    bnwx/bkTjkWo+JE/pCrMjvU=
    =CmhE
    -----END PGP SIGNATURE-----
    Kirk Strauser, Jun 2, 2004
    #2
    1. Advertising

  3. Bart Nessux

    Bart Nessux Guest

    Thanks for the advice Kirk, I appreciate it.

    Kirk Strauser wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > At 2004-06-02T21:10:02Z, Bart Nessux <> writes:
    >
    >
    >>In particular, I'd like to write a file fragmentor in Python that will
    >>randomly fragment x% of files on a NTFS filesystem into y number of
    >>fragments.

    >
    >
    > You may or may not be able to do so, depending on how smart your exact
    > version of NTFS decides to be on that given day. Still, the standard
    > algorithm to fragment a file m bytes long into n pieces is:
    >
    > 1) Create n * 2 files, each (m/n) bytes long.
    > 2) Delete every other file.
    > 3) Write the file to be fragmented, and hope that the filesystem naively
    > shoves it into the empty holes.
    > 4) Delete the remaining "pad" files.
    >
    > A similar algorithm is to replace step 1 with:
    >
    > 1) Fill the entire drive with files (m/n) bytes long.
    >
    > If the filesystem isn't smart enough to rearrange empty blocks, then that
    > should to the trick.
    >
    >
    >>Anyway, would Python be acceptable for this type of project? Speed is
    >>somewhat important, but not extremely.

    >
    >
    > You bet. Filesystem speed will be the limiting factor.
    > - --
    > Kirk Strauser
    > The Strauser Group
    > Open. Solutions. Simple.
    > http://www.strausergroup.com/
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v1.2.4 (GNU/Linux)
    >
    > iD8DBQFAvky35sRg+Y0CpvERAkm9AKCOeYJZ3aEbgcFERo8Iy5dxAKD6aQCeMWEO
    > bnwx/bkTjkWo+JE/pCrMjvU=
    > =CmhE
    > -----END PGP SIGNATURE-----
    Bart Nessux, Jun 3, 2004
    #3
  4. Bart Nessux

    JanC Guest

    Bart Nessux <> schreef:

    > Python may not be suitable for this, but I thought I'd ask the experts:
    >
    > I'm doing a summer project that will attempt to measure exactly how file
    > fragmentation affects disk drive and OS performance. I'd like to use
    > Python for some of this. In particular, I'd like to write a file
    > fragmentor in Python that will randomly fragment x% of files on a NTFS
    > filesystem into y number of fragments. For example, assuming that we
    > start with a 100% defragmented drive, run the program to randomly
    > fragment 20% of the drive's files into 7 different fragments (may also
    > base the number of fragments on the file's size).
    >
    > Anyway, would Python be acceptable for this type of project? Speed is
    > somewhat important, but not extremely.
    >
    > All comments and advice are welcomed.


    Read this: <http://www.sysinternals.com/ntw2k/info/defrag.shtml>

    --
    JanC

    "Be strict when sending and tolerant when receiving."
    RFC 1958 - Architectural Principles of the Internet - section 3.9
    JanC, Jun 6, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben_
    Replies:
    1
    Views:
    4,902
  2. DNass
    Replies:
    6
    Views:
    2,754
    Darryl L. Pierce
    Nov 28, 2004
  3. Ike
    Replies:
    4
    Views:
    747
    Thomas Weidenfeller
    Jul 29, 2005
  4. Tron Thomas

    Preventing memory fragmentation

    Tron Thomas, Dec 22, 2003, in forum: C++
    Replies:
    18
    Views:
    885
    Tom Plunket
    Jan 3, 2004
  5. spasmous
    Replies:
    5
    Views:
    2,404
Loading...

Share This Page