You are not logged in.

#1 2025-05-25 16:10:44

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 203
Website

[SOLVED] delete directory on a read-only filesystem

One of my system partition, /backup,  is from an external HD and is mounted this way via FSTAB:

# /dev/sda1 LABEL=backup
UUID=dccf798a-53a3-4fe5-aa77-95dc0fd28458	/backup	btrfs     	rw,noatime,ssd,discard,space_cache=v2	0 0

I want to clean part of this directory but can't as it is mounted as read-only filesystem (no idea why):

[root@magnolia /]# ls -al /backup/
total 16
drwxr-xr-x 1 gabx gabx 272 May 25 17:50 .
drwxr-xr-x 1 root root 208 May 21 23:56 ..
drwxr-xr-x 1 gabx gabx  38 Sep 18  2024 back-development-20240919114809
drwxr-xr-x 1 root root 424 May 23 18:00 back-development-20250523
drwx------ 1 root root 156 May 23 18:32 back-gabx-20250523
drwxr-xr-x 1 root root  24 Sep 19  2024 back-home-20240919114809
drwxr-xr-x 1 root root 198 Sep 19  2024 back-root-20240919114809
drwxr-xr-x 1 gabx gabx   0 Sep 12  2024 home_snapshots
# rm -r /back-up back-home-20240919114809
rm: cannot remove '/backup/back-home-20240919114809/gabx/.cache/yay/electron21/src/src/chrome/browser/apps/app_service/app_service_proxy_ash.h': Read-only file system
... and so on 

Now, I try to umount the partition:

[root@magnolia /]# umount /backup
umount: /backup: target is busy.
[root@magnolia /]# lsof /backup
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse.portal file system /run/user/1000/doc
      Output information may be incomplete.

How can I umount the partition, and then mount it with rw somewhere else so I can delete some folders (and maybe fsck it) ?
Why is this folder read-only as some others from /backup are not ? Btw, I can:

[root@magnolia /]# touch /backup/test
[root@magnolia /]# rm /backup/test

so this read only story looks weird to me.

Last edited by gabx (2025-05-26 17:04:04)

Offline

#2 2025-05-25 17:21:43

topcat01
Member
Registered: 2019-09-17
Posts: 191

Re: [SOLVED] delete directory on a read-only filesystem

Read-only means btrfs encountered an error. Please post the output of the journal, and also

sudo btrfs filesystem usage -T

Offline

#3 2025-05-25 17:55:17

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 203
Website

Re: [SOLVED] delete directory on a read-only filesystem

gabx@magnolia ➤➤ ~ % sudo btrfs filesystem usage -T /backup
Overall:
    Device size:		 400.00GiB
    Device allocated:		 334.99GiB
    Device unallocated:		  65.01GiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			 170.90GiB
    Free (estimated):		 221.16GiB	(min: 188.66GiB)
    Free (statfs, df):		 221.16GiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		 255.86MiB	(used: 0.00B)
    Multiple profiles:		        no

             Data      Metadata System
Id Path      single    DUP      DUP      Unallocated Total     Slack
-- --------- --------- -------- -------- ----------- --------- -----
 1 /dev/sda1 322.98GiB 12.00GiB 16.00MiB    65.01GiB 400.00GiB     -
-- --------- --------- -------- -------- ----------- --------- -----
   Total     322.98GiB  6.00GiB  8.00MiB    65.01GiB 400.00GiB 0.00B
   Used      166.82GiB  2.04GiB 64.00KiB
