This umount fail is a very big worry

Moderator: BarryK

Post Reply
User avatar
BarryK
Posts: 2692
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 132 times
Been thanked: 738 times

This umount fail is a very big worry

Post by BarryK »

In EasyOS there is a bash script /usr/local/limine-installer/find-installations, that searches for all installed OSs.
I am using it to install Limine bootloader, and it is useful to multiple-boot any OS, not just EasyOS.

Anyway, I ran the script from a terminal:

Code: Select all

# export UEFIflg=1
# /usr/local/limine-installer/find-installations

And it reported unable to unmount some partitions, with the message "resource busy".

What the script does is mount each partition read-only, if not already mounted, perform a search, then unmount, like this:

Code: Select all

  mkdir -p /mnt/$aDEV
  mount -t $FSTYPE -r /dev/$aDEV /mnt/$aDEV 2>/dev/null

  ...search...

  sync
  umount /dev/$aDEV

The search is just a "find" operation, nothing exotic. That used to work fine, in fact didn't have the "sync" either, and umount always worked.

But no longer. I found inserting a "sleep 1" before the umount fixed unmounting.
But why should that be required?

What has changed that could be causing this? Well, the kernel version. Currently using 5.15.79.

The partition should just unmount, it should not be "busy". Having to implement the "sleep 1" hack is a real worry.

I think this is a question for the experts, like @dimkr , @Keef , @jamesbond , @01micko , etc.

The 'find-installations' script is here:
https://github.com/bkauler/woofq/blob/m ... tallations

User avatar
BarryK
Posts: 2692
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 132 times
Been thanked: 738 times

Re: This umount fail is a very big worry

Post by BarryK »

Note, it is only HDD partitions that are failing to unmount. The NVME SSD partitions all unmount without requiring the "sleep 1"

User avatar
wiak
Posts: 4082
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1208 times
Contact:

Re: This umount fail is a very big worry

Post by wiak »

I'm curious if using sync;sync improves matters though the following suggests that may be an urban legend?

https://unix.stackexchange.com/question ... -sync-sync

Also:

https://serverfault.com/questions/11506 ... down-linux

I can only speak to why you would issue sync multiple times. The command schedules the flush to disk but returns before the actual flush completes. Any subsequent sync command will block until any outstanding flush is in progress before scheduling another flush and exiting. Therefore, sync; sync ensures a synchronous flush. You do not need to do it more than 2 times, nor bring sleep into the mix.

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

dimkr
Posts: 2424
Joined: Wed Dec 30, 2020 6:14 pm
Has thanked: 53 times
Been thanked: 1202 times

Re: This umount fail is a very big worry

Post by dimkr »

Does this script cd /mnt/$aDEV?

User avatar
BarryK
Posts: 2692
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 132 times
Been thanked: 738 times

Re: This umount fail is a very big worry

Post by BarryK »

dimkr wrote: Sun Jan 01, 2023 12:15 pm

Does this script cd /mnt/$aDEV?

No, there is no 'cd'
Just a simple 'find' in each mounted partition (but no cd into it) and log results to a file in /tmp

wiak,
no, 'sysnc;sync' doesn't fix it!

Note, the script is using bash, but just on the off-chance, tried ash, same problem.

User avatar
rockedge
Site Admin
Posts: 6549
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2751 times
Been thanked: 2627 times
Contact:

Re: This umount fail is a very big worry

Post by rockedge »

this sounds like a kernel specific problem. Does a different kernel configuration fix it?

I seem to recall that 5.15+ series was buggy in several ways :ugeek:

dimkr
Posts: 2424
Joined: Wed Dec 30, 2020 6:14 pm
Has thanked: 53 times
Been thanked: 1202 times

Re: This umount fail is a very big worry

Post by dimkr »

Does umount -l work?

Also, I'd recommend you to dump the out of lsof to a file, just before that umount - maybe some process tries to access the mount point?

User avatar
BarryK
Posts: 2692
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 132 times
Been thanked: 738 times

Re: This umount fail is a very big worry

Post by BarryK »

