我正在尝试删除专用/boot
分区并将其合并到根分区/
。我已经找到了https://askubuntu.com/questions/741672/how-do-i-merge-my-boot-partition-to-be-a-part-of-the-partition,但这似乎并没有帮助。
什么情况:
# uname -a
Linux c02 6.1.0-12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.52-1 (2023-09-07) x86_64 GNU/Linux
# fdisk -l /dev/sda
Disk /dev/sda: 4 TiB, 4398046511104 bytes, 8589934592 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1673AA12-2A54-4718-AF1E-58FE670A87E3
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2007039 2002944 978M Linux filesystem
/dev/sda3 2007040 10008575 8001536 3.8G Linux swap
/dev/sda4 10008576 8589932543 8579923968 4T Linux filesystem
以下内容有效,让我成功重新启动机器:
# copy content of boot partition to root
cp -a /boot /boot.bak
umount /boot
rm -rf /boot
mv /boot.bak /boot
# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.0-12-amd64
Found initrd image: /boot/initrd.img-6.1.0-12-amd64
Found linux image: /boot/vmlinuz-6.1.0-10-amd64
Found initrd image: /boot/initrd.img-6.1.0-10-amd64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done
但是当另外删除物理启动分区时,重启失败:
# fdisk /dev/sda
Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): d
Partition number (1-4, default 4): 2
Partition 2 has been deleted.
Command (m for help): w
The partition table has been altered.
Syncing disks.
这会导致 grub 错误:
error: no such partition.
grub rescue>
grub
当通过重新安装时,apt-get install --reinstall grub-pc
我收到以下 grub 错误:
error: attempt to read or write outside of disk `hd0`.
grub rescue>
这是怎么回事?