opensuse-microos-delete-snapshots

概述

不可变操作系统opensuse microos,解决删除历史快照

  • 回滚
    MicroOS是个不可变的操作系统,可轻松回滚不可变,磁盘上不会有更改可重启,到旧的 BTRFS 快照来回滚

env

  • opensuse-microos

delete snapshot(delete disk snapshots in SUSE)

#btrfs snapshot
/.snapshots/x/snapshot

//List available available snapper configs
gaga-90:~ # snapper list-configs
Config | Subvolume
-------+----------
root   | / 

//List available available snapper configs
gaga-90:~ # snapper --config root list
 # | Type   | Pre # | Date                     | User | Used Space | Cleanup | Description           | Userdata
---+--------+-------+--------------------------+------+------------+---------+-----------------------+---------
0  | single |       |                          | root |            |         | current               |         
8* | single |       | Fri Dec  2 21:30:19 2022 | root | 730.67 MiB |         | Snapshot Update of #7 |            //current from snapshot

//Delete snapshot based on snapshot number
snapper --config root delete 2
snapper --config root delete 1-10   //delete number 1..10

gaga-90:~ # snapper --config root delete 8
Cannot delete snapshot 8 since it is the currently mounted snapshot.   //不可变
gaga-90:~ # snapper --config root delete 0
Cannot delete snapshot 0 since it is the current system.  //挂载可写层

force snapper

问题

