Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Problem with grub-install on Dell Vostro pc, after a restore

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
ole_thor
Posts: 18
Joined: 2020-01-23 11:09
Has thanked: 3 times

Problem with grub-install on Dell Vostro pc, after a restore

#1 Post by ole_thor »

20200123 20:15 ; the problem has been resolved. see edit in green italics below for missing code.
I couldn't boot from the disk after restore.
The system has 3 disks, 240GB SSD (sda), 320GB HDD (sdb), 320GB HDD (sdc).
I want to be able to boot debian buster from any 1 of the 3 disks by selecting the boot disk from the Bios.
The system used to have win7 installed with similar operation to below (without grub) and it worked from each disk.
I am trying to migrate from windows to Debian Buster.

I have installed buster on each of the disks from a live installation dvd (10.2) with 4 primary msdos partitions.
  • /boot ........... ext2 512MB
    / .................. ext4 16GB
    swap .......... 8GB
    /home ......... ext4 rest of disk
I am able to boot from any of the 3 disks and get into the OS.

To test backup and recovery, I backup from sdb and recover to sdc.
The backup process is as follows:
  • Boot from sda
    save the partition information with sfdisk --dump /dev/sdb > sdb.dump
    save the MBR information (and partition info) with dd if=/dev/sdb of=backup-sdb.mbr bs=512 count=1
    mount the partitions to /disks/Bkp-Boot /disks/Bkp-Root /disks/Bkp-Home
    backup sdb (using tar for /boot, /, /home to separate files)
    • tar -C /disks/Bkp-Boot -cvzf sdb-Boot_20200122.tar.gz --one-file-system ./ > sdb-Boot_20200122.txt 2>&1
      tar -C /disks/Bkp-Root -cvzf sdb-Root_20200122.tar.gz --one-file-system ./ > sdb-Root_20200122.txt 2>&1
      tar -C /disks/Bkp-Home -cvzf sdb-Home_20200122.tar.gz --one-file-system ./ > sdb-Home_20200122.txt 2>&1
To ensure that the restore simulates a replacement of the disk, I use gparted to create a gpt partition table on sdc.
The restore process (from backup of sdb to "new" disk sdc) is as follows:
  • boot from sda
    restore the MBR and partition info with "dd if=backup-sdb.mbr of=/dev/sdc bs=512 count=1".
    • with or without the previous step, yields the same result.
    initialize sdc partitions with sfdisk /dev/sdc < sdb.dump
    verify that the partitions are created correctly with sfdisk -l /dev/sdc
    initialize the file systems and swap
    • mkfs.ext2 -L Bkp-Boot /dev/sdc1
      mkfs.ext4 -L Bkp-Root /dev/sdc2
      mkswap -L Bkp-Swap /dev/sdc3
      mkfs.ext4 -L Bkp-Home /dev/sdc4
    mount the partitions to /disks/Bkp-Boot /disks/Bkp-Root /disks/Bkp-Home
    verify that the partitions are mounted correctly with mount -l | grep sdc
    restore /boot, /, /home to sdc
    • tar -xvf sdb-Boot_20200122.tar.gz -C /disks/Bkp-Boot --numeric-owner > sdc-Boot_Restore_20200122.txt 2>&1
      tar -xvf sdb-Root_20200122.tar.gz -C /disks/Bkp-Root --numeric-owner > sdc-Root_Restore_20200122.txt 2>&1
      tar -xvf sdb-Home_20200122.tar.gz -C /disks/Bkp-Home --numeric-owner > sdc-Home_Restore_20200122.txt 2>&1
    fix /disks/Bkp-Root/etc/fstab so that it has all the correct UUIDs
    execute "grub-install /dev/sdc" reports no errors. This is not required
  • mount /dev/sdc1 /disks/Bkp-Root/boot
    for i in /dev /dev/pts /proc /sys /run; do mount -B $i /disks/Bkp-Root$i; done
    chroot /disks/Bkp-Root
    grub-install /dev/sdc
    update-grub
    ctrl-d to exit chroot

reboot system and select "boot from sdc" in bios.
The system now boots to /dev/sdc.

these lines are no longer relevant:
The system boots but goes to /dev/sdb instead of /dev/sdc.
I used kdiff3 to compare the /boot/grub/grub.cfg on sdb and sdc and they are identical, indicating that the grub-install did not change the grub info on sdc.

I arrived at this process after several days of googling and trying different suggestions and trying to understand the grub information, but I have run out of ideas on how to resolve this.

Any thoughts on what I need to do to be able to boot from sdc at this point?
thanks for any assistance.
Last edited by ole_thor on 2020-01-24 00:44, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Problem with grub-install on Dell Vostro pc, after a res

#2 Post by Head_on_a_Stick »

ole_thor wrote:I used kdiff3 to compare the /boot/grub/grub.cfg on sdb and sdc and they are identical, indicating that the grub-install did not change the grub info on sdc
Why do you think the grub-install command will change grub.cfg? See https://wiki.debian.org/Grub#Configuring_GRUB_v2
deadbang

ole_thor
Posts: 18
Joined: 2020-01-23 11:09
Has thanked: 3 times

Re: Problem with grub-install on Dell Vostro pc, after a res

#3 Post by ole_thor »

head_on_a_stick:
I was expecting that the grub.cfg file would have to be changed to use the correct UUID for the boot device.

I did find somewhere that I needed to do a chroot to the target before I do the grub-install and then I have to do upgrade-grub to change the grub.cfg that I was looking for. I added that to the process, however, now I am getting a bunch of failures on the boot and I am looking into those.
failed to start hostname service
failed to start daily apt download activities
failed to start daily apt upgrade and clean activities
... and a bunch of other ones that went off the screen.

I will update the post when I am done investigating why these failures occurred.

ole_thor
Posts: 18
Joined: 2020-01-23 11:09
Has thanked: 3 times

Re: Problem with grub-install on Dell Vostro pc, after a res

#4 Post by ole_thor »

I have resolved the problems.
1- original problem (won't boot to correct disk) was resolved by adding this code after the restore and then the system will boot from the correct disk:
  • mount /dev/sdc1 /disks/Bkp-Root/boot
    for i in /dev /dev/pts /proc /sys /run; do mount -B $i /disks/Bkp-Root$i; done
    chroot /disks/Bkp-Root
    grub-install /dev/sdc
    update-grub
2 - problem with failed processes was due to a typo in the /etc/fstab after the restore.

I have updated the original post with the missing information that resolved the problem.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Problem with grub-install on Dell Vostro pc, after a res

#5 Post by Head_on_a_Stick »

ole_thor wrote:

Code: Select all

for i in /dev /dev/pts /proc /sys /run; do mount -B $i /disks/Bkp-Root$i; done
chroot /disks/Bkp-Root
You can save effort next time by using the arch-chroot command (from the arch-install-scripts package) to mount the API filesystems & chroot in.

Anyway, please add [SOLVED] to the thread title to help others who may encounter this problem.
deadbang

Post Reply