0

In doing some testing with BTRFS I created some read-only snapshots using a timestamp for the name (i.e. including special characters). Now I can't remove them.

$ sudo btrfs subvolume list /test
...
ID 387 gen 289 top level 5 path snapshots/2022-08-22 20:41:00
ID 388 gen 293 top level 5 path snapshots/2022-08-23 07:55:00
...

Trying to remove one:

$ btrfs subvolume snapshot delete /test/snapshots/'2022-08-23 07:55:00'
ERROR: Could not statfs: No such file or directory

Note I can get the stats for this file, and the snapshot is completely functional:

$ stat /test/snapshots/'2022-08-23 07:55:00'
  File: /test/snapshots/2022-08-23 07:55:00
  Size: 50          Blocks: 0          IO Block: 4096   directory
Device: 51h/81d Inode: 256         Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/     que)   Gid: ( 1000/     que)
Access: 2022-08-23 00:00:04.349592125 -0500
Modify: 2022-08-23 00:00:02.257592094 -0500
Change: 2022-08-23 00:00:02.257592094 -0500
 Birth: 2022-08-16 12:14:14.154459488 -0500

I've tried various combinations to escape the file name, but nothing seems to work. I see there is an ID listed, but it doesn't seem I can remove a snapshot by id. Any ideas on how to remove snapshots with special characters in the snapshot name?

2
  • Your list command doesn't show the snapshot you're trying to remove. but I suspect that is just a poor choice of lines to show in that output? Aug 23, 2022 at 15:43
  • @Henriksupportsthecommunity My mistake. It has been corrected.
    – A. Que
    Aug 23, 2022 at 15:57

1 Answer 1

1

The issue has nothing to do with characters (special or not). This is the command that failed:

btrfs subvolume snapshot delete /test/snapshots/'2022-08-23 07:55:00'

btrfs subvolume snapshot … creates a snapshot. The subcommand is snapshot. delete is not a subcommand here, it's an operand to snapshot.

Your command tried to create a snapshot from delete. It's a shame No such file or directory is vague in this case. It would be better if this error was verbose and told you it meant "file or directory" named delete; this would give you a hint that delete was interpreted as a pathname, not a subcommand. Oh well.

The right syntax to remove what you wanted to remove is:

btrfs subvolume delete /test/snapshots/'2022-08-23 07:55:00'

where delete is placed where you had snapshot. delete is a subcommand now.

2
  • My mistake is clear now albeit rather embarrassing. I must keep in mind that a snapshot is a subvolume.
    – A. Que
    Aug 23, 2022 at 17:21
  • @A.Que Not so embarrassing, regarding the fact the error message failed to be helpful. Aug 23, 2022 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .