venerdì 25 novembre 2011

Cannot boot OpenSuse 12 after cloning disk due to by-id access to the disk

Hi all,
today I tried to clone a pc with OpenSuse12 using Clonezilla as cloning solution.
Then I tried to boot the target cloned machine but it wasn't able to boot and the errors was something like this (the disk names are from another post, just as an example) :



Trying manual resume from /dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part1
resume device dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part1 not found (ignoring)
Trying manual resume from /dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part1
resume device dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part1 not found (ignoring)
Waiting for device dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part2 to appear : ........................ Could not find dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part2 .
Want me to fall back to dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part2 ? (Y/N)
y
Waiting for device dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part2 to appear : ...............not found -- exiting to /bin/sh




The typical messages are:

Trying manual resume from
resume device dev/disk/by-id/ata-...-part1 not found (ignoring)
Waiting for device dev/disk/by-id/ata-...-part2 to appear
Could not find dev/disk/by-id/ata-...-part2
Want me to fall back to dev/disk/by-id/ata-...-part2 ? (Y/N)


This happens due to a new default setting in OpenSuse: from Ver.10Sp1 on, the new default is to reference the storage device (the disks)  "by-id" instead of by-name

I mean, in the past the disks was referenced like this:
sda
sdb
...


then the partitions of the first disk (sda) was:
sda1
sda2
sda3


and so on.

Now the new way to reference disk and partition is:

The disks are (just an example, it changes based on the disk manifacturer and other data):
/dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T
/dev/disk/by-id/ata-ST380013AS_4MR2NSD8

where the first row is the first disk, a Toshiba disk, the second is another disk, a Seagate disk.

The partitions will be, for the first disk, for example:

/dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part1
/dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part2

for the second disk:
/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part1
/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part2

The problem with cloning is that around the system, in some configuration files, there are references to the original disks "by-id", unfortunately on the target computer (where we restore the image) the disks will be different, will have different "by-id" name, so linux will be unable to find the disks and boot correctly.

SOLUTION


The solution is quite simple.
After creating the MASTER computer, we need to change 2 files in order to modify the "by-id" reference in "by-name" reference.
The files are:


/etc/fstab
/boot/grub/menu.lst


in both the files we need to find every instance of names like (example)

/dev/disk/by-id/ata-TOSHIBA-MK1246GSX-28FGTI70T-part1

and change in something like:

/dev/sda1

take care about the partition number:
-part1  ->  sda1
-part2  ->  sda2

and so on.

To modify those files from a command prompt we need to run the editor using sudo else we will get an error (missing rights):

sudo vi /etc/fstab


(then i to go into insert mode, change the disk name, then press ESC to exit insert mode, then :wq to write the changes to disk and quit, else to discard changes :qa!)

sudo vi /boot/grub/menu.lst


(same instruction as above)

Reboot the computer to check that everything is still working fine.
You are now ready to create the image with Clonezilla (or other cloning solution) and restore on the target pc.


SAMPLE
Here how my files appeared before and after the change:

/etc/fstab
BEFORE


/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part1 swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part2 /                    ext4       acl,user_xattr        1 1
/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part3 /home                ext4       acl,user_xattr        1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0


/etc/fstab
AFTER


/dev/sda1 swap                 swap       defaults              0 0
/dev/sda2 /                    ext4       acl,user_xattr        1 1
/dev/sda3 /home                ext4       acl,user_xattr        1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0



/boot/grub/menu.lst
BEFORE




# Modified by YaST2. Last modification on Fri Nov 25 21:23:32 CET 2011
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader


default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,1)/boot/message
##YaST - activate


###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 12.1 - 3.1.0-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-3.1.0-1.2-default root=/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part2 resume=/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part1 splash=silent quiet showopts vga=0x31a
    initrd /boot/initrd-3.1.0-1.2-default


###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 12.1 - 3.1.0-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-3.1.0-1.2-default root=/dev/disk/by-id/ata-ST380013AS_4MR2NSD8-part2 showopts apm=off noresume nosmp maxcpus=0 edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x31a
    initrd /boot/initrd-3.1.0-1.2-default


/boot/grub/menu.lst
AFTER


# Modified by YaST2. Last modification on Fri Nov 25 21:23:32 CET 2011
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader


default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,1)/boot/message
##YaST - activate


###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 12.1 - 3.1.0-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-3.1.0-1.2-default root=/dev/sda2 resume=/dev/sda1 splash=silent quiet showopts vga=0x31a
    initrd /boot/initrd-3.1.0-1.2-default


###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 12.1 - 3.1.0-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-3.1.0-1.2-default root=/dev/sda2 showopts apm=off noresume nosmp maxcpus=0 edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x31a
    initrd /boot/initrd-3.1.0-1.2-default



bye
Digger



17 commenti:

  1. Thanks a lot!!,
    I had over 20 copies of hard disks to prepare for classroom, and I couldn't make it. It was that error. Cloned disks doesn't worked out. Now everything is OK. Tomas, Poland

    RispondiElimina
  2. You're welcome, glad to know it was useful to you :)

    RispondiElimina
  3. Thanks for the solution and explanation!

    RispondiElimina
  4. Thank You, very useful.

    For beginners... the following steps may be useful

    1. boot in "rescue system" mode
    2. use "fdisk -l" to view available partitions
    3. mount the partitions to a temporary folder
    i.e mount /dev/sda2 /mnt
    4. modify /mnt/etc/fstab and /mnt/boot/grub/menu.lst as per above instructions.

    RispondiElimina
  5. @Digger, excellent post !!!
    Thank you VERY much !!!
    I was able to recover two very important VM disks.

    RispondiElimina
  6. Thanx a lot made my day

    RispondiElimina
  7. I'm able to use Repair option from the installation media to get this issue fixed.

    RispondiElimina
  8. Thanks for your excellent post! I was now able to clone SLES 10 SP3 in Virtualbox 4.1.12 without any further problem. Dig ya! Michael

    RispondiElimina
  9. Thanks for your help!!!
    The easiest way I found to fix it was to put the drive in a casing, backup the boot/grub2/grub.cfg and changed the config file directly. Initially I had a problem which I found was caused by the root being installed in my case on the second drive on my desktop machine. So swapping #.sda with #.sdb did the trick.
    Thanks again!!!

    RispondiElimina
  10. Awesome, thank you! Works for Oracle VirtualBox perfectly.

    RispondiElimina
  11. Thanks a lot, It helped me a lot !

    RispondiElimina
  12. JAZAKALLAH BRO , JAZAKALLAH ,
    MAY ALMIGHTY ALLAH GIVE YOU BEST THING FROM HIM ...
    2DAY I SUCCEEDED IN MAKING CLONE OF ONE OF MY BACKUP SERVER ...
    INSHA ALLAH SOON WE ARE PLANING TO MAKE BACKUP OF PRODUCTION SERVER ALSO ...
    AFTER READING THIS PAGE I HAVE DONE A SUCCESSFUL OPERATION ...
    THANKS ALOT BRO ...
    GREAT POST !!!

    RispondiElimina
  13. Thanks :) It works like a shame :)
    Massimo

    RispondiElimina