rockedge wrote: Mon Jan 02, 2023 1:30 am

this sounds like a kernel specific problem. Does a different kernel configuration fix it?

I seem to recall that 5.15+ series was buggy in several ways :ugeek:

Hmmm, my memory was that the script worked before, but I just now tested it with EasyOS Pyro-series, with 5.4.6 kernel, and got the same "busy" messages.

User avatar
BarryK
Posts: 2692
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 132 times
Been thanked: 738 times

Re: This umount fail is a very big worry

Post by BarryK »

dimkr wrote: Mon Jan 02, 2023 6:58 am

Does umount -l work?

Also, I'd recommend you to dump the out of lsof to a file, just before that umount - maybe some process tries to access the mount point?

I took out the "sync" and "sleep 1", replaced with just this:

Code: Select all

  lsof /mnt/${aDEV}
  umount /dev/$aDEV

And lsof did not output anything, furthermore no busy message, all partitions unmounted:

Code: Select all

# export UEFIflg=1
# /usr/local/limine-installer/find-installations 
Found Windows
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Pyro64 1.3
Found Easy Pyro64 1.3
Found Easy Dunfell64 2.7.3
Found Easy Dunfell64 2.7.3
Found Easy Buster64 2.6.1
Found Easy Buster64 2.4.92
Found Easy Buster64 2.5.1
Found Easy Buster64 2.5.3
Found Easy Buster64 2.5.5
Found Easy Buster64 2.5
Found Easy Buster64 2.4.1
Found Easy Buster64 2.6.1
Found Easy Pyro64 1.3
Found Puppy EasyPup 
Found Puppy EasyPup 
Found Easy Dunfell64 3.4.4
Found Easy Dunfell64 4.2.2
Found Easy Dunfell64 3.4.7
Found Easy Dunfell64 4.1
Found Easy Dunfell64 4.2.2
Found Linux Quirky Buster64 8.8.1
Found Easy Dunfell64 4.4.2
Found Easy Dunfell64 4.4.1
Found Easy Dunfell64 4.3.4
Found Easy Dunfell64 4.5
Found Easy Dunfell64 4.3
Found Easy Dunfell64 4.5.2
Found Easy Dunfell64 4.4
Found Easy Dunfell64 4.5.1
Found Easy Dunfell64 4.5.3
Found Easy Dunfell64 4.2.3
Found Easy Dunfell64 4.2.7
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Dunfell64 4.3
#

Go back to how it was before, no sleep, no sync either, as it shouldn't be required with the partitions mounted read-only, get this:

Code: Select all

# /usr/local/limine-installer/find-installations 
Found Windows
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Pyro64 1.3
Found Easy Pyro64 1.3
umount: can't unmount /mnt/sda2: Resource busy
Found Easy Dunfell64 2.7.3
Found Easy Dunfell64 2.7.3
Found Easy Buster64 2.6.1
Found Easy Buster64 2.4.92
Found Easy Buster64 2.5.1
Found Easy Buster64 2.5.3
Found Easy Buster64 2.5.5
Found Easy Buster64 2.5
Found Easy Buster64 2.4.1
Found Easy Buster64 2.6.1
umount: can't unmount /mnt/sda4: Resource busy
Found Easy Pyro64 1.3
umount: can't unmount /mnt/sda5: Resource busy
Found Puppy EasyPup 
Found Puppy EasyPup 
Found Easy Dunfell64 3.4.4
Found Easy Dunfell64 4.2.2
Found Easy Dunfell64 3.4.7
Found Easy Dunfell64 4.1
Found Easy Dunfell64 4.2.2
umount: can't unmount /mnt/sda6: Resource busy
Found Linux Quirky Buster64 8.8.1
Found Easy Dunfell64 4.4.2
Found Easy Dunfell64 4.4.1
Found Easy Dunfell64 4.3.4
Found Easy Dunfell64 4.5
Found Easy Dunfell64 4.3
Found Easy Dunfell64 4.5.2
Found Easy Dunfell64 4.4
Found Easy Dunfell64 4.5.1
Found Easy Dunfell64 4.5.3
Found Easy Dunfell64 4.2.3
Found Easy Dunfell64 4.2.7
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Dunfell64 4.3
#

