remounting /usr readonly

Asked by Rolf Leggewie

I prefer to mount /boot and /usr readonly.

$ grep ,ro /etc/fstab
LABEL=BOOT /boot ext2 defaults,ro 0 2
LABEL=USR /usr ext2 defaults,ro 0 2

This works nicely. Whenever I need to do an update, I remount the partition in question as rw with "sudo mount -o rw,remount /usr/". Remounting it as readonly after that fails though because there are of course open processes accessing the partition all the time.

$ sudo mount -o ro,remount /usr/
mount: /usr is busy

Is there any way to do this without a complete reboot or dropping into single-user mode? I tried adding the -l switch to mount which sometimes helped me unmounting a busy partition in the past, but in this case this does not do the trick, either.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Rolf Leggewie
Solved:
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Rolf Leggewie (r0lf) said :
#2

I still have this problem. No comments from anyone?

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Rolf Leggewie (r0lf) said :
#4

The following seems to work (the -l switch is the key):

sudo mount -l -o remount,ro /usr/

Revision history for this message
Rolf Leggewie (r0lf) said :
#5

closing

Revision history for this message
Olaf Dietsche (olaf.dietsche) said :
#6

This problem still exists.
It usually happens, when a package related to the desktop is updated, installed or removed. Some update script modifies the files

/usr/share/glib-2.0/schemas/gschemas.compiled
/usr/share/icons/hicolor/icon-theme.cache

Programs using gnome have these files open and prevent /usr from being remounted readonly afterwards.

You can see this with lsof

lsof /usr | grep DEL

sudo mount -l -o remount,ro /usr/ cannot help here, because -l only adds the labels to mount output.
I suspect it worked before, because there was an update to a package not using gnome libraries.

A real solution would move these files to some /var directory.