Moving the / (root) volume - redux

opensuse 13.2
linux 3.16.7-21-desktop x86_64

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

Based on the little detail you posted,

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.

TSU

On 2015-04-26 01:26, jimoe666 wrote:

> 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”.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

It is hard to know what is expected. I guess listing the creation process was inadequate.

I’m guessing that you haven’t marked the boot partition.

Good guess. Obviously the missing step.

I looked through the fdisk man page. It mentioned nothing about how to mark a disk as bootable. Same for gdisk and gpart.

So, explicitly, what are the steps?

On 2015-04-26 03:56, jimoe666 wrote:

> 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.

Also, you haven’t installed grub code.

Assuming it is not an EFI setup…


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

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.

Okay. grub_installdevice:

ata-Axiom_Signature_Series_III_SSD_AX150206AS1706442-part2
activate
generic_mbr

if /boot/grub2/device.map exists, make sure to replace device paths there with correct ones (that match your new disk)
Okay. device.map:

(hd0)    /dev/disk/by-id/ata-Axiom_Signature_Series_III_SSD_AX150206AS1706442
(hd2)    /dev/disk/by-id/ata-Axiom_Signature_Series_III_SSD_AX150206AS1706441
(hd1)    /dev/disk/by-id/scsi-SSEAGATE_ST336753LW_3HX0G0GM000073370Y4S

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

The final actions were to (in my case):

  • boot the Rescue System
  • run YaST::Boot Loader
  • select “Custom Boot Partition”
  • enter the target device (/dev/sda2, for instance)
  • verify “Set active Flag…” and “Write generic Boot Code to MBR” are set
  • save
  • boot

I then set the boot device in the BIOS. The system booted using the new SSD device. Yay!

On 2015-04-26 04:56, gogalthorp wrote:
> So need to know the exact way the copy was made.

He pasted the exact commands on the first post.

He did a plain file copy, not a clone. So boot records were not copied,
nor the grub images.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

On 2015-04-26 20:46, jimoe666 wrote:
>> Is “setting the active partitioin” the same as “marking a partition as
> bootable”?

Yes.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

On 2015-04-27 00:06, jimoe666 wrote:
>
> The final actions were to (in my case):
> - boot the Rescue System
> - run YaST::Boot Loader

Well, I told you to do just that…


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

It should have been full device name (/dev/disk/by-id/…).

Yes, you did. Sort of.

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.