gaga-90:~ # transactional-update status
transactional-update 4.1.0 started
Options: status
Separate /var detected.
--------------------------------------------------------------------------------------------------------------------
Snapshot:          8* [2022-12-02 13:30:19]
Description:       Snapshot Update of #7
(Missing status file)
--------------------------------------------------------------------------------------------------------------------
grep: /.snapshots/3/info.xml: No such file or directory   //由于人工删除过目录导致异常,必须强制删除
/sbin/transactional-update: line 720: [: : integer expression expected
/sbin/transactional-update: line 722: [: : integer expression expected
grep: /.snapshots/3/info.xml: No such file or directory
grep: /.snapshots/3/info.xml: No such file or directory
grep: /.snapshots/3/info.xml: No such file or directory
Snapshot:           []
grep: /.snapshots/3/info.xml: No such file or directory
Description:       
(Missing status file)
--------------------------------------------------------------------------------------------------------------------
grep: /.snapshots/2/info.xml: No such file or directory
/sbin/transactional-update: line 720: [: : integer expression expected
/sbin/transactional-update: line 722: [: : integer expression expected
grep: /.snapshots/2/info.xml: No such file or directory
grep: /.snapshots/2/info.xml: No such file or directory
grep: /.snapshots/2/info.xml: No such file or directory
Snapshot:           []
grep: /.snapshots/2/info.xml: No such file or directory
Description:       
(Missing status file)

解决

transactional-update status

btrfs subvolume delete /.snapshots/SNAPSHOTNUMBER/snapshot
rm -rf /.snapshots/SNAPSHOTNUMBER

btrfs

gaga-90:~ # btrfs --help
usage: btrfs [--help] [--version] [--format <format>] [-v|--verbose] [-q|--quiet] <group> [<group>...] <command> [<args>]

    btrfs balance start [options] <path>
        Balance chunks across the devices
    btrfs balance pause <path>
        Pause running balance
    btrfs balance cancel <path>
        Cancel running or paused balance
    btrfs balance resume <path>
        Resume interrupted balance
    btrfs balance status [-v] <path>
        Show status of running or paused balance

    btrfs check [options] <device>
        Check structural integrity of a filesystem (unmounted).

    btrfs device add [options] <device> [<device>...] <path>
        Add one or more devices to a mounted filesystem.
    btrfs device delete <device>|<devid> [<device>|<devid>...] <path>
    btrfs device remove <device>|<devid> [<device>|<devid>...] <path>
        Remove a device from a filesystem
    btrfs device replace <command> [...]
    	Replace a device (alias of "btrfs replace")
    btrfs device scan [-d|--all-devices] <device> [<device>...]
    btrfs device scan -u|--forget [<device>...]
        Scan or forget (unregister) devices of btrfs filesystems
    btrfs device ready <device>
        Check and wait until a group of devices of a filesystem is ready for mount
    btrfs device stats [options] <path>|<device>
        Show device IO error statistics
    btrfs device usage [options] <path> [<path>..]
        Show detailed information about internal allocations in devices.

    btrfs filesystem df [options] <path>
        Show space usage information for a mount point
    btrfs filesystem du [options] <path> [<path>..]
        Summarize disk usage of each file.
    btrfs filesystem show [options] [<path>|<uuid>|<device>|label]
        Show the structure of a filesystem
    btrfs filesystem sync <path>
        Force a sync on a filesystem
    btrfs filesystem defragment [options] <file>|<dir> [<file>|<dir>...]
        Defragment a file or a directory
    btrfs filesystem resize [options] [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>
        Resize a filesystem
    btrfs filesystem label [<device>|<mount_point>] [<newlabel>]
        Get or change the label of a filesystem
    btrfs filesystem usage [options] <path> [<path>..]
        Show detailed information about internal filesystem usage .

    btrfs inspect-internal inode-resolve [-v] <inode> <path>
        Get file system paths for the given inode
    btrfs inspect-internal logical-resolve [-Pvo] [-s bufsize] <logical> <path>
        Get file system paths for the given logical address
    btrfs inspect-internal subvolid-resolve <subvolid> <path>
        Get file system paths for the given subvolume ID.
    btrfs inspect-internal rootid <path>
        Get tree ID of the containing subvolume of path.
    btrfs inspect-internal min-dev-size [options] <path>
        Get the minimum size the device can be shrunk to
    btrfs inspect-internal dump-tree [options] <device> [<device> ..]
        Dump tree structures from a given device
    btrfs inspect-internal dump-super [options] device [device...]
        Dump superblock from a device in a textual form
    btrfs inspect-internal tree-stats [options] <device>
        Print various stats for trees

    btrfs property get [-t <type>] <object> [<name>]
        Get a property value of a btrfs object
    btrfs property set [-f] [-t <type>] <object> <name> <value>
        Set a property on a btrfs object
    btrfs property list [-t <type>] <object>
        Lists available properties with their descriptions for the given object

    btrfs qgroup assign [options] <src> <dst> <path>
        Assign SRC as the child qgroup of DST
    btrfs qgroup remove [options] <src> <dst> <path>
        Remove a child qgroup SRC from DST.
    btrfs qgroup create <qgroupid> <path>
        Create a subvolume quota group.
    btrfs qgroup destroy <qgroupid> <path>
        Destroy a quota group.
    btrfs qgroup show [options] <path>
        Show subvolume quota groups.
    btrfs qgroup limit [options] <size>|none [<qgroupid>] <path>
        Set the limits a subvolume quota group.

    btrfs quota enable <path>
        Enable subvolume quota support for a filesystem.
    btrfs quota disable <path>
        Disable subvolume quota support for a filesystem.
    btrfs quota rescan [-sw] <path>
        Trash all qgroup numbers and scan the metadata again with the current config.

    btrfs receive [options] <mount>
    btrfs receive --dump [options]
        Receive subvolumes from a stream

    btrfs replace start [-Bfr] <srcdev>|<devid> <targetdev> <mount_point>
        Replace device of a btrfs filesystem.
    btrfs replace status [-1] <mount_point>
        Print status and progress information of a running device replace operation
    btrfs replace cancel <mount_point>
        Cancel a running device replace operation.

    btrfs rescue chunk-recover [options] <device>
        Recover the chunk tree by scanning the devices one by one.
    btrfs rescue super-recover [options] <device>
        Recover bad superblocks from good copies
    btrfs rescue zero-log <device>
        Clear the tree log. Usable if it's corrupted and prevents mount.
    btrfs rescue fix-device-size <device>
        Re-align device and super block sizes. Usable if newer kernel refuse to mount it due to mismatch super size
    btrfs rescue create-control-device
        Create /dev/btrfs-control (see 'CONTROL DEVICE' in btrfs(5))
    btrfs rescue clear-uuid-tree
        Delete uuid tree so that kernel can rebuild it at mount time

    btrfs restore [options] <device> <path>
    btrfs restore [options] -l <device>
        Try to restore files from a damaged filesystem (unmounted)

    btrfs scrub start [-BdqrRf] [-c ioprio_class -n ioprio_classdata] <path>|<device>
        Start a new scrub. If a scrub is already running, the new one fails.
    btrfs scrub cancel <path>|<device>
        Cancel a running scrub
    btrfs scrub resume [-BdqrR] [-c ioprio_class -n ioprio_classdata] <path>|<device>
        Resume previously canceled or interrupted scrub
    btrfs scrub status [-dR] <path>|<device>
        Show status of running or finished scrub

    btrfs send [-ve] [-p <parent>] [-c <clone-src>] [-f <outfile>] <subvol> [<subvol>...]
        Send the subvolume(s) to stdout.

    btrfs subvolume create [-i <qgroupid>] [<dest>/]<name>
        Create a subvolume
    btrfs subvolume delete [options] <subvolume> [<subvolume>...]
    btrfs subvolume delete [options] -i|--subvolid <subvolid> <path>  //删除subvolume
        Delete subvolume(s)
    btrfs subvolume list [options] <path>
        List subvolumes and snapshots in the filesystem.
    btrfs subvolume snapshot [-r] [-i <qgroupid>] <subvolume> { <subdir>/<name> | <subdir> }
        
    btrfs subvolume get-default <path>
        Get the default subvolume of a filesystem
    btrfs subvolume set-default <subvolume>
    btrfs subvolume set-default <subvolid> <path>
        Set the default subvolume of the filesystem mounted as default.
    btrfs subvolume find-new <path> <lastgen>
        List the recently modified files in a filesystem
    btrfs subvolume show [options] <path>
        Show more information about the subvolume (UUIDs, generations, times, snapshots)
    btrfs subvolume sync <path> [<subvol-id>...]
        Wait until given subvolume(s) are completely removed from the filesystem.

    btrfs help [--full] [--box]
        Display help information
    btrfs version
        Display btrfs-progs version

Use --help as an argument for information on a specific group or command.
Options for --format are: text, json
gaga-90:~ #
posted @ 2023-03-06 12:25  mvpbang  阅读(76)  评论(0编辑  收藏  举报