BTRFS 安装陷入 Snapper 回滚

BTRFS 安装陷入 Snapper 回滚

我在 openSUSE 中使用 snapper。

出于学习目的,我这样做了% snapper rollback。这更像是出于对鲷鱼的好奇原因,但却变成了一个错误。

之后% snapper rollback,我的% snapper list就变得空了。看起来根文件系统已安装到快照卷,如下面的命令所示。

% sudo snapper list
Type   | # | Pre # | Date | User | Cleanup | Description | Userdata
-------+---+-------+------+------+---------+-------------+---------
single | 0 |       |      | root |         | current     |     

% sudo snapper rollback
IO error (.snapshots is not a btrfs subvolume).

% mount | grep '/dev/sda8 on / type'
/dev/sda8 on / type btrfs (rw,relatime,space_cache,subvolid=400,subvol=/@/.snapshots/75/snapshot)

如何在不改变的情况下解决问题/etc/fstab

如何撤消回滚到正常文件系统?

如何正确使用回滚?

答案1

  1. 首先我需要添加这一行/etc/fstab

    % sudo nano /etc/fstab
    UUID=e901452a-b3ea-48d2-acdb-6687fad0be50 /.snapshots btrfs subvol=@/.snapshots   0 0
    

    并安装它,无需重新启动。

    % sudo mount /.snapshots
    
  2. 获取当前快照

    就我而言,之前我的快照编号为 75。

    % sudo btrfs subvolume show /
    
    @/.snapshots/45/snapshot
        Name:           snapshot
        UUID:           29d4436b-72d1-f14d-a9e9-f04b70c0ebe0
        Parent UUID:        efa9f21b-f3b7-3543-9649-3897e083b39d
        Received UUID:      -
        Creation time:      2018-01-03 00:15:01 +0700
        Subvolume ID:       355
        Generation:         5677
        Gen at creation:    3968
        Parent ID:      301
        Top level ID:       301
        Flags:          -
        Snapshot(s):
                    @/.snapshots/50/snapshot
                    @/.snapshots/51/snapshot
    

    % sudo btrfs subvolume get-default /
    
    ID 355 gen 5682 top level 301 path @/.snapshots/45/snapshot 
    
  3. 列出快照程序 % sudo 快照程序列表

    Type   | #  | Pre # | Date                            | User | Cleanup  | Description  | Userdata     
    -------+----+-------+---------------------------------+------+----------+--------------+--------------
    single | 0  |       |                                 | root |          | current      |              
    single | 3  |       | Mon 01 Jan 2018 02:45:03 PM WIB | root | timeline | timeline     |              
    single | 7  |       | Mon 01 Jan 2018 04:30:01 PM WIB | root | timeline | timeline     |              
    single | 40 |       | Tue 02 Jan 2018 10:15:01 PM WIB | root | timeline | timeline     |              
    single | 41 |       | Tue 02 Jan 2018 10:52:35 PM WIB | root |          | backup.epsi  |              
    pre    | 42 |       | Tue 02 Jan 2018 11:01:48 PM WIB | root | number   | zypp(zypper) | important=yes
    post   | 43 | 42    | Tue 02 Jan 2018 11:07:23 PM WIB | root | number   |              | important=yes
    single | 44 |       | Tue 02 Jan 2018 11:15:01 PM WIB | root | timeline | timeline     |              
    single | 45 |       | Wed 03 Jan 2018 12:15:01 AM WIB | root | timeline | timeline     |              
    pre    | 46 |       | Wed 03 Jan 2018 12:16:34 AM WIB | root | number   | zypp(zypper) | important=no 
    post   | 47 | 46    | Wed 03 Jan 2018 12:19:38 AM WIB | root | number   |              | important=no 
    pre    | 48 |       | Wed 03 Jan 2018 12:47:47 AM WIB | root | number   | zypp(zypper) | important=no 
    post   | 49 | 48    | Wed 03 Jan 2018 12:48:10 AM WIB | root | number   |              | important=no 
    ...
    

    我决定回到45岁。

  4. BTRFS ID

    % sudo btrfs subvolume list -a /
    
    ID 257 gen 4804 top level 5 path <FS_TREE>/@
    ID 258 gen 5096 top level 257 path <FS_TREE>/@/opt
    ID 259 gen 4157 top level 257 path <FS_TREE>/@/srv
    ID 260 gen 5672 top level 257 path <FS_TREE>/@/tmp
    ID 261 gen 5538 top level 257 path <FS_TREE>/@/usr/local
    ID 262 gen 5688 top level 257 path <FS_TREE>/@/var/cache
    ID 263 gen 4157 top level 257 path <FS_TREE>/@/var/crash
    ID 264 gen 4157 top level 257 path <FS_TREE>/@/var/lib/libvirt/images
    ID 265 gen 4157 top level 257 path <FS_TREE>/@/var/lib/machines
    ID 266 gen 4157 top level 257 path <FS_TREE>/@/var/lib/mailman
    ID 267 gen 4157 top level 257 path <FS_TREE>/@/var/lib/mariadb
    ID 268 gen 4157 top level 257 path <FS_TREE>/@/var/lib/mysql
    ID 269 gen 4157 top level 257 path <FS_TREE>/@/var/lib/named
    ID 270 gen 4157 top level 257 path <FS_TREE>/@/var/lib/pgsql
    ID 271 gen 5688 top level 257 path <FS_TREE>/@/var/log
    ID 272 gen 4157 top level 257 path <FS_TREE>/@/var/opt
    ID 273 gen 5688 top level 257 path <FS_TREE>/@/var/spool
    ID 274 gen 5672 top level 257 path <FS_TREE>/@/var/tmp
    ID 301 gen 5674 top level 257 path <FS_TREE>/@/.snapshots
    ID 304 gen 3008 top level 301 path <FS_TREE>/@/.snapshots/3/snapshot
    ID 311 gen 3160 top level 301 path <FS_TREE>/@/.snapshots/7/snapshot
    ID 345 gen 3737 top level 301 path <FS_TREE>/@/.snapshots/40/snapshot
    ID 350 gen 3849 top level 301 path <FS_TREE>/@/.snapshots/41/snapshot
    ID 351 gen 3862 top level 301 path <FS_TREE>/@/.snapshots/42/snapshot
    ID 353 gen 3874 top level 301 path <FS_TREE>/@/.snapshots/43/snapshot
    ID 354 gen 3887 top level 301 path <FS_TREE>/@/.snapshots/44/snapshot
    ID 355 gen 5688 top level 301 path <FS_TREE>/@/.snapshots/45/snapshot
    ID 356 gen 3972 top level 301 path <FS_TREE>/@/.snapshots/46/snapshot
    ID 357 gen 3980 top level 301 path <FS_TREE>/@/.snapshots/47/snapshot
    ID 358 gen 4021 top level 301 path <FS_TREE>/@/.snapshots/48/snapshot
    ID 359 gen 4022 top level 301 path <FS_TREE>/@/.snapshots/49/snapshot
    

    我查到ID是45,是355。

  5. 更改默认值

    使其可写

    % sudo btrfs property set -ts /.snapshots/45/snapshot ro false
    

    并设为默认

    % sudo btrfs subvolume set-default 355 /
    

    然后重新启动

  6. 删除烦人的回滚快照。

    % sudo snapper delete 75
    
    % sudo snapper delete 76
    
    % sudo snapper delete 77
    
    % sudo snapper list
    

就这样

谢谢

相关内容