git-bashwindows-7-x64usb-flash-drive

Safely remove flash drive - git bash - Windows 7 x 64


I am trying to eject a usb flash drive but I cannot find a way to do it via git bash. Of course I can do it the traditional way, but I want to know if there is an option via git bash. Thanks


Solution

  • If you run the git bash as admin you could unmount a drive labeled E: this way:

    cmd.exe /C 'mountvol  E:\ /P'
    

    But please be very careful with it. Double check your volume's label with

    cmd.exe /C 'mountvol' 
    

    before and make sure you didn't hit any partition which you shouldn't remove.

    Here are some remarks from Microsoft:

    • /p : Removes the volume mount point from the specified directory, dismounts the basic volume, and takes the basic volume offline, making it unmountable. If other processes are using the volume, mountvol closes any open handles before dismounting the volume.
    • Volumes that are dismounted by using /p are listed in the volumes list as "NOT MOUNTED UNTIL A VOLUME MOUNT POINT IS CREATED." If the volume has more than one mount point, use /d to remove the additional mount points before using /p. You can make the basic volume mountable again by assigning a volume mount point.

    Check this: Mountvol man