Now trying with "mount -l /dev/$aDEV":

Code: Select all

# /usr/local/limine-installer/find-installations 
Found Windows
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Pyro64 1.3
Found Easy Pyro64 1.3
Found Easy Dunfell64 2.7.3
Found Easy Dunfell64 2.7.3
Found Easy Buster64 2.6.1
Found Easy Buster64 2.4.92
Found Easy Buster64 2.5.1
Found Easy Buster64 2.5.3
Found Easy Buster64 2.5.5
Found Easy Buster64 2.5
Found Easy Buster64 2.4.1
Found Easy Buster64 2.6.1
Found Easy Pyro64 1.3
Found Puppy EasyPup 
Found Puppy EasyPup 
Found Easy Dunfell64 3.4.4
Found Easy Dunfell64 4.2.2
Found Easy Dunfell64 3.4.7
Found Easy Dunfell64 4.1
Found Easy Dunfell64 4.2.2
Found Linux Quirky Buster64 8.8.1
Found Easy Dunfell64 4.4.2
Found Easy Dunfell64 4.4.1
Found Easy Dunfell64 4.3.4
Found Easy Dunfell64 4.5
Found Easy Dunfell64 4.3
Found Easy Dunfell64 4.5.2
Found Easy Dunfell64 4.4
Found Easy Dunfell64 4.5.1
Found Easy Dunfell64 4.5.3
Found Easy Dunfell64 4.2.3
Found Easy Dunfell64 4.2.7
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Dunfell64 4.3
#

All partitions have unmounted.

In the case of using lsof, it would seem to have provided just enough delay for whatever is keeping the partitions busy, to have completed. I tried this (without a sync):

Code: Select all

  sleep 0.01
  umount /dev/$aDEV

Code: Select all

# /usr/local/limine-installer/find-installations 
Found Windows
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Pyro64 1.3
Found Easy Pyro64 1.3
Found Easy Dunfell64 2.7.3
Found Easy Dunfell64 2.7.3
Found Easy Buster64 2.6.1
Found Easy Buster64 2.4.92
Found Easy Buster64 2.5.1
Found Easy Buster64 2.5.3
Found Easy Buster64 2.5.5
Found Easy Buster64 2.5
Found Easy Buster64 2.4.1
Found Easy Buster64 2.6.1
umount: can't unmount /mnt/sda4: Resource busy
Found Easy Pyro64 1.3
Found Puppy EasyPup 
Found Puppy EasyPup 
Found Easy Dunfell64 3.4.4
Found Easy Dunfell64 4.2.2
Found Easy Dunfell64 3.4.7
Found Easy Dunfell64 4.1
Found Easy Dunfell64 4.2.2
Found Linux Quirky Buster64 8.8.1
Found Easy Dunfell64 4.4.2
Found Easy Dunfell64 4.4.1
Found Easy Dunfell64 4.3.4
Found Easy Dunfell64 4.5
Found Easy Dunfell64 4.3
Found Easy Dunfell64 4.5.2
Found Easy Dunfell64 4.4
Found Easy Dunfell64 4.5.1
Found Easy Dunfell64 4.5.3
Found Easy Dunfell64 4.2.3
Found Easy Dunfell64 4.2.7
Found Easy Dunfell64 4.5.3
Found Easy Buster64 2.3.2
Found Easy Dunfell64 4.3
#

Very interesting, almost succeeded. OK:

Code: Select all

  sleep 0.1
  umount /dev/$aDEV

...this time, all partitions unmounted.

This PC has two 1TB nvme SSDs and one 8TB HDD. Maybe there is something strange about the HDD.

Whatever, this behaviour is a worry, as I have so many scripts that mount a partition, read something off it, then unmount the partition. Standard practice is to have a "sync" before the umount. But now it is looking like have to put in a delay before unmounting.

Post Reply

Return to “EasyOS”