On Ubuntu 13.10 when I safely remove my usb hard disk, I have to wait for a few minutes for the hard disk to stop spinning.
After checking Ubuntu forums I found a program called “udisks”
To use this command line program you need to know the file system location.
output of “df” command on terminal for my pendrive was
1
2
3
$ df
/dev/sdb1 2000262 903550 1096712 /media/test/UUI
Now to safely remove this using udisks command, we will have to execute the below commands.
1
2
3
$ udisks --unmount /dev/sdb1
$ udisks --detach /dev/sdb
To create a GUI for the above steps I wrote a java applet which searches for devices mounted on “/media” location and then allows the user to safely remove them.
The “/media” location can be changed or other locations can be easily added to the code.
The program GIT-HUB location is: safely-remove-usb-drive
- Get the project
1
$ git clone https://github.com/chandnarahul/safely-remove-usb-drive.git
- Build the project
1
2
3
$ cd safely-remove-usb-drive.git
$ mvn clean install
Once the project has been successfully compiled goto the target folder and execute the below command to run the applet.
1
2
3
$ cd target
$ java -jar SafelyRemoveUsbDrive-1.0-SNAPSHOT.jar
The applet will run and if no USB devices have been mounted on “/media” path then no devices will appear on the drop-down.
Click on “Refresh” button once the USB device has been connected to the PC.
The device will then appear on the drop-down.
Click on “Safely Remove” button to remove the USB device.
A message box pop-up will appear once the device has been removed.