opensuse btrfs删除子卷

一开始把一块50G的分区装了系统。后续考虑把home目录单独拉出来放到另一块50G的分区。https://www.cnblogs.com/studywithallofyou/p/16969639.html

按照原来的流程,只不过懒得做启动盘,就在当前系统直接操作了。不过游戏系统挂在了home,所以导致无法移动和删除,于是直接修改fstab,重启。

UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /                       btrfs  defaults                      0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /var                    btrfs  subvol=/@/var                 0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /usr/local              btrfs  subvol=/@/usr/local           0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /tmp                    btrfs  subvol=/@/tmp                 0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /srv                    btrfs  subvol=/@/srv                 0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /root                   btrfs  subvol=/@/root                0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /opt                    btrfs  subvol=/@/opt                 0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /home                   btrfs  subvol=/@/home                0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /boot/grub2/x86_64-efi  btrfs  subvol=/@/boot/grub2/x86_64-efi  0  0
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /boot/grub2/i386-pc     btrfs  subvol=/@/boot/grub2/i386-pc  0  0
UUID=2882-EC2A                             /boot/efi               vfat   utf8                          0  2
UUID=73c0baf1-f315-4bef-a7d1-b8779855ec83  /.snapshots             btrfs  subvol=/@/.snapshots          0  0
UUID=e772594b-cf78-48dc-b24d-c1c84cabe620  swap                    swap   defaults                      0  0

把home那一行修改成

UUID=c51dcae3-f43f-4334-b2c7-f22a6d60a90e  /home                   btrfs  defaults                      0  0

home挂在过去了,但是原来的home数据并没有删除,占用了空间,所以对其进行删除。

由fstab可以发现btrfs的系统多了一列,就是指定子卷。

先查看当前系统的挂在

sudo df -T
文件系统       类型        1K-块     已用     可用 已用% 挂载点devtmpfs       devtmpfs     4096        8     4088    1% /dev
tmpfs          tmpfs     8038040        4  8038036    1% /dev/shm
tmpfs          tmpfs     3215220    10960  3204260    1% /run
tmpfs          tmpfs        4096        0     4096    0% /sys/fs/cgroup
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /.snapshots
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /boot/grub2/i386-pc
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /opt
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /srv
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /boot/grub2/x86_64-efi
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /tmp
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /root
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /usr/local
/dev/nvme0n1p3 btrfs    50331648 22790316 27459684   46% /var
/dev/nvme0n1p6 btrfs    52428800 13515404 38712932   26% /home
/dev/nvme0n1p1 vfat       262144    17956   244188    7% /boot/efi
tmpfs          tmpfs     1607608       76  1607532    1% /run/user/1000

然后把对应分区/dev/nvme0n1p6的home分卷挂在到一个目录

sudo mount /dev/nvme0n1p3 -o subvol=@/home /mnt/olddata

查看一下,/mnt/olddata目录下就是原来home的数据。

查看一下分卷信息

sudo btrfs subvolume list /mnt/olddata  
ID 256 gen 32 top level 5 path @
ID 257 gen 925 top level 256 path @/var
ID 258 gen 847 top level 256 path @/usr/local
ID 259 gen 917 top level 256 path @/tmp
ID 260 gen 847 top level 256 path @/srv
ID 261 gen 901 top level 256 path @/root
ID 262 gen 676 top level 256 path @/opt
ID 263 gen 922 top level 256 path @/home
ID 264 gen 847 top level 256 path @/boot/grub2/x86_64-efi
ID 265 gen 847 top level 256 path @/boot/grub2/i386-pc
ID 266 gen 892 top level 256 path @/.snapshots
ID 267 gen 920 top level 266 path @/.snapshots/1/snapshot
ID 275 gen 53 top level 266 path @/.snapshots/2/snapshot
ID 431 gen 775 top level 266 path @/.snapshots/140/snapshot
ID 433 gen 777 top level 266 path @/.snapshots/141/snapshot
ID 434 gen 789 top level 266 path @/.snapshots/142/snapshot
ID 435 gen 790 top level 266 path @/.snapshots/143/snapshot
ID 436 gen 855 top level 266 path @/.snapshots/144/snapshot
ID 437 gen 856 top level 266 path @/.snapshots/145/snapshot
ID 438 gen 863 top level 266 path @/.snapshots/146/snapshot
ID 439 gen 865 top level 266 path @/.snapshots/147/snapshot
ID 440 gen 871 top level 266 path @/.snapshots/148/snapshot
ID 441 gen 873 top level 266 path @/.snapshots/149/snapshot

不管是指定/mnt/olddata 还是/,只要是同一分区下的目录,都会把当前子卷信息列出来

运行如下命令删除子卷

sudo btrfs subvolume delete --subvolid 263 /mnt/olddata
Delete subvolume (no-commit): '/mnt/olddata/@/home'

可以看到是no-commit,因为这时还没提交,具体什么时候提交,不太清楚,可以重启系统让其生效。也可以增加-c参数直接提交。

sudo btrfs subvolume delete -c --subvolid 263 /mnt/olddata

https://btrfs.readthedocs.io/en/latest/btrfs-subvolume.html
https://documentation.suse.com/zh-cn/sles/15-SP3/html/SLES-all/cha-filesystems.html

posted @ 2023-06-10 11:25  秋来叶黄  阅读(364)  评论(0编辑  收藏  举报