Linux LVM-based Multiple Disks System/Data Migration

What I Have

  1. Current Setup

    • Disk /dev/nvme0n1:
      • Partition 1 (/dev/nvme0n1p1): EFI System, mounted as /boot/efi.
      • Partition 2 (/dev/nvme0n1p2): Linux FileSystem, mounted as /boot.
      • Partition 3 (/dev/nvme0n1p3): LVM, part of ubuntu-vg Volume Group, mounted as /.
    • Disk /dev/nvme2n1:
      • Entire disk is an LVM Physical Volume, also part of ubuntu-vg.

    Output of sudo pvs:

    PV             VG        Fmt  Attr PSize    PFree
    /dev/nvme0n1p3 ubuntu-vg lvm2 a--  <473.89g    0
    /dev/nvme2n1   ubuntu-vg lvm2 a--  <476.94g    0
    
  2. New Disk /dev/nvme1n1:
    • Empty, unformatted disk.
    • To be partitioned and used to replace /dev/nvme0n1 and /dev/nvme2n1.

What I Want

  1. Disk /dev/nvme1n1 Setup:
    • Partition 1 (/dev/nvme1n1p1): EFI System, 1 GiB, formatted as vfat, mounted as /boot/efi.
    • Partition 2 (/dev/nvme1n1p2): Linux FileSystem, 2 GiB, formatted as ext4, mounted as /boot.
    • Partition 3 (/dev/nvme1n1p3): LVM, occupies the remaining space, part of ubuntu-vg, mounted as /.
  2. Complete Migration:
    • All data (including /boot, /boot/efi, and /) migrated to /dev/nvme1n1.
    • GRUB configured to boot from /dev/nvme1n1.
    • /dev/nvme0n1 and /dev/nvme2n1 removed after migration.

What I Do

Step 1: Partition the New Disk

  1. Launch fdisk to partition /dev/nvme1n1:
    sudo fdisk /dev/nvme1n1
    
  2. Create partitions:
    • Partition 1:
      • Size: 1 GiB.
      • Type: EFI System (t, code 1).
    • Partition 2:
      • Size: 2 GiB.
      • Type: Linux FileSystem.
    • Partition 3:
      • Size: Remaining space.
      • Type: Linux LVM (t, code 8e).
  3. Save and exit fdisk (w).
  4. Format the partitions:
    sudo mkfs.vfat -F32 /dev/nvme1n1p1
    sudo mkfs.ext4 /dev/nvme1n1p2
    sudo pvcreate /dev/nvme1n1p3
    
  5. Add /dev/nvme1n1p3 to the volume group:
    sudo vgextend ubuntu-vg /dev/nvme1n1p3
    

Step 2: Migrate LVM Data

  1. Move LVM data from old disks to the new disk:
    sudo pvmove /dev/nvme0n1p3 /dev/nvme1n1p3
    sudo pvmove /dev/nvme2n1 /dev/nvme1n1p3
    
  2. Remove old Physical Volumes:
    sudo vgreduce ubuntu-vg /dev/nvme0n1p3
    sudo vgreduce ubuntu-vg /dev/nvme2n1
    sudo pvremove /dev/nvme0n1p3
    sudo pvremove /dev/nvme2n1
    

Step 3: Migrate Boot Data

  1. Mount new partitions
    sudo mount /dev/nvme1n1p2 /mnt/target_p2
    sudo mkdir -p /mnt/target_p2/boot/efi
    sudo mount /dev/nvme1n1p1 /mnt/target_p2/boot/efi
    
  2. Copy data from old /boot and /boot/efi:
    sudo rsync -avh /boot/ /mnt/target_p2/
    sudo rsync -avh /boot/efi/ /mnt/target_p2/boot/efi/
    

Step 4: Update /etc/fstab

  1. Mount the new root Logical Volume:
    sudo mount /dev/mapper/ubuntu--vg-root /mnt/target_root
    
  2. Bind /boot and /boot/efi to the new root:
    sudo mount --bind /mnt/target_p2 /mnt/target_root/boot
    sudo mount --bind /mnt/target_p2/boot/efi /mnt/target_root/boot/efi
    
  3. Edit /mnt/target_root/etc/fstab:
    • Update UUIDs for /boot/efi, /boot, and / using blkid:
      sudo blkid
      
      Example /etc/fstab:
      UUID=<new-efi-uuid> /boot/efi vfat defaults 0 1
      UUID=<new-boot-uuid> /boot ext4 defaults 0 2
      

Step 5: Install GRUB

  1. Enter a chroot environment:
    sudo mount --bind /dev /mnt/target_root/dev
    sudo mount --bind /proc /mnt/target_root/proc
    sudo mount --bind /sys /mnt/target_root/sys
    sudo mount --bind /sys/firmware/efi/efivars /mnt/target_root/sys/firmware/efi/efivars
    sudo chroot /mnt/target_root
    
  2. Install GRUB:
    grub-install
    update-grub
    
  3. Exit chroot:
    exit
    