gabx@magnolia ➤➤ ~ % journalctl -r
May 25 19:52:41 magnolia sudo[3738]: pam_unix(sudo:session): session closed for user root
May 25 19:52:41 magnolia sudo[3738]: pam_unix(sudo:session): session opened for user root(uid=0) by gabx(uid=1000)
May 25 19:52:41 magnolia sudo[3738]:     gabx : TTY=pts/0 ; PWD=/home/gabxnew ; USER=root ; COMMAND=/usr/bin/btrfs filesystem usage -T /backup
May 25 19:51:59 magnolia sudo[3721]: pam_unix(sudo:session): session closed for user root
May 25 19:51:59 magnolia sudo[3721]: pam_unix(sudo:session): session opened for user root(uid=0) by gabx(uid=1000)
May 25 19:51:59 magnolia sudo[3721]:     gabx : TTY=pts/0 ; PWD=/home/gabxnew ; USER=root ; COMMAND=/usr/bin/btrfs filesystem usage -T
May 25 19:51:49 magnolia rtkit-daemon[1032]: Supervising 8 threads of 4 processes of 1 users.
May 25 19:51:49 magnolia rtkit-daemon[1032]: Successfully made thread 3705 of process 1834 owned by '1000' RT at priority 10.
May 25 19:51:49 magnolia rtkit-daemon[1032]: Supervising 7 threads of 4 processes of 1 users.
May 25 19:51:49 magnolia rtkit-daemon[1032]: Supervising 7 threads of 4 processes of 1 users.
May 25 19:51:36 magnolia cosmic-comp[1770]: Failed to parse marker-end value: 'none'.
May 25 19:51:36 magnolia cosmic-comp[1770]: Failed to parse marker-mid value: 'none'.
May 25 19:51:36 magnolia cosmic-comp[1770]: Failed to parse marker-start value: 'none'.
May 25 19:51:36 magnolia systemd[1]: systemd-coredump@0-3658-0.service: Consumed 157ms CPU time, 103.5M memory peak.
May 25 19:51:36 magnolia systemd[1]: systemd-coredump@0-3658-0.service: Deactivated successfully.
May 25 19:51:36 magnolia systemd-coredump[3659]: [?] Process 3656 (tokio-runtime-w) of user 1000 dumped core.

                                                 Stack trace of thread 3656:
                                                 #0  0x00007956fcc1a424 n/a (libc.so.6 + 0x97424)
                                                 #1  0x00007956b1b5ad77 n/a (libgallium-25.0.5-arch1.1.so + 0x55ad77)
                                                 #2  0x00007956b1b15457 n/a (libgallium-25.0.5-arch1.1.so + 0x515457)
                                                 #3  0x00007956b1b154ec n/a (libgallium-25.0.5-arch1.1.so + 0x5154ec)
                                                 #4  0x00007956fcbc35e1 n/a (libc.so.6 + 0x405e1)
                                                 #5  0x00007956fcbc36be exit (libc.so.6 + 0x406be)
                                                 #6  0x00005abde9984715 n/a (/usr/bin/cosmic-app-library + 0x15e5715)
                                                 #7  0x00005abde997ebd4 n/a (/usr/bin/cosmic-app-library + 0x15dfbd4)
                                                 #8  0x00005abde926dd88 n/a (/usr/bin/cosmic-app-library + 0xeced88)
                                                 #9  0x00005abde9271467 n/a (/usr/bin/cosmic-app-library + 0xed2467)
                                                 #10 0x00005abde9266c4b n/a (/usr/bin/cosmic-app-library + 0xec7c4b)
                                                 #11 0x00005abde91fd219 n/a (/usr/bin/cosmic-app-library + 0xe5e219)
                                                 #12 0x00005abde9a6a281 n/a (/usr/bin/cosmic-app-library + 0x16cb281)
                                                 #13 0x00005abde9a675d0 n/a (/usr/bin/cosmic-app-library + 0x16c85d0)
                                                 #14 0x00005abde9a4fc38 n/a (/usr/bin/cosmic-app-library + 0x16b0c38)
                                                 #15 0x00005abde9a6a0b8 n/a (/usr/bin/cosmic-app-library + 0x16cb0b8)
                                                 #16 0x00005abde9a5c272 n/a (/usr/bin/cosmic-app-library + 0x16bd272)
                                                 #17 0x00005abde9a4706d n/a (/usr/bin/cosmic-app-library + 0x16a806d)
                                                 #18 0x00005abde9a540ae n/a (/usr/bin/cosmic-app-library + 0x16b50ae)
                                                 #19 0x00005abde9a66104 n/a (/usr/bin/cosmic-app-library + 0x16c7104)
                                                 #20 0x00005abde9a7049e n/a (/usr/bin/cosmic-app-library + 0x16d149e)
                                                 #21 0x00005abde998590b n/a (/usr/bin/cosmic-app-library + 0x15e690b)
                                                 #22 0x00007956fcc187eb n/a (libc.so.6 + 0x957eb)
                                                 #23 0x00007956fcc9c18c n/a (libc.so.6 + 0x11918c)
                                                 ELF object binary architecture: AMD x86-64
May 25 19:51:36 magnolia systemd[1]: Started Process Core Dump (PID 3658/UID 0).
May 25 19:51:36 magnolia systemd[1]: Created slice Slice /system/systemd-coredump.
May 25 19:51:36 magnolia systemd-coredump[3658]: Process 3656 (tokio-runtime-w) of user 1000 terminated abnormally with signal 11/SEGV, processing...
May 25 19:51:36 magnolia kernel: Code: b1 55 f8 5d c3 90 f3 0f 1e fa 55 48 89 e5 41 57 41 56 41 55 41 54 53 48 83 ec 48 64 48 8b 04 25 28 00 00 00 48 89 45 c8 31 c0 <8b> 87 d0 02

