9

I state I am asking if it is possible and HOW. I note many forum answers are 'you can't' or 'you don't need to on Linux cause it is perfect and wonderful' - none of these answers will help.

Firstly, the HDD in question is SATA 163 GB and contains ONLY backup data like music, video and NO windows programs or installations. I have had a HDD failure in second HDD that is completely FUBAR so have lost my windows installation, this HDD had linux and windows dual boot, HDD is undetectable in BIOS.

The working HDD is 130GB full with capacity of 163GB (it is badly fragmented due to excessive use...). I intend to defrag this drive using USB linux OS (bootable USB with installation files and 'trial') and any other programs that will enable this task. Once this is done I intend to locate which data areas are free (the end of HDD data storage area), create a new partition on this free space, install linux full version and get things working.

+++

I understand fully the following:

I can buy a new HDD for install.

I can get an external hard drive, back up the data.

I also understand that copying off backup hdd and then copying back will do the same as defrag.

I ask this question to find out how to complete this action I have requested and NOT to complete it using the methods unavailable to me at this time.

Thanks

9
  • you don't hvae to defrag a ext filesystem, so no you can't do it.
    – Alvar
    Jul 13, 2013 at 16:48
  • 1
    Well, to add to "you can't" and "you don't need", I think you don't even want to. Defragmentation won't make a large area of free space. It will only defragment individual files - so they can still be scattered over the whole area. Secondly, if you succeed in moving files to the start of end of the current partition then it will take you the same amount of time as letting the partition shrink and have the resize process take care of that for you. (both methods require the same data to be moved).
    – gertvdijk
    Jul 13, 2013 at 16:48
  • however, I have one partition on this HDD. To create a new partition now would surely not allocate space fairly and keep all data. Surely I am right in saying partitioning this drive will involve data loss?? This is my issue... I wish to defrag only so I can safely 'move' data to a smaller area so it will read that 'HDD area from 130GB to 160GB is free' therefore a partition would be possible.
    – mike
    Jul 13, 2013 at 16:56
  • 2
    Alvar, it is not ext filesystem it is NTFS, and aswell as that linux can become fragmented and at times a defrag could be useful (except on new drives etc) despite what linux users say about allocation of HDD space by linux. This question asks: is this action possible and how would i do it, NOT should i do it.
    – mike
    Jul 13, 2013 at 16:58
  • 2
    well you never said what file system was used on the HDD
    – Alvar
    Jul 13, 2013 at 17:01

1 Answer 1

5

Personally I wouldn't bother to defrag the NTFS partition of the HDD since if you install Ubuntu on the spare part it will only use that amount as a hard drive and the rest will not be affected. Then just mount the NTFS on Ubuntu and access the files there.

An ext4 file system doesn't have the problems with empty slots as NTFS or FAT32. The problems with NTFS and FAT32 are that the storage is based on data being put in slots and if a files on fills up 15 slots but are assigned 16 slots then one slot will be empty.

Here is where defrag comes in and moves the data around so that the data is used in each slot and the empty slots are declared as empty instead of used by this and that file. This saves space and makes access times shorter since you don't have to search the whole HDD for a file.

In ext4 files are divided throughout the disk and the fields where the data is stored is linked to the original file, so a file can be stored in row 1 field 2, row 3 field 12, etc.

So moving files around to save space doesn't work in ext4, you will make no more room on the hard drive. it will be just as easy to access files as it was before. This is just an example of the principle, explaining it in detail seemed too complex right now.

Is it possible to defrag an NTFS from Ubuntu
What I've found out by searching on this topic is that there is no program to defrag an NTFS HDD from Ubuntu. The best solution is to:

  1. Mount the HDD under Ubuntu
  2. Copy the files to another HDD
  3. Re-format the HDD (preferably with ext4)
  4. Move back the files

If you don't have another drive I would

  1. Create a ext4 partition on the empty space and move some files to there
  2. Remove those files from the NTFS partition
  3. Resize the NTFS partition to make it smaller
  4. Make the ext4 partition larger

Do this procedure until all files are moved and the NTFS partition is gone.

18
  • 1
    I am not trying to create 'more' space, I am trying to compress the files in one section of the HDD so I can manually create the space for a possible new partition. As I said before the question is how can you do this, please refer to the question.
    – mike
    Jul 13, 2013 at 17:04
  • Unless I am wrong a defrag can allow files to be stored in sections 0-130 GB with the rest empty. Im trying to make a new partition that is all.
    – mike
    Jul 13, 2013 at 17:07
  • @mike, you can make a new partition without defragging.
    – Alaa Ali
    Jul 13, 2013 at 17:08
  • 2
    @mike No. Read up on how filesystems work. Your continuing repeated question about to control the physical spot on the hard drive does not make sense for what you're trying to achieve. Shrinking a filesystem (and partition) should not delete any files.
    – gertvdijk
    Jul 13, 2013 at 17:13
  • 1
    Just wanted to add that the order of shrinking the filesystem and then shrinking the partition is important. Otherwise you will lose data. And yes, a filesystem is different from a partition, in case you are frowning upon this comment.
    – gertvdijk
    Jul 13, 2013 at 17:19

Not the answer you're looking for? Browse other questions tagged .