Skip to content

Instantly share code, notes, and snippets.

@wcxaaa
Created June 5, 2022 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wcxaaa/cd58c8a57827469f79b4a0d5d60e7ba5 to your computer and use it in GitHub Desktop.
Save wcxaaa/cd58c8a57827469f79b4a0d5d60e7ba5 to your computer and use it in GitHub Desktop.
btrfs 子卷系统迁移清单

准备

要准备一个目标系统,或者至少要live cd

开始迁移 进chroot

  • 执行btrfs send 和 btrfs rec
  • 挂子卷,挂efi
  • /etc/fstab (删subvolid,改uuid, 加swap space)
  • /etc底下:hostname hosts resolv.conf
  • 挂子卷
    for i in /dev /dev/pts /proc /sys /run; do mount -B $i /mnt/LINUXNAME$i; done
  • chroot进去
    • Arch Linux直接用arch-chroot, Manjaro用manjaro-chroot
  • 换machine-id
    rm /etc/machine-id
    dbus-uuidgen >| /etc/machine-id
    注:不推荐systemd-machine-id-setup因为有些发行版会生成相同的machine-id,比如Ubuntu

修引导 - systemd-boot版

popOS

  • 修改/etc/kernelstub/configuration,在user小节的数组里加入:rootflags=subvol=@popOS-root
  • 执行
    apt install --reinstall linux-generic linux-headers-generic
    update-initramfs -c -k all
    bootctl --path=/mnt/popOS/boot/efi install

其他Linux. 以ArchLinux为例

  • 添加引导记录
bootctl --path=/boot/efi install
  • 重构启动镜像

    • ArchLinux
    mkinitcpio -p linux
    • Fedora
    dracut --regenerate-all --force
  • 将位于/boot下的文件拷贝到EFI分区。例如/EFI/arch/。这些文件包括

    • vmlinuz-linux(-lts,bla-bla-bla)
    • initramfs-linux(-lts,bla-bla-bla).img
    • 如果有microcode,也需要拷贝。
  • 修改/boot/efi/loader/entries/xxx.conf.

    • linux小节指定vmlinuz的路径(例如:/EFI/arch/vmlinuz-linux
    • initrd一节指定initramfs的路径(例如:/EFI/arch/initramfs-linux-lts.img
    • 如果有microcode,需要再加个initramfs到第一行并且指定相应路径
    • options小节为
      options root=UUID=[btrfs分区的UUID] rootflags=subvol=[子卷名称] rw
  • 运行bootctl list,确保没有错误

  • Refs:

修引导 - GRUB版

  • ubuntu debian: 可以直接重装:
apt install --reinstall grub-efi-amd64
  • Deepin 20: 按照底下一般linux来,但除了bootloader-id=deepin外还要再运行bootloader-id=UOS、ubuntu和boot,一共运行4次

  • Fedora 27 - 32, CentOS 7

    • 重新安装grub2-efi-modules
    • 重构启动镜像。见“其他Linux. 以ArchLinux为例”小节
  • 一般linux

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=[linux名字]
grub-mkconfig -o /boot/grub/grub.cfg

安装 intel-ucode / amd-ucode

  • 按照发行版说明进行安装。有些发行版已经自带。
  • (systemd-boot) entries 最前面一行initrd指定microcode的路径
  • (GRUB) 再运行一次grub-mkconfig

安装 nvdia/amd driver (独显) ==或== xorg(集显、虚拟机)

  • Fedora: dnf groupinstall base-x
  • hyperV 补装 xf86-video-fbdev (Arch Linux)

安装喜欢的桌面

按照发行版的文档安装自己喜欢的桌面

如果有用户存在但是家被炸了,需要重新修家

cp -r /etc/skel/* /home/myuser123
chmod -R 755 /home/myuser123 && chown -R myuser123:myuser123 /home/myuser123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment