Any need for defragmentation before partitioning?

Discussion in 'General Linux' started by Yesyesloud, Jan 12, 2014.

  1. Yesyesloud

    Yesyesloud Active Member

    Messages:
    170
    Likes Received:
    76
    Trophy Points:
    28
    Hello there... I finally decided to install a new, say, permanent distro on my laptop and I'm going for Arch, since it's a 'power user' lightweight OS still featuring practical ways to install thousands of applications (I am always testing new software, it's better to have dependency complaints automatically solved). Two questions emerged, however.

    1st: There's only one HDD on this laptop, containing a single EXT4 partition (having 6GB RAM, I'm no SWAP fan; I even reclaimed almost all system reserved blocks to free space), and I want to install ARCH alongside my present GNU/Linux install. As I intend to create a new partition, it must be done under rescue mode or with a live cd, the only ways I am allowed to unmount and resize the current one. I want to make a 50GB segment - there's about 400GB of free space. Still, I am warned I can lose data if I do it. I decided to defragment my disk just to make sure I won't lose anything while splitting those free gigabytes... But, hey, there's a lot of free space at the end of the drive and Linux tend not to fragment data, specially when it's running on a smart EXT4 file system. So... Is defragmentation really necessary before partitioning, in this particular case?

    2nd: I've been running e4defrag for an hour on this 500GB, 7200 RPM, 16MB Cache, SATA hard drive (single ext4 partition, as mentioned). Only ~100GB in use, 0,5-1GB files mostly. Any ideas on how long may the defrag process take? Windows' could take days.


    I know I should back up everything and just do it the easy way, but I have no spare storage with enough free space.


    Thanks in advance for any ideas.
  2. Eric Hansen

    Eric Hansen Member

    Messages:
    95
    Likes Received:
    38
    Trophy Points:
    18
    When it comes to partitioning there's always going to be that inherent risk of data loss. You're essentially moving data on the disk itself.

    As for defragging before partitioning, no. Unlike NTFS and other Windows-centric filesystems, if you're sticking with EXT2-4 it does a pretty good job itself on handling fragmented files. However, it never hurts to run fsck to make sure.

    Truthfully, not sure why you're running e4defrag, I'll point you to this Ubuntu question that handles it pretty well: http://askubuntu.com/a/265963

    The only tool you should have to run is fsck and that's just to make sure that the superblocks are synched and the filesystem is proper. Anything else is basically like taking a polished trophy and polishing it some more. Best case scenario nothing happens, worst case is you ruin it due to too much TLC.
  3. Yesyesloud

    Yesyesloud Active Member

    Messages:
    170
    Likes Received:
    76
    Trophy Points:
    28
    Yes... I guess that's what the partitioning software warned me about, as mentioned in the thread. But that risk is only inherent to user-oriented errors or damaged hardware.

    EXT4 sure is good at handling fragmented files, as also mentioned in the thread. I just wanted to make sure that defragmenting would eliminate the possibility of data loss.

    I really don't understand why that link was posted. I'm pretty sure about what I am doing with e4defrag and how it works precisely. I am not looking for discovering if e4defrag is safe (what kind of question was that?) or increasing disk performance, thus the question, the answer and the additional documentation pointed out in that link don't suit my defrag question related to safe partitioning.

    Isn't defragmentation a process that physically relocates fragmented data to where it belongs on the disk? I believed that if my HDD were utterly defragmented, meaning data would be physically stored according to what is shown in space allocation graphics, there would be most likely no risk in partitioning free space, since there wouldn't be any misplaced fragment in there. If that line of thinking is wrong, I'll just stick to the regular installation process, which will run fsck for me.


    Hijacking my own topic with a new question: why would anyone run e4defrag if EXT4 is that tidy? Having been created/adapted for a relatively new file system, e4defrag shouldn't even exist, then.

    I've run it again as root in recovery mode and it reported several failed attempts when the process ended (the same happened when X server and its whole process tree was running):
    Success: [ 177470/255010 ]
    Failure: [ 77540/255010 ]

    Hey, it only took about an hour and a quarter. One question conquered. Glorious. Much faster than NTFS or FAT defragging.

    I'll run it again, using a live cd to have full access to all of my disk. And there's absolutely no risk in doing that, unless I run out of power and my laptop battery can't carry on for that short time. I may be taking too much care, but I guess I will wait a bit more before partitioning my disk, as I want everything as polished as possible. If anyone has any other consideration with regards to those particular questions, I'm all eyes. Thanks anyway.
    Last edited: Jan 14, 2014
  4. Cyber-Berserker

    Cyber-Berserker Active Member

    Messages:
    242
    Likes Received:
    138
    Trophy Points:
    43
    If I understand things correctly, new files are always placed on the hard-drive contiguously. So as more files are added, the free space outside the occupied area gets smaller. De-fragging moves files around in order to optimise performance. It does not create unused space. Perhaps I am missing something, but I do not see the benefit of "de-fragging" before creating a new partition.
    Risk can be minimised, but not eliminated.
  5. |)/-\|)

    |)/-\|) Member

    Messages:
    30
    Likes Received:
    11
    Trophy Points:
    8
    I haven't tried Arch yet, but have installed multiple partitions and usb's with debian and its derivatives (read every flavor of ubuntu ;) ) and have found that 16G partition is usable for targeted applications (office suites or 1 to 2 language app development or games or ubuntustudio .... ).

    All you really have to do is decide how much of that 100G free space you want to devote to Arch and (know the disk device names that all of your OS's expect to see when you are finished BEFORE you start!) create that partition manually (either from your current system or Arch installer).

    I'm suffering from disk envy! (512 meg ram, 56G hd, 1.6Ghz Celeron) =(
  6. Yesyesloud

    Yesyesloud Active Member

    Messages:
    170
    Likes Received:
    76
    Trophy Points:
    28
    If you fill your entire hard drive and remove those files several times, cyclically (which happens with me), for whatever reason that suits your uses, fragmentation gets a little more complex than that. So, yes, something was missing. Who said defragmentation creates unused space?
  7. Cyber-Berserker

    Cyber-Berserker Active Member

    Messages:
    242
    Likes Received:
    138
    Trophy Points:
    43
    No one. I mentioned it as part of my description of how I understand de-fragging to work.
    I admit I am now lost. The way I see it is thus:
    1) If the hard-drive is almost full, a new partition cannot be created without destroying files.
    2) If there is enough unused space to create a new partition, creating said partition should not affect the other partition (other than make it smaller).

    I am not computer savvy, so something can easily escape my ability to understand. The only thing I am sure of is "de-frag" is Microsoft terminology. I do not even know the Linux/BSD word for the concept. It is something I have never had to worry about.

    Bottom line; if you are creating a new partition out of free space on the drive, I see no reason for it to affect the system already on the drive. Tidying up that system before or after partitioning is a matter unto itself. (My non-expert opinion.)
  8. |)/-\|)

    |)/-\|) Member

    Messages:
    30
    Likes Received:
    11
    Trophy Points:
    8
    ALWAYS BACKUP ANYTHING YOU CAN'T REPLACE OR DON'T WANT TO LOOSE BEFORE YOU START!!!

    If you only have 1 partition that takes the entire disk (with some amount of free space left in that partition) then a partition manager like gparted can be used to shrink the original partition so that you can use the free space for partition #2 You will have to boot from cd or usb so that your current system can be managed in an un-mounted state, but it is crucial that your original partition be shrunk (resized) before creating your new partition or YOU WILL LOOSE YOUR OLD SYSTEM.
  9. Cyber-Berserker

    Cyber-Berserker Active Member

    Messages:
    242
    Likes Received:
    138
    Trophy Points:
    43
    No shit.
    It should be obvious from the contents of the thread that Yesyesloud and I both know how to create partitions and multi-boot. That is not what the thread is about. The thread concerns the question of whether or not "de-fragging" a partition before re-sizing is beneficial.
    Again, no shit.
    You are either a spammer or someone trying to impress "the other computer geeks" with your knowledge.
  10. Yesyesloud

    Yesyesloud Active Member

    Messages:
    170
    Likes Received:
    76
    Trophy Points:
    28
    1) The hard drive has plenty of unused space right now (4/5 free), but the thing is its one and only huge partition has been almost completely filled and 'emptied' several times, cyclically. A lot of fragmentation resulted from that, having been spotted by e4defrag. Not all of it has been solved yet.

    If the disk is too fragmented, I tend to believe chances are I can lose data after partitioning. Isn't it one of the phantoms that haunt partitioning, one of the reasons why we're warned something can be lost? I wanted rock-solid information that ruled out that possibility.

    2) That's the basic idea. I can't afford to ruin my current system at all.


    I wouldn't say de-frag is MS-only terminology. That verb derives from the very common noun 'fragment'. E4defrag is linux software. Fragmentation also occurs on EXT partitions. It's actually a physical phenomenon in HDDs (special drives like SDDs suffer from fragmentation, it doesn't reduce performance at any extent due to their reading techniques, although it could also have side-effects over partitioning until proven otherwise).

    As MS seized more space in this debate... After analyzing one's hard disk (pretty long event), sometimes windows partitioning applications will only let a small part of free space be split, depending on the drive situation. I can't think of other reason for such free space partitioning limit but fragmentation, which's definitely not restricted to MS. Although EXT4 is smarter than NTFS or FAT, it's not perfect.

    In ideal - and most - circumstances, yes, I'm aware I shouldn't worry about splitting some of those free 400 gigabytes. If I wasn't able to imply this before, let it be clear now :)



    Cyber-Berserker already answered this odd message very well.

    Anyway, |)/-\|), if you can consistently assure me GParted/Parted or GNU/Linux installers partitioners (that may be just the same) will certainly analyze and consider fragmentation before partitioning, I'll just go for it.
    Last edited: Jan 13, 2014
  11. Cyber-Berserker

    Cyber-Berserker Active Member

    Messages:
    242
    Likes Received:
    138
    Trophy Points:
    43
    If a drive has been emptied, logical thinking says the drive is empty, so new files will be placed at the beginning. But as I mentioned, I am not even close to being an expert, and computers often do bizarre things. I would like to say your worry is unfounded, but in truth, I do not know.

    People are given the warning in case someone is foolish enough to screw around without making fresh copies of back-up files. Even experts can make mistakes when altering partitions or doing anything else.

    It is. The term became vogue, because Windows needs to be re-organised regularly to keep functioning. With a *nix system, fragmentation only becomes an issue when the hard-drive is almost full, and therefore, rarely encountered.

    And in this case. I doubt you have anything to worry about, other than the chance of human error when making the new partition. So be careful and good luck.:)
  12. |)/-\|)

    |)/-\|) Member

    Messages:
    30
    Likes Received:
    11
    Trophy Points:
    8
    No guarantees that any software will do anything anybody claims it will, but linux seems to recognize NT file systems and gparted (for me, anyway) did resize/split a VERY fragmented XP partition perfectly (had 20M empty in the XP file system) because it seems to move data in the partition you are shrinking (don't know that it is defraggin' as it goes).

    As for the warning, after rereading the the original question I was concerned that I may have misunderstood the layout of the disk concerning what was actually partitioned and what was not. I'm not trying to show off or impress anyone here 'cause I'm jus' a toothless ol' white man who's forgotten where he left his hat.
    DevynCJohnson likes this.
  13. Yesyesloud

    Yesyesloud Active Member

    Messages:
    170
    Likes Received:
    76
    Trophy Points:
    28
    I won't worry about the chance of human error when partitioning that single partition, only free space will be allowed to split up. I only fear the "unknown" possibilities of data loss, which remain unexplained and rather nonexistent according to the feedback I got in this thread.

    Thanks for the info on MS terminology trends, but I will stick with the idea that file system fragmentation is a physical phenomenon in hard disks.

    And really thanks for the luck wishes. I definitely have nothing to worry about right now, as I could finally perform a full defragmentation using a live cd :)
  14. Yesyesloud

    Yesyesloud Active Member

    Messages:
    170
    Likes Received:
    76
    Trophy Points:
    28
    Well, last time I resized a very fragmented XP partition, for a friend, a few months ago, using windows itself, I was only allowed to split ~15 GB of ~80 free gigabytes. I did it on Windows because the live cd distro I was trying to install warned me I could lose data after partitioning, thus I wanted to ensure Windows wouldn't be ruined (although I would secretly enjoy that hehe). Perhaps, Gparted is also better at splitting DOS partitions, but, as there's still doubt involved, I wouldn't use it to split a friend's Windows system.

    I also don't think anonymous users would have any need to show off, it's silly. Regardless, you didn't seem to consider primary information provided on this thread prior to posting.

    Please accept my sincere empathy for your tooth lack and abandoned hat, but this most unexpected passage of your message made my day.
    Last edited: Jan 13, 2014
    |)/-\|) likes this.
  15. |)/-\|)

    |)/-\|) Member

    Messages:
    30
    Likes Received:
    11
    Trophy Points:
    8
  16. |)/-\|)

    |)/-\|) Member

    Messages:
    30
    Likes Received:
    11
    Trophy Points:
    8
    It was late for me and I really should not have butted in.

    You are right about helping friends (or customers for that matter): "Physician do no harm!"

    The things on MS systems that I have seen that cannot be relocated usually are:
    1 - liscense keys (weird 3rd party copy protection schemes)
    2 - permenent swap file (for Windows itself, version dependant)
    3 - data locked in a cluster marked bad by os but still readable (very rare)
    DevynCJohnson likes this.

Share This Page