Step 6: Verify and Test

  1. Set /dev/nvme1n1 as the boot device in your BIOS/UEFI settings.
  2. Remove /dev/nvme0n1 and /dev/nvme2n1 from the machine.
  3. Boot into the system and verify:
    lsblk
    cat /etc/fstab
    df -h
    

Step 7: Resize the New Volume

  1. Extend the LV:
    sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
    
  2. Resize the Filesystem
    sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
    

- DONE -

Warp Terminal Automatically Warpify Subshells

# For zsh subshells, add to ~/.zshrc.
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "zsh"}}\x9c'

# For bash subshells, add to ~/.bashrc or ~/.bash_profile.
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "bash"}}\x9c'

# For fish subshells, add to ~/.config/fish/config.fish.
if status is-interactive
  printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "fish"}}\x9c'
end

via

Go-compiled binary running on alpine

One command is all you need:

apk add libc6-compat

via

SuperMicro X10SRL-F 主板 OOB per Node License 生成方法

这个 License 的用途:

激活后,可通过 IPMI Web 页面直接做 BIOS Update 或 RAID Management 操作;据说该方法对 X9/X10/X11 系列均适用

生成方法:

  • 在 IPMI Web 首页上复制 BMC MAC 地址
  • 执行命令:echo -n '<BMC_MAC>' | xxd -r -p | openssl dgst -sha1 -mac HMAC -macopt hexkey:8544E3B47ECA58F9583043F8 | awk '{print $2}' | cut -c 1-24

激活方法:

  • 将上一步生成的 License 分段填入点激活即可

via

Ubuntu Server 22.04.2 LTS 启动卡在 A start job is running for wait for network to be configured

解决方法

sudo systemctl disable systemd-networkd-wait-online.service
sudo systemctl mask systemd-networkd-wait-online.service

ref

NVIDIA Tesla P40 显卡 BIOS 报错 PCI OUT OF RESOURCES

报错如下:

!!!!PCI Resource ERROR!!!!

PCI OUT OF RESOURCES CONDITION:

Error: Insufficient PCI Resources Detected!!!

System is running with Insufficient PCI Resources!
In order to display this message some
PCI devices were set to disabled state!
It is strongly recommended to Power Off the system and remove some PCI/PCI Express cards from the system!
To continue booting, proceed to Menu Option and select Boot Device or .

WARNING: If you choose to continue booting some Operating
Systems might not be able to complete boot correctly!

解决方法:

  • 开机进入 BIOS 设置
  • 找到设置项:BIOS > Advanced > PCIe/PCI/PnP Configuration > Above 4G Decoding
  • 设为 Enabled

ref

ESXi vm 自动启动不起作用的解决方法

  1. Navigator -> Manage -> System -> Autostart
  2. Edit settings -> Enabled -> Yes

ESXi VM 使用 vmdk 文件虚拟 USB 安装/引导盘的方法

要点如下:

  • 在 VM 的数据目录下新建一个空白 vmdk 文件:vmkfstools -c 8G <path-to-vmdk-file>,注意替换尖括号里的文件名,假设就叫 usb.vmdk,下同
  • 使用 dd 命令将可引导的 iso 或 img 写入 vmdk 文件:dd if=<path-to-iso-or-img-file> of=<path-to-vmdk-file> bs=1M conv=notrunc
  • 修改 vmx 文件,添加以下配置:
    usb_xhci:0.present = "TRUE"
    usb_xhci:0.deviceType = "disk"
    usb_xhci:0.fileName = "usb.vmdk"
    usb_xhci:0.readOnly = "FALSE"
    usb_xhci:0.speed = "16"
    usb_xhci:0.parent = "-1"
    usb_xhci:0.port = "0"
    
  • 使用 vim-cmd 命令重新加载虚拟机配置:vim-cmd vmsvc/reload $(vim-cmd vmsvc/getallvms | grep '<你的虚拟机名称>' | awk '{print $1}')
  • 启动!

CentOS 7 从 Unraid VM 迁移到 ESXi 无法启动的解决方法

要点如下:

  • 将硬盘的控制器修改为 IDE
  • 进入系统
  • dracut --force --no-hostonly
  • 关闭 vm
  • 将硬盘的控制器修改为你想要的
  • 进入系统
  • dracut --force

Dell OptiPlex 7080mff 安装 ESXi 7.x 不识别 HP EX950 M.2 nvme 硬盘的解决方法

先说结论(2023-03-16):

  • 用这个方法也只能安装 ESXi 7.0u3,8.0b 仍然无法安装。
  • 为什么不直接安装 ESXi 6.5,因为 6.5 又缺少网卡驱动,而且版本太旧

解决方法:

  • 根本原因,ESXi 7.0 缺少一些 M.2 nvme 硬盘的驱动,据说是从 ESXi 6.7 开始干掉的
  • 下载 ESXi 6.5u2 的 iso,打开
  • 提取出 NVME.V00 文件,改名为 NVME_PCI.V00
  • 打开 ESXi 7.0 的 iso,把 NVME_PCI.V00 改名为 NVME_PCI.V00.OLD
  • 把之前提取出来的 NVME_PCI.V00 覆盖进来,保存
  • 用修改过的 iso 安装即可