Offline

#4 2025-05-25 19:04:04

topcat01
Member
Registered: 2019-09-17
Posts: 191

Re: [SOLVED] delete directory on a read-only filesystem

Thanks! It's not a space allocation issue. However, the journal is not complete and is missing the btrfs messages which were printed when btrfs encountered an error and went read-only.
Also, let's first see

sudo btrfs device stats /dev/sda1

Offline

#5 2025-05-26 09:57:29

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 203
Website

Re: [SOLVED] delete directory on a read-only filesystem

gabx@magnolia ➤➤ ~ % sudo btrfs device stats /dev/sda1
[sudo] password for gabx:
[/dev/sda1].write_io_errs    0
[/dev/sda1].read_io_errs     0
[/dev/sda1].flush_io_errs    0
[/dev/sda1].corruption_errs  0
[/dev/sda1].generation_errs  0

I have been able to umount /backup and mount -rw on /mnt/rescue.

# umount /backup
# mount -rw /dev/sda1 /mnt/rescue/
# rm -r /mnt/rescue/back-home-20240919114809/

rm: cannot remove '/mnt/rescue/back-home-20240919114809/gabx/Pictures/vente_btc.png': Read-only file system
rm: cannot remove '/mnt/rescue/back-home-20240919114809/gabx/Pictures/BTC-SP500_Correlation,_YTD_(90d).png': Read-only file system
etc etc

same issue.

[root@magnolia gabxnew]# journalctl -r
May 26 12:05:46 magnolia kernel: BTRFS info (device sda1): using free-space-tree
May 26 12:05:46 magnolia kernel: BTRFS info (device sda1): using crc32c (crc32c-x86) checksum algorithm
May 26 12:05:46 magnolia kernel: BTRFS info (device sda1): first mount of filesystem dccf798a-53a3-4fe5-aa77-95dc0fd28458
May 26 12:05:46 magnolia kernel: BTRFS: device label backup devid 1 transid 9280 /dev/sda1 (8:1) scanned by mount (15837)
May 26 12:05:39 magnolia systemd[1]: mnt-rescue.mount: Deactivated successfully.
May 26 12:05:39 magnolia kernel: BTRFS info (device sda1): last unmount of filesystem dccf798a-53a3-4fe5-aa77-95dc0fd28458
May 26 12:04:49 magnolia kernel: BTRFS info (device sda1): using free-space-tree
May 26 12:04:49 magnolia kernel: BTRFS info (device sda1): using crc32c (crc32c-x86) checksum algorithm
May 26 12:04:49 magnolia kernel: BTRFS info (device sda1): first mount of filesystem dccf798a-53a3-4fe5-aa77-95dc0fd28458
May 26 12:04:49 magnolia kernel: BTRFS: device label backup devid 1 transid 9279 /dev/sda1 (8:1) scanned by mount (15777)
May 26 12:04:35 magnolia cosmic-comp[1518]: Failed to parse marker-end value: 'none'.
May 26 12:04:35 magnolia cosmic-comp[1518]: Failed to parse marker-mid value: 'none'.
May 26 12:04:35 magnolia cosmic-comp[1518]: Failed to parse marker-start value: 'none'.
May 26 12:03:48 magnolia kernel: BTRFS info (device sda1): last unmount of filesystem dccf798a-53a3-4fe5-aa77-95dc0fd28458
May 26 12:03:48 magnolia systemd[1]: backup.mount: Deactivated successfully.
May 26 12:03:03 magnolia cosmic-comp[1518]: Failed to parse marker-end value: 'none'.
May 26 12:03:03 magnolia cosmic-comp[1518]: Failed to parse marker-mid value: 'none'.
May 26 12:03:03 magnolia cosmic-comp[1518]: Failed to parse marker-start value: 'none'.
May 26 12:03:03 magnolia systemd[1]: systemd-coredump@9-15597-0.service: Consumed 165ms CPU time, 113.9M memory peak.
May 26 12:03:03 magnolia systemd[1]: systemd-coredump@9-15597-0.service: Deactivated successfully.
May 26 12:03:03 magnolia systemd-coredump[15598]: [?] Process 15595 (tokio-runtime-w) of user 1000 dumped core.

Last edited by gabx (2025-05-26 10:09:40)

Offline

#6 2025-05-26 10:05:22

just4arch
Member
Registered: 2023-01-07
Posts: 107

Re: [SOLVED] delete directory on a read-only filesystem

Snapshot / readonly subvol?

btrfs subvolume show /backup

Offline

#7 2025-05-26 14:33:27

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 203
Website

Re: [SOLVED] delete directory on a read-only filesystem

[root@magnolia gabxnew]# btrfs subvolume show /backup
/
	Name: 			<FS_TREE>
	UUID: 			c3766e7c-9b80-4381-b02b-857b22dc988a
	Parent UUID: 		-
	Received UUID: 		-
	Creation time: 		2024-08-31 18:06:38 +0200
	Subvolume ID: 		5
	Generation: 		9282
	Gen at creation: 	0
	Parent ID: 		0
	Top level ID: 		0
	Flags: 			-
	Send transid: 		0
	Send time: 		2024-08-31 18:06:38 +0200
	Receive transid: 	0
	Receive time: 		-
	Snapshot(s):
	Quota group:		n/a

Offline

#8 2025-05-26 15:18:21

just4arch
Member
Registered: 2023-01-07
Posts: 107

Re: [SOLVED] delete directory on a read-only filesystem

You might want to check that for all subvolumes:

btrfs subvolume list /backup

Some subdir might be a subvolume.

Offline

#9 2025-05-26 17:00:13

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 203
Website

Re: [SOLVED] delete directory on a read-only filesystem

[root@magnolia gabxnew]# btrfs subvolume list /backup
ID 256 gen 58 top level 5 path back-development-20240919114809
ID 258 gen 87 top level 5 path back-root-20240919114809
ID 259 gen 114 top level 5 path back-home-20240919114809
[root@magnolia gabxnew]# btrfs subvolume show /backup/back-development-20240919114809/
back-development-20240919114809
	Name: 			back-development-20240919114809
	UUID: 			4e5ccc97-ad2a-3347-8219-01133897f79b
	Parent UUID: 		-
	Received UUID: 		affeaf28-3d3b-a448-8065-2a51bd52c48b
	Creation time: 		2024-09-19 15:59:01 +0200
	Subvolume ID: 		256
	Generation: 		58
	Gen at creation: 	56
	Parent ID: 		5
	Top level ID: 		5
	Flags: 			readonly
	Send transid: 		111077
	Send time: 		2024-09-19 15:59:01 +0200
	Receive transid: 	56
	Receive time: 		2024-09-19 15:59:02 +0200
	Snapshot(s):
	Quota group:		n/a
[root@magnolia gabxnew]# btrfs subvolume show /backup/back-root-20240919114809
back-root-20240919114809
	Name: 			back-root-20240919114809
	UUID: 			f4fe0b48-5c25-8340-8377-c0151794178b
	Parent UUID: 		-
	Received UUID: 		d8497641-1e62-9349-a80b-8b4ad5bd6d19
	Creation time: 		2024-09-19 19:15:46 +0200
	Subvolume ID: 		258
	Generation: 		87
	Gen at creation: 	69
	Parent ID: 		5
	Top level ID: 		5
	Flags: 			readonly
	Send transid: 		112688
	Send time: 		2024-09-19 19:15:46 +0200
	Receive transid: 	84
	Receive time: 		2024-09-19 19:27:27 +0200
	Snapshot(s):
	Quota group:		n/a
[root@magnolia gabxnew]# btrfs subvolume show /backup/back-home-20240919114809
back-home-20240919114809
	Name: 			back-home-20240919114809
	UUID: 			3dcd34ba-bdc3-334f-8204-e7f45560d76e
	Parent UUID: 		-
	Received UUID: 		ee8b895a-8b95-6441-a907-7735959c6dd6
	Creation time: 		2024-09-19 19:49:19 +0200
	Subvolume ID: 		259
	Generation: 		114
	Gen at creation: 	88
	Parent ID: 		5
	Top level ID: 		5
	Flags: 			readonly
	Send transid: 		112688
	Send time: 		2024-09-19 19:49:19 +0200
	Receive transid: 	110
	Receive time: 		2024-09-19 20:08:32 +0200
	Snapshot(s):
	Quota group:		n/a

Yes, the 3 directories are btrfs subvolumes with readonly flags. Well done.

[root@magnolia gabxnew]# btrfs subvol delete /backup/back-home-20240919114809/
Delete subvolume 259 (no-commit): '/backup/back-home-20240919114809'

The above command did the job. Thank you for your help.

Last edited by gabx (2025-05-26 17:03:40)

Offline

#10 2025-05-26 17:13:12

topcat01
Member
Registered: 2019-09-17
Posts: 191

Re: [SOLVED] delete directory on a read-only filesystem

just4arch wrote:

Snapshot / readonly subvol?

btrfs subvolume show /backup

I never thought to check readonly! The good news is that it is all working as intended. As just4arch said, the subvolume is read-only (backups should be). So, you need to use

sudo btrfs subvolume delete snapshot_directory

Offline

Board footer

Powered by FluxBB