the umount() saga for regular linux desktop users
Hi!
Quoted 6 lines
X-Original-To: [email protected]
From: Andy Lutomirski <[email protected]>
To: Andries Brouwer <[email protected]>
Cc: [email protected]
Subject: Re: theumount()saga for regular linux desktop users
Quoted 15 lines
Quoted 14 lines · Andries Brouwer
Quoted 5 lines · William
Regularly, when attempting to
umount()a filesystem I receive 'device is busy' errors. The only way (that I have found) to solve these problems is to go on a journey into processland and kill all the guilty ones that have tied themselves to the filesystem concerned.Do you know about the existence of the
MNT_DETACHflag of umount(2), or the -l option of umount(8)?It seems that does at least some of the things you are asking for.
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
Of course, even nicer would be "filesystem goes away now, all operations fail", but that needs kernel support.
Quoted 3 lines
Sometimes I want to "unmount cleanly, damnit, and I don't care if applications that are currently accessing it lose data." Windows can do this, and it's _useful_.
Agreed. When some machine refuses to eject cd because it is busy... That's bad. I have strong temptation to just remove AC power, plug it back and then claim my CD...
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 7 lines · Pavel Machek
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...
What's wrong with
fuser -k /mnt && umount /mnt
?
Quoted 1 line
Pavel
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedHi!
Quoted 11 lines
Quoted 7 lines
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...What's wrong with
fuser -k /mnt && umount /mnt
Okay, probably nothing (I knew about fuser, but did not know about -k option...). fuser followed by ps and kill is not nice.
[Perhaps umount could tell user about fuser -k ?]
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Am Sonntag, 2. Januar 2005 21:11 schrieb Adrian Bunk:
Quoted 5 lines · Pavel Machek
Quoted 4 lines
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
Quoted 8 lines
Quoted 4 lines
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...What's wrong with
fuser -k /mnt && umount /mnt
1. Would need suid.
2. Is a mindless slaughter of important processes.
3. Is a race condition.
Regards
Oliver
Quoted 11 lines · Oliver Neukum
Am Sonntag, 2. Januar 2005 21:11 schrieb Adrian Bunk:
Quoted 10 lines · Pavel Machek
Quoted 8 lines
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...
Quoted 5 lines
Quoted 3 lines
What's wrong with
fuser -k /mnt && umount /mnt1. Would need suid.
It needs suid only if you aren't root and you want to kill processes you don't own.
Yes, this might cause problems e.g. if users are allowed to mount their cdroms, but simply allowing them to kill processes of other users who access this device isn't a solution, too.
Quoted 1 line
2. Is a mindless slaughter of important processes.
It's what Pavel wanted to get included in umount.
Usually, you'll let fuser give you the list of processes and inspect them manually.
Quoted 1 line
3. Is a race condition.
Then put it into a while loop that executes until umount returns 0.
I still fail to see why I should implement half of fuser in umount. Either you are working at the command line and know about fuser or you are working through a GUI which can offer you a "kill all applications accessing this device" button that calls fuser.
Quoted 2 lines
Regards
Oliver
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedHi!
Quoted 28 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...Quoted 5 lines
Quoted 3 lines
What's wrong with
fuser -k /mnt && umount /mnt1. Would need suid.
It needs suid only if you aren't root and you want to kill processes you don't own.
Yes, this might cause problems e.g. if users are allowed to mount their cdroms, but simply allowing them to kill processes of other users who access this device isn't a solution, too.
Quoted 1 line
2. Is a mindless slaughter of important processes.
It's what Pavel wanted to get included in umount.
Usually, you'll let fuser give you the list of processes and inspect them manually.
Quoted 8 lines
Quoted 1 line
3. Is a race condition.
Then put it into a while loop that executes until umount returns 0.
I still fail to see why I should implement half of fuser in umount. Either you are working at the command line and know about fuser or you are working through a GUI which can offer you a "kill all applications accessing this device" button that calls fuser.
Okay, so the right solution is probably something more like
while umount /mnt; do
fuser -km -TERM /mnt
sleep 1
fuser -km /mnt
done
Not sure how many command line users can do this... Perhaps including fumount script doing this is good idea?
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 11 lines · Pavel Machek
Okay, so the right solution is probably something more like
while umount /mnt; do
fuser -km -TERM /mnt
sleep 1
fuser -km /mnt
doneNot sure how many command line users can do this... Perhaps including fumount script doing this is good idea?
A command line user only needs to know about fuser, and in the unlikely case if the race condition Oliver thought of occurs he'll note since umount will give an error message.
I'd even say the more common case is to use fuser to get the PIDs of the processes and manually check which they are - e.g. you might not want to kill your OpenOffice with many open documents only because you'd forgotten that it still has one document open on the file system you are trying to remove.
Quoted 1 line
Pavel
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 10 lines · Adrian Bunk
Quoted 8 lines · Pavel Machek
Okay, so the right solution is probably something more like
while umount /mnt; do
fuser -km -TERM /mnt
sleep 1
fuser -km /mnt
done
Quoted 3 lines
A command line user only needs to know about fuser, and in the unlikely case if the race condition Oliver thought of occurs he'll note since umount will give an error message.
There's a much more interesting race: another process succesfully umounting the thing while this one's asleep.
Signature · 1 line
Frank
Quoted 11 lines · Frank van Maarseveen
Quoted 8 lines · Adrian Bunk
Quoted 7 lines · Pavel Machek
Okay, so the right solution is probably something more like
while umount /mnt; do
fuser -km -TERM /mnt
sleep 1
fuser -km /mnt
doneThere's a much more interesting race: another process succesfully umounting the thing while this one's asleep.
For those who don't know what happens: fuser -km /mnt will act like fuser -km / in that race and kill all processes.
BTDT :-(
Quoted 3 lines · Adrian Bunk
What's wrong with
fuser -k /mnt && umount /mnt
Better: fuser -km /mnt
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 10 lines · Adrian Bunk
Quoted 7 lines · Pavel Machek
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...
Quoted 4 lines
What's wrong with
fuser -k /mnt && umount /mnt
...
I meant
fuser -km /mnt && umount /mnt
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 23 lines · Adrian Bunk
Quoted 13 lines · Adrian Bunk
Quoted 9 lines · Pavel Machek
Well, umount -l can be handy, but it does not allow you to get your CD back from the drive.
umount --kill that kills whoever is responsible for filesystem being busy would solve part of the problem (that can be done in userspace, today).
...Quoted 6 lines
What's wrong with
fuser -k /mnt && umount /mnt
...
Quoted 9 lines
I meant
fuser -km /mnt && umount /mnt
cu
Adrian
I'm as newbie as they get but the above command just made my system freeze hard and I could do nothing but reboot (use the power switch). I had nothing mounted there but have a directory under /mnt where I occasionaly mount my samba share. (which was not mounted when I tried this) . So much for user friendlyness ... oh well ...
~puneet