1

I am trying to add support for a proprietary codec in Opera according to this question. However, my version of Opera is installed as a snap. I thus would need to know how to create a directory and copy a file into the snap folder in Ubuntu 20.04.

More specifically, the issue is that the Opera browser is installed in the snap folder and if I try to create a directory in that folder, I get the error mkdir: cannot create directory ‘lib_extra’: Read-only file system. The complete path of Opera is snap/opera/85/usr/lib/x86_64-linux-gnu/opera. I also tried to use chmod and mount-remount but I got similar errors.

vanadium
  • 98,427
cholo14
  • 141
  • 1
    You are not supposed to create directories there. These are read-only file systems provided by the mounted .snap disk image of the package. So rather than asking a secondary question on how you think the real problem can be solved, describe the real problem you want to solve. That may lead to quite different approaches than what you currently think is the solution. – vanadium Aug 19 '20 at 08:55
  • @vanadium the real problem I want to solve is already described in the question I linked. Explaining it here would result in a duplicate of that question. Should I delete this question then? – cholo14 Aug 19 '20 at 09:36
  • 1
    I see now, it is probably the first two sentences that gave me the wrong impression. Still, the solution probably will need to be different: the application files of a snap package are consisting of a read only file system mounted during startup. So even if you could add a folder there, e.g. using mount --bind, you would need to have that set automatically each time during restart, e.g. with a custom systemd service. – vanadium Aug 19 '20 at 10:13
  • I have suggested an edit to the first lines of your question: feel free to reject if you do not agree. – vanadium Aug 19 '20 at 10:17
  • @vanadium thanks for your edit. You are right, the question was unclear before, now it is better phrased. I agree with your edit – cholo14 Aug 19 '20 at 12:00
  • Read the comments under this question. I don't use snaps but it looks like you have a ~/snaps folder where you can put extra files and additional configurations. – KGIII Aug 19 '20 at 14:40
  • @KGIII I tried your suggestion but unfortunately it didn't work – cholo14 Aug 20 '20 at 07:19

1 Answers1

3

There is a snap application called 'overlay' - you can install it via Snap Store. This little app makes it possible to remount a snap read/write. Then you can create a directory and copy files there. However, it needs to be repeated evry time the system starts up, so you have to write a script that is called on system startup, which remounts the Opera snap r/w using 'overlay', and then creates the appropriate directory and copies files. (Actually you don't have to use the 'overlay' application, you can remount a snap r/w using just 'mount' command with overlayfs, but that application simplifies it).

raj
  • 11,504
  • 1
    Just to make it explicit: overlay can remount read/write, but it cannot persist those changes in the image; the homepage https://snapcraft.io/overlay notes: "Now the snap can be edited! This is done via overlayfs, and it's temporary. One can undo it by rebooting, or by simply unmounting the overlay" – sdbbs Jan 24 '22 at 18:25
  • @sdbbs That's why I wrote that this solution needs a script that modifies the snap every time the system starts up. – raj Jan 24 '22 at 20:22