usb flash drive - Can a USB be removed with out un-mounting during de-fragmentation

08
2014-07
  • 09stephenb

    I have a USB flash drive formatted to fat32 and I have a batch file to defragment it. Would there be any damage done to the flash drive or it's files if I was to unplug it from the USB port while it was defragmenting. Thanks in advance.

  • Answers
  • Keltari

    Removing any drive while defragmenting can cause damage to the file system. When you defragment a drive, the computer is constantly reading data from the drive and writing it to different parts of the drive. So if you were to remove the drive during this process, there is a strong possibility data that was read will not get written and there will be corruption. You should always stop defragmenting before removing a drive.

    Also, if you dont have a removable drive set for quick removal in Windows, pulling it out before unmounting it can cause file damage as well.


  • Related Question

    Windows XP mounting USB drive to same letter as previously mapped network drive
  • GAThrawn

    Why does Windows always mount a USB drive as the next drive letter after the last physical drive, even when that letter is already taken by a mapped drive, and is there any way to improve this behaviour?

    What happens is I tend to use a few different flash drives on my PC, as well as having both a Blackberry and a personal phone that mount as USB drives when I plug them in to charge. Being on a corporate PC I also have a number of mapped network drives (some set by login script, some set as persistent mappings in my profile).

    When I first login I'll have drive letters like this:

    C: - Local Drive
    D: - DVD Drive
    G: - Login script mapped drive
    J: - Login script mapped drive

    When I plug the Blackberry in it'll mount two drives (one for onboard storage, one for the SD card) as E: and F:. If I then plug in another USB drive it will mount as G:, even though that's already taken by a network mapped drive. This leaves me with the following drives:

    C: - Local Drive
    D: - DVD Drive
    E: - USB drive (Blackberry)
    F: - USB drive (Blackberry)
    G: - Login script mapped drive
    [G: - USB drive - mounted but not visible in Explorer or command prompt]
    J: - Login script mapped drive

    I then have to go into Disk Management, find the new USB drive that's mounted to G: and re-assign it to another letter eg Z:, once this is done Auto-Play detects it and throws up its normal dialog, and its browseable in Explorer.

    While this is OK to do if you only use one or two USB drives and have admin access to your PC with your login account, its a total pain in the proverbial if you regularly use a whole load of different USB devices, and corporate policy means you have one account for your normal login (that only has User access to workstations), but have to use a different account for any privileged action.

    I realize that one possible reason for this is the difference between hardware which is mounted and assigned drive letters at the systen level, and mapped drives which are done at the user level. For USB devices that are already plugged in before login, then obviously they're mounted before Windows knows what network drives may be mapped. However if you plug the USB devices in after you're fully logged in and have drives mapped then Windows must know which letters are available?


  • Related Answers
  • Snark

    For this kind of problem, USB Drive Letter Management (USBDLM) makes wonders. You can allocate drive letters to USB drives, make sure it does not interfere with network drives, ...

    From their Getting Started section:

    When a removable drive (USB flash drive, flash card reader, portable hard drive) is attached for the first time, Windows mounts it to the first available 'local' drive letter. If there is a network share on this letter, Windows XP will use it anyway for the new USB drive because since XP network shares are specific to the current user and not visible in the context of the system where the letter is assigned. The USB drive then appears to be invisible. This is fixed by SP3 in most situations. You can change the letter assignments in the Windows Disk Management Console with a lot of mouse clicks but you have to do it again for every new device. And, for USB devices that have no serial number (in violation of the USB standards) you have to do it too when you attach it to a different USB port. USBDLM can for newly attached USB drives

    ...

    check if the letter is used by a network share of the currently logged on user and assign the next letter that is really available

  • Synetech

    You can try the mountvol command:

    mountvol g: /d
    mountvol 
    

    To get the right VolumeName:

    mountvol h: \\?\Volume{blablabla}\
    
  • Raystafarian

    The Windows-native way to do this may be DISKPART. It works for me.

    From the DISKPART> prompt use:

    list volume

    to identify the USB drive,

    select volume {number}

    to choose it then

    assign letter={letter}

    to set its drive letter.

  • Russ Warren

    It's a huge pain and I'm not quite sure why Microsoft didn't right some extra code to use the next available letter.

    You might consider pestering your IT department to change the login script to map the network drive in the latter half of the alphabet instead of "G." Depending on the size of your operation and the extent of use of the network drive, that might be a huge undertaking.