We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

pipuppy
Posts: 97
Joined: Fri Aug 24, 2012 12:51 pm

How to delete a read-only directory in Rasbian Bookworm release.

Tue Nov 21, 2023 11:16 am

Hi,

I recently came back to using my raspi 400 after a break of almost a year. I also re-flashed the SD card to take advantage of the newer Bookworm release of raspbian and for the most part everything works as I remeber except for the "rm" trminal command.

I would like to remove an unwanted "snap" directory which remained after removal of the snap-store package.

I Googled for information on how to remove an unwanted directory in Debian linux and the pages I have read describe variants of the rm command which I have been trying.

I open a terminal window, navigate to the "/" directory and then attempt to remove the unwanted "snap" directory using

Code: Select all

sudo rm -r snap
Each time I try to delete the unwanted directory I get the following error message which keeps repeating for every file in the directory and sub directories.

Code: Select all

rm: cannot remove 'snap/core22/867/usr/lib/aarch64-linux-gnu/libzstd.so.1.4.8': Read-only file system
I had a go at changing file permissions with...

Code: Select all

sudo chmod +rwx snap
and then

Code: Select all

sudo rm -r snap
and other variations of the rm command but the directory refuses to delete.

I could just re-flash but thats the cowards way out and I wont learn anything from my mistakes :D

After a year away from using terminal commands I have become very rusty and suspect I am missing something here and would appreciate some pointers as to which terminal command I should be using to delete an unwanted directory :oops:



Pipuppy

User avatar
B.Goode
Posts: 18715
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to delete a read-only directory in Rasbian Bookworm release.

Tue Nov 21, 2023 12:20 pm

pipuppy wrote:
Tue Nov 21, 2023 11:16 am
Hi,

I recently came back to using my raspi 400 after a break of almost a year. I also re-flashed the SD card to take advantage of the newer Bookworm release of raspbian and for the most part everything works as I remeber except for the "rm" trminal command.

I would like to remove an unwanted "snap" directory which remained after removal of the snap-store package.

I Googled for information on how to remove an unwanted directory in Debian linux and the pages I have read describe variants of the rm command which I have been trying.

I open a terminal window, navigate to the "/" directory and then attempt to remove the unwanted "snap" directory using

Code: Select all

sudo rm -r snap
Each time I try to delete the unwanted directory I get the following error message which keeps repeating for every file in the directory and sub directories.

Code: Select all

rm: cannot remove 'snap/core22/867/usr/lib/aarch64-linux-gnu/libzstd.so.1.4.8': Read-only file system
I had a go at changing file permissions with...

Code: Select all

sudo chmod +rwx snap
and then

Code: Select all

sudo rm -r snap
and other variations of the rm command but the directory refuses to delete.

I could just re-flash but thats the cowards way out and I wont learn anything from my mistakes :D

After a year away from using terminal commands I have become very rusty and suspect I am missing something here and would appreciate some pointers as to which terminal command I should be using to delete an unwanted directory :oops:



Pipuppy

If this were my issue to resolve I would be investigating why the Operating System thinks it has a Read-Only root filesystem. (This is a different level of protection to having a read-only file or a read-only directory.)

I don't think that is the standard behaviour/configuration of RasPiOS Bookworm.


Are you running some other 'rasbian' OS, or have you made some change subsequent to flashing it to the microSD card?
Beware of the Leopard

User avatar
neilgl
Posts: 11167
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: How to delete a read-only directory in Rasbian Bookworm release.

Tue Nov 21, 2023 12:33 pm

Maybe

Code: Select all

rm -rf snap

User avatar
kerry_s
Posts: 8430
Joined: Thu Jan 30, 2020 7:14 pm

Re: How to delete a read-only directory in Rasbian Bookworm release.

Tue Nov 21, 2023 12:41 pm

navigate to the "/" directory
you sure you removed, snaps are mounted.


do a double check.

Code: Select all

apt search ^snap | grep installed
clean

Code: Select all

sudo apt -y autoremove && sudo apt -y clean && sudo apt -y purge ?config-files

cleverca22
Posts: 9564
Joined: Sat Aug 18, 2012 2:33 pm

Re: How to delete a read-only directory in Rasbian Bookworm release.

Tue Nov 21, 2023 1:15 pm

B.Goode wrote:
Tue Nov 21, 2023 12:20 pm
If this were my issue to resolve I would be investigating why the Operating System thinks it has a Read-Only root filesystem. (This is a different level of protection to having a read-only file or a read-only directory.)
but is it even the root that is read-only?

snaps work by mounting something, so it may actually be a snap that is mounted read-only
in that case, the answer is to just umount it, or tell snapd to stop doing whatever its doing, or uninstall snap

User avatar
B.Goode
Posts: 18715
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to delete a read-only directory in Rasbian Bookworm release.

Tue Nov 21, 2023 1:26 pm

cleverca22 wrote:
Tue Nov 21, 2023 1:15 pm
B.Goode wrote:
Tue Nov 21, 2023 12:20 pm
If this were my issue to resolve I would be investigating why the Operating System thinks it has a Read-Only root filesystem. (This is a different level of protection to having a read-only file or a read-only directory.)
but is it even the root that is read-only?

I am content for the user to find that is not the case.


My response was based on the disparity between the topic Title: How to delete a read-only directory, and the error
reported in the message text: rm: cannot remove 'snap/core22/867/usr/lib/aarch64-linux-gnu/libzstd.so.1.4.8': Read-only file system


That seemed worth drawing attention to for investigation. It is good that other volunteers can provide more focussed advice.
Beware of the Leopard

pipuppy
Posts: 97
Joined: Fri Aug 24, 2012 12:51 pm

Re: How to delete a read-only directory in Rasbian Bookworm release.

Wed Nov 22, 2023 11:06 am

Hi again,

First of all my thanks to all of you for taking the time to respond to my request for help.

I am pleased to report that following the advice of kerry_s the problem has now been resolved.

kerry_ advised...

Code: Select all

apt search ^snap | grep installed
and...

Code: Select all

sudo apt -y autoremove && sudo apt -y clean && sudo apt -y purge ?config-files
I dont fully understand exactly where I went wrong but it is now clear that some residue of the snap store was still present after using apt-get remove snap-store command.

After reading this webpage...

https://linuxsimply.com/linux-basics/pa ... ove-purge/

I strongly suspect that I had only removed the snap-store package and possibly left behind snapd, the snap-core or both and that was preventing the unwanted directory from being attacked.

Because the entry in the applications menu had been removed I had wrongly assumed that the snap-store bundle had been fully removed :oops:

After following kerry_s instructions the problem is now resolved and I will now know what to look for if I run into this problem again in the future so, my thanks to kerry_s for pointing me in the right direction.

Regards,

pipuppy

Return to “Beginners”