无法删除btrfs快照


8

我无法删除btrfs快照“ apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26”。详细信息如下:

root@cioco:~# btrfs subvolume list -s /
ID 261 gen 246 cgen 245 top level 5 otime 2013-10-19 00:52:26 path @apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
root@cioco:~# btrfs subvolume list  /
ID 256 gen 334584 top level 5 path @
ID 258 gen 334134 top level 5 path @home
ID 261 gen 246 top level 5 path @apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
ID 267 gen 334580 top level 256 path var/lib/lxc/mythtv/rootfs
ID 268 gen 334584 top level 256 path var/lib/lxc/jira/rootfs
ID 278 gen 279278 top level 256 path var/lib/lxc/michele/rootfs
root@cioco:~# grep btrfs /proc/self/mountinfo
20 1 0:16 /@ / rw,relatime - btrfs /dev/sda2 rw,compress=zlib,space_cache
39 20 0:16 /@home /home rw,relatime - btrfs /dev/sda2 rw,compress=zlib,space_cache

root@cioco:~# btrfs subvolume delete /@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
ERROR: error accessing '/@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26' 

但是,我可以删除由我创建的快照:

root@cioco:~# btrfs subvolume snapshot / root-snap
Create a snapshot of '/' in './root-snap'
root@cioco:~# btrfs subvolume list -s /
ID 261 gen 246 cgen 245 top level 5 otime 2013-10-19 00:52:26 path @apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
ID 309 gen 334592 cgen 334592 top level 256 otime 2014-03-31 02:19:08 path root/root-snap
root@cioco:~# btrfs subvolume delete /root/root-snap
Delete subvolume '/root/root-snap'

EDIT1:内核日志中未记录任何内容:

root@cioco:~# dmesg -c >/dev/null
root@cioco:~# btrfs subvolume delete /@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
ERROR: error accessing '/@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26'
root@cioco:~# dmesg
root@cioco:~#

但是strace给出了一个提示:

root@cioco:~# strace btrfs subvolume delete /@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
...
stat("/@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26", 0x7fffe88ebb60) = -1 ENOENT (No such file or directory)
write(2, "ERROR: error accessing '/@apt-sn"..., 82ERROR: error accessing '/@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26'
) = 82

Edit2:我已经安装了该卷...

root@cioco:~# mkdir /snapshot
root@cioco:~# mount /dev/sda2 /snapshot -o subvol=/@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
root@cioco:~# grep btrfs /proc/self/mountinfo
20 1 0:16 /@ / rw,relatime - btrfs /dev/sda2 rw,compress=zlib,space_cache
39 20 0:16 /@home /home rw,relatime - btrfs /dev/sda2 rw,compress=zlib,space_cache
61 20 0:16 /@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26 /snapshot rw,relatime - btrfs /dev/sda2 rw,compress=zlib,space_cache
root@cioco:~# btrfs subvolume delete /snapshot/
Delete subvolume '//snapshot'
ERROR: cannot delete '//snapshot' - Invalid argument

root@cioco:~# strace btrfs subvolume delete /snapshot/
...
stat("/snapshot", {st_mode=S_IFDIR|0755, st_size=230, ...}) = 0
brk(0)                                  = 0x2206000
brk(0x2228000)                          = 0x2228000
lstat("/snapshot", {st_mode=S_IFDIR|0755, st_size=230, ...}) = 0
stat("/", {st_mode=S_IFDIR|0755, st_size=242, ...}) = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 23), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd8ad2ae000
write(1, "Delete subvolume '//snapshot'\n", 30Delete subvolume '//snapshot'
) = 30
ioctl(3, BTRFS_IOC_SNAP_DESTROY, 0x7fff5f1e5878) = -1 EINVAL (Invalid argument)
close(3)                                = 0
write(2, "ERROR: cannot delete '//snapshot"..., 53ERROR: cannot delete '//snapshot' - Invalid argument
) = 53
...

root@cioco:~# dmesg
[3172764.459166] device label cioco-root devid 1 transid 336213 /dev/sda2

Edit3:解决方案

root@cioco:~# mount /dev/sda2 /btrfs-root/
root@cioco:~# ls -l /btrfs-root/
total 0
drwxr-xr-x 1 root root 262 Apr  1 08:31 @
drwxr-xr-x 1 root root 230 Oct 16 22:53 @apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26
drwxr-xr-x 1 root root   6 Oct 16 22:13 @home
root@cioco:~# btrfs subvolume delete /btrfs-root/@apt-snapshot-release-upgrade-saucy-2013-10-19_00\:52\:26/
Delete subvolume '/btrfs-root/@apt-snapshot-release-upgrade-saucy-2013-10-19_00:52:26'
root@cioco:~# dmesg
[41113.537617] device label cioco-root devid 1 transid 337615 /dev/sda2

任何帮助,将不胜感激。


您可以将其从实时会话中删除吗?也许它还在使用中。grepping /proc/self/mountinfo是不够的,例如,它可以用作绑定安装,或者是否已使用umount -l(懒惰卸载)卸载,并且我不知道是否还有其他情况。
ignis 2014年

根本没有安装。该系统是我的家庭服务器。而且我认为快照是在Ubuntu升级后拍摄的。我的Ubuntu 13.10 64位,现在运行
米尔恰Vutcovici

“实时会话”是什么意思?
Mircea Vutcovici 2014年

我的意思是Live DVD或Live USB。
ignis

请张贴的输出dmesg | tail,经过btrfs subvolume delete失败。
ignis

Answers:


15

快照存在于文件系统的实际根目录中,而不是您在/中挂载的目录。您在/中挂载了/ @子卷,因此没有具有该名称的此类文件。您必须将真实的根卷安装在某处,并使用该路径引用快照。

或者您也可以使用apt-btrfs-snapshot delete


2
过去我在安装和删除文件时遇到了很多问题,但运行apt-btrfs-snapshot delete
起来

与常规btrfs快照管理不同,apt-btrfs-snapshot将从运行中的系统而不是已安装的分区中运行。
mchid

3
@mchid,什么?常规btrfs快照管理是从正在运行的系统中运行的... apt-btrfs-snapshot只是一个apt脚本,只要您具有apt安装/升级/删除软件包,它就可以自动运行常规btrfs快照。
psusi '16

我的问题是,由于快照的原因,我的磁盘已满,因此无法安装apt-btrfs-snapshot
fccoelho

空间不足时,必须从USB引导以删除内容。另外,如果将卷安装到/ mnt,我想您可以从正在运行的系统中删除。
mchid '19
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.