I attempted to move the root (/) volume (on a hard disk) to another volume (a SSD). All seemed to go well… Except that the target disk is not bootable. When I select the disk in the BIOS as the one to boot, all I get is a dumbfounded silence (i.e., only a blinking cursor) where I expected “GRUB loading …”
What is the step needed to make the SSD bootable?
# boot rescue system
# verify the /dev/sd* volumes are as expected.
mkdir root1
mkdir root2
mount /dev/sdj2 /mnt/root1 -- the old system root
mount /dev/sda2 /mnt/root2 -- the new system root
cd /mnt/root1
cp -a . /mnt/root2 -- copy everything from old to new
# modify /mnt/etc/fstab to mount new root as root.
umount /mnt/root1
umount /mnt/root2
rmdir root1
rmdir root2
# Rebuild the boot stuff
mkdir /mnt/usr
mount /dev/sda2 /mnt
mount /dev/sdb2 /mnt/usr
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
chroot /mnt
mkinitrd
exit
I’m guessing that you haven’t marked the boot partition.
To do that, you’ll need to run fdisk or a partitioning app from a bootable disk… eg a LiveCD.
Make sure you mark the partition containing the boot files (which includes GRUB) which isn’t always the root (/) partition.
> What is the step needed to make the SSD bootable?
>
>
> Code:
> --------------------
> cd /mnt/root1
> cp -a . /mnt/root2 – copy everything from old to new
…
> --------------------
Well, you copied the files, but grub is not installed as “files”, but
into some raw sectors outside of the filesystem. Typically, you need to
reinstall grub or grub2.
You might try to run, from the rescue system, yast boot loader module to
install it. Or a sequence of commands I never remember right for grub 1,
and never learned right for grub 2.
For grub1, the parameters should be in “/etc/grub.conf”.
> I looked through the fdisk man page. It mentioned nothing about how to
> mark a disk as bootable. Same for gdisk and gpart.
You do not mark a disk as bootable; you mark a partition.
minas-tirith:~ # fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Command action
a toggle a bootable flag <<=====
b edit bsd disklabel
.....
Notice that this alone does nothing, you also need booting code in the
master boot record. And you haven’t done that in your steps.
Marking partitions as boot is a MBR boot thing if the system is set up to boot EFI then the whole thing is different. Also it depends exactly how the partition was copied wither all things came over. You may nee to modify the /etc/fstab too point to the new partitions if it was not a full clone since the UUID will be different.
So need to know the exact way the copy was made. Also if EFI or MBR boot
You need to install bootloader on new disk and configure it to look at the correct partition for various files. Which means in chroot
edit /etc/default/grub_installdevice and replace partition name with correct one (that refers to your new disk)
if /boot/grub2/device.map exists, make sure to replace device paths there with correct ones (that match your new disk)
run “update-bootloader --reinit”. This should both install grub on disk defined in /etc/default/grub_installdevice and rebuild grub.cfg.
if your boot device was partition, you also need to install boot code in MBR and set active partition. Now about MBR I’m not sure … there is fixmbr command but I never used it.
run “update-bootloader --reinit”. This should both install grub on disk defined in /etc/default/grub_installdevice and rebuild grub.cfg.
Not okay:
$ update-bootloader --reinit
Perl-Bootloader: 2015-04-25 22:59:01 <3> pbl-1345.2 Core::RunCommand.1658: Error: '/usr/sbin/grub2-install --target=i386-pc --force --skip-fs-probe "ata-Axiom_Signature_Series_III_SSD_AX150206AS1706442-part2"' failed with exit code 1, output:
<<<<<<<<<<<<<<<<
Installing for i386-pc platform.
/usr/sbin/grub2-install: error: cannot find a GRUB drive for ata-Axiom_Signature_Series_III_SSD_AX150206AS1706442-part2. Check your device.map.
>>>>>>>>>>>>>>>>
I have tried a number of variants including an exact match between grub_installdevice and device.map.
What is a “GRUB drive”?
if your boot device was partition, you also need to install boot code in MBR and set active partition. Now about MBR I’m not sure … there is fixmbr command but I never used it.
Is “setting the active partitioin” the same as “marking a partition as bootable”?
$ fdisk -l /dev/sda
Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
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: dos
Disk identifier: 0x000a538e
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 4208639 4206592 2G 82 Linux swap / Solaris
/dev/sda2 * 4208640 234440703 230232064 109.8G 83 Linux
It was not at all clear to me that was the preferred method; you also mentioned running a series of (unspecified) grub commands that you never get correct.