Results 1 to 10 of 19
hello 2 all.
there's an interesting tool "USB Safily Remove" for windows. It allows to safily remove usb flash drive by simply pressing hotkeys (for example Win+S ).
And I ...
- 06-22-2009 #1
safely remove usb flash drive with hotkeys
hello 2 all.
there's an interesting tool "USB Safily Remove" for windows. It allows to safily remove usb flash drive by simply pressing hotkeys (for example Win+S).
And I can remove device without using of mouse: easily and quickly. =)
Does anybody know, is there something similar to Linux?
I use GNOME, maybe there's some desklet or other widget with same functionality.
Thanx
- 06-23-2009 #2
I don't use GNOME much these days, but I believe you can just bind what keys you like to the umount command. Umount requires root priveleges, so you could also install pmount to mount and unmount as a user.
Or, presumably, you could bind gnome-mount to some key shortcut as well.
- 06-23-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
You can easily "safely remove" a usb drive by right-clicking on the drive icon on the desktop and select "Safely Remove" or "Unmount".
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-23-2009 #4
I think he was looking for a keybinding to do it, rather than using the mouse?
- 06-24-2009 #5Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
I know nothing about gnome, but most WM's do have a functionality to umount a given drive. First you need to know where the drive has been mounted, then you can bind the needed umount command to the key.
In kde you can define key bindings in kcontrol (or systemsettings for kde4, I guess). In gnome, no idea, but look around the control panel or whatever tool is has to define key bindings, shortcuts or whatever the gnome crew call it.
If not, you can always use xbindkeys I guess.
Yes, you can do it with the mouse but I guess the original poster already knows that. He is looking for a simpler and faster way to do the same job.
- 06-24-2009 #6
safely remove? I know what you are talking about but safely remove is almost always for "moving discs" (actual physical hard drives). USB disks have no moving parts so you can't damage anything by taking it out without the "safely remove" (this goes for both linux an Windows). Please correct me if I'm wrong (anyone?) but from my understanding this is the case
Bodhi 1.3 & Bodhi 1.4 using E17
Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17
"The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"
- 06-24-2009 #7Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
You are confusing this with "parking the heads" (or so it seems at least), which is something you don't have to worry about since like 25 years ago. Movable parts or mechanical vs. flash drives have nothing to do with the safe removal you see in many desktops (including Windows).
This feature is referred to the integrity of the data. I have no idea if it also affects other things like voltage or something. In linux you need to "umount" a drive before removing it. Otherwise your data might not even reach the disk at all. That is, unless you mount -o sync that fs, which will make the I/O operations synchronous, which means that nothing is cached. This affects performance very badly of course, and it almost invalidates the I/O scheduler, which can be really negative for NAND based flash memories (it will significantly shorten their life).USB disks have no moving parts so you can't damage anything by taking it out without the "safely remove" (this goes for both linux an Windows). Please correct me if I'm wrong (anyone?) but from my understanding this is the case
Even then you mount -o sync, you should umount the drive before removing it just to make sure that every I/O operation over the drive has ended, otherwise you *will* eventually run intro trouble, which can range from lost files to completelly corrupted fs's which will screw up all the files in the volume.
In windows you don't have the umount command, but you have the safe removal feature for *all* usb disks. It doesn't matter if the device is based on magnetic disks, nand or xor flash memories or whatever else. Some people refuse to use that feature, then they wonder where the files that they just recorded have gone... Go figure.
- 06-25-2009 #8Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
What i92guboj said. I've lost data on a USB drive when I removed it before unmounting it because of the delayed write behavior of the Linux file system. Because the delayed write caches data before writing it in blocks to the device, it will help lengthen the lifetime of the flash memory on the device. I recently read an article in one of the engineering mags about this issue, and that disabling the write-behind cache will seriously impair both performance and the life expectancy of a USB flash drive. Caveat User!
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-25-2009 #9Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Yep.
In this kind of device, you can only write whole blocks, not single bytes. If you mount -o sync then you are telling the fs driver that each time there's a single byte to write, it *must* write it without any delay. If you make 20 consecutive writes leaving a bit of time between them then the same block might be written 20 times. When you mount as usual, these operations would be delayed for some time, so there's a big chance that the 20 operations can be done in one sweep when it comes the time to do so. 20 write operations vs. 1. Due to the fact that nand devices have a limited write cycle mounting them in sync mode is usually not a good idea.
It's true, though, that the medium life of these toys is nowadays much larger than it used to be, and that they are cheap enough. So it all depends on the circumstances.
There are other things to consider, for example, laptops + mechanical drive + mount sync equals to throwing your battery through the window. And so on, you just need to be creative
- 06-28-2009 #10
udev rules
Udev Rules would be my answer as then you would not need to run any commands or push a button or anything but unplug the USB device. Here is how yuo go about making a rule for your device.
1) as root run this command. -> udevadm monitor --env
2) Plugin in your USB device.
3) Once you see it stop scrolling grab the -> DEVPATH=
Example of my output:
UDEV [1246154651.585662] add /block/sde/sde1 (block)
UDEV_LOG=3
ACTION=add
DEVPATH=/block/sde/sde1
SUBSYSTEM=block
SEQNUM=1543
DEVTYPE=partition
ID_VENDOR=Staples
ID_MODEL=Staples_UFD
ID_REVISION=PMAP
ID_SERIAL=Staples_Staples_UFD_0778169494F2-0:0
ID_SERIAL_SHORT=0778169494F2
ID_TYPE=disk
ID_INSTANCE=0:0
ID_BUS=usb
ID_PATH=pci-0000:00:1d.7-usb-0:4.1.4:1.0-scsi-0:0:0:0
ID_FS_USAGE=filesystem
ID_FS_TYPE=vfat
ID_FS_VERSION=FAT16
ID_FS_UUID=48B6-EF7A
ID_FS_UUID_ENC=48B6-EF7A
FSTAB_NAME=/dev/256m1
FSTAB_DIR=/mnt/usb-sticks/256M
FSTAB_TYPE=vfat
FSTAB_OPTS=defaults,noauto
FSTAB_FREQ=0
FSTAB_PASSNO=0
DEVNAME=/dev/sde1
MAJOR=8
Once you get DEVPATH plug it into this command.
udevadm info --query=all --path=/block/sde/sde1 --attribute-walk| less
You are looking for the "third" section down. Please look at my output below.
looking at device '/block/sde/sde1':
KERNEL=="sde1"
SUBSYSTEM=="block"
DRIVER==""
ATTR{stat}==" 671 1336 0 0"
ATTR{size}=="497952"
ATTR{start}=="63"
looking at parent device '/block/sde':
KERNELS=="sde"
SUBSYSTEMS=="block"
DRIVERS==""
ATTRS{capability}=="13"
ATTRS{stat}==" 79 673 1984 140 0 0 0 0 0 110 140"
ATTRS{size}=="503808"
ATTRS{removable}=="1"
ATTRS{range}=="16"
looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4.1/1-4.1.4/1-4.1.4:1.0/host7/target7:0:0/7:0:0:0':
KERNELS=="7:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{ioerr_cnt}=="0x2"
ATTRS{iodone_cnt}=="0x68"
ATTRS{iorequest_cnt}=="0x68"
ATTRS{iocounterbits}=="32"
ATTRS{timeout}=="30"
ATTRS{state}=="running"
ATTRS{rev}=="PMAP"
ATTRS{model}=="Staples UFD "
ATTRS{vendor}=="Staples "
ATTRS{scsi_level}=="0"
ATTRS{type}=="0"
ATTRS{queue_type}=="none"
ATTRS{queue_depth}=="1"
ATTRS{device_blocked}=="0"
ATTRS{max_sectors}=="240"
That one ^^ Now Pull the same lines I did, copy EXACTLY "yes even the white spaces.
Create this file if it is not there, for your homeade rules. -> /etc/udev/rules.d/10-local.rules
You will need two lines. One for mounting the /dev/. One for umouny /dev
Here are my two lines.
ACTION=="add", SUBSYSTEMS=="scsi", KERNEL=="sd*", ATTRS{model}=="Staples UFD ", NAME="%k", SYMLINK+="256m%n", RUN+="/bin/mount -o defaults /dev/256m1 /mnt/usb-sticks/256M"
ACTION=="remove", SUBSYSTEMS=="scsi", KERNEL=="sd*", ATTRS{model}=="Staples UFD ", NAME="%k", SYMLINK+="256m%n", RUN+="/bin/umount -f -l /mnt/usb-sticks/256M"
I will break this down for you.
ACTION=="add", <- start with that as you want udev to "add" the /dev
Pull these next three from your output above.
SUBSYSTEMS=="scsi",
KERNEL=="sd*",
ATTRS{model}=="Staples UFD ",
SYMLINK+="256m%n", <- change the 256m to what ever you want your /dev symlink to be named.
RUN+="/bin/mount -o defaults /dev/256m1 /mnt/usb-sticks/256M" <- Where do you want it mounted? Change accordingly
root//gentoo 09:08 PM /var/log # ls -la /dev/256m*
lrwxrwxrwx 1 root root 3 2009-06-27 21:04 /dev/256m -> sde
lrwxrwxrwx 1 root root 4 2009-06-27 21:04 /dev/256m1 -> sde1
Udev creates the symlink as seen above ^
All that goes on one line each item has a comma and then a space to seperate them.
Repeat For the "remove" line. Change your information accordingly.
THAT IS YOUR RULE! FINISHED..
As you see once you get the correct information for your device udev will do all thew work. After you create your rules you can monitor yout device with the " udevadm monitor --env" command and see that everything checks.
Very nice don't you think? I hope you enjoy.


Reply With Quote
