Difference between revisions of "Grub"
From Briki
(→Moving boot record and /boot to a new disk) |
|||
Line 40: | Line 40: | ||
</pre> | </pre> | ||
* Restart (or halt and disconnect old drive), and cross your fingers! | * Restart (or halt and disconnect old drive), and cross your fingers! | ||
+ | |||
+ | == Updating /boot/grub/device.map == | ||
+ | This file is no longer generated (or kept up to date) by default in recent grub versions, since it's largely unused. To update it manually: | ||
+ | sudo grub-mkdevicemap |
Revision as of 08:05, 4 February 2021
Moving boot record and /boot to a new disk
- Setup new disk with GPT partition table
- For BIOS (not EFI) booting, create a ~2MB partition at the start of the disk, with the bios_grub flag
sudo parted -a optimal -s /dev/sdX -- mklabel gpt mkpart bios 0% 2MB set 1 bios_grub on
- Create a boot partition (but don't set the boot flag)
sudo parted -a optimal -s /dev/sdX -- mkpart boot 2MB 5GB sudo mkfs.ext4 /dev/sdX2
- Use the remainder of the space as desired
- Example "parted /dev/sdX -- print free" for a bootable drive:
Model: ATA ST3320620A (scsi) Disk /dev/sde: 320GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 1049kB 1031kB bios bios_grub 2 1049kB 2000MB 1999MB ext4 boot 3 2000MB 320GB 318GB ext4 tmp 320GB 320GB 335kB Free Space
- Mount new boot partition at /mnt, and copy boot partition onto it:
mount /dev/sdXY /mnt cp -a /boot/* /mnt
- Edit /etc/fstab and change /boot partition mount to UUID for new partition (use /dev/disk/by-uuid to determine partition uuid)
- Unmount existing /boot, and mount new /boot
umount /boot mount /boot
- Install grub boot loader into the bios partition, using the /boot partition for OS loading. Note that the disk is specified, rather than a partition:
grub-install /dev/sdX
- Update grub to match the new partition layout:
update-grub
- Restart (or halt and disconnect old drive), and cross your fingers!
Updating /boot/grub/device.map
This file is no longer generated (or kept up to date) by default in recent grub versions, since it's largely unused. To update it manually:
sudo grub-mkdevicemap