Ubuntu won't boot after partitions moved

Discussion in 'Acronis Disk Director Suite' started by LesBG, Jun 12, 2009.

Thread Status:
Not open for further replies.
  1. LesBG

    LesBG Registered Member

    Joined:
    Jan 6, 2007
    Posts:
    7
    Location:
    Midwest
    Using OSS to multiboot XP, Vista, W7 & Ubuntu. Used Disk Director to move free-space from end of drive down to one of the primary XP partitions so I could make that partition bigger. To do that, I had to move the free-space in front of each partition until I got it where I wanted it and then I re-sized my XP partition. So the Ubuntu /root, /home and swap partitions have been MOVED.

    All 3 Windows OS's still boot thru OSS but Ubuntu no longer boots. After I select it in OSS, all I see is a black screen with a blinking cursor. GRUB was installed in the boot sector if the Ubuntu root partition. I think this is a problem with GRUB but do not know how it fix it.

    Can someone help?

    Thanks,
    Les
     
  2. K0LO

    K0LO Registered Member

    Joined:
    Mar 9, 2006
    Posts:
    2,591
    Location:
    State College, Pennsylvania
    Les:

    I'll take a stab at it. This is messy because of Ubuntu's shift to using UUIDs to reference partitions. When you moved Ubuntu's partitions, their UUIDs changed. You need to fix the references in /boot/grub/menu.lst, /etc/fstab, and the swap partition reference in /boot/initrd.gz

    Fortunately, DD allows you to edit files on your Linux partitions directly while running the Windows version of DD. To help you figure this out could you post a screen shot of DD showing your disk layout, similar to this one?

    Layout.PNG

    From there I can help you change the relevant pointers in the files.
     
  3. LesBG

    LesBG Registered Member

    Joined:
    Jan 6, 2007
    Posts:
    7
    Location:
    Midwest
    Here is the requested screenshot attached to this reply. How do I embed the image directly in the reply?
     

    Attached Files:

  4. K0LO

    K0LO Registered Member

    Joined:
    Mar 9, 2006
    Posts:
    2,591
    Location:
    State College, Pennsylvania
    Les:

    After you upload your file, look below the editing window to the "Additional Options" window. Under "Attach Files" you will see a code that references your image upload, similar to this:
    Code:
    [ATTACH]xxxxxx[/ATTACH]
    where xxxxxx is a file reference number. Copy/paste the link into your post. When you preview the post you'll be able to see the image file in the preview.

    Thanks for the screen shot. It looks like your Ubuntu root partition is partition #10 (referenced in Linux as /dev/sda10). What is in partition #11; is it the Ubuntu home partition? And swap is /dev/sda12, correct?

    Now, if you double-click on the Ubuntu root partition in Disk Director can you see files and folders? If so, navigate to the file /etc/fstab. Right-click on the file and choose "Edit". Highlight all of the text in the file and copy it to the clipboard. Post the result back here.

    If you can't see the files in the previous step it means that you have a newer version of Ubuntu that uses inode-256 partitions, which Disk Director doesn't understand. If that's the case we will have to edit the files from an Ubuntu Live CD.

    While you're doing that I'll look up the config file that needs to be changed for the swap file reference...
     
  5. LesBG

    LesBG Registered Member

    Joined:
    Jan 6, 2007
    Posts:
    7
    Location:
    Midwest
    BTW: Thanks for your help!

    You are correct about your assumptions for the Ubuntu partitions:

    /dev/sda10 - root
    /dev/sda11 - home
    /dev/sad12 - swap

    Here is the contents of my fstab file:

    # /etc/fstab: static file system information.
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    proc /proc proc defaults 0 0
    # /dev/sda10
    UUID=a687cec6-aa7e-4889-a06d-77ec5950e265 / ext3 relatime,errors=remount-ro 0 1
    # /dev/sda11
    UUID=f89bf350-77e2-458b-b54d-1d64f9176e1a /home ext3 relatime 0 2
    /dev/sda12 none swap sw 0 0
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
    /dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec,utf8 0 0
    /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
     
  6. K0LO

    K0LO Registered Member

    Joined:
    Mar 9, 2006
    Posts:
    2,591
    Location:
    State College, Pennsylvania
    Great! I presume then that you were able to view the files on your Linux partitions directly from DD. That means that you can also edit them directly. Here are the changes that I suggest.

    1. For the file system table, /etc/fstab, just edit the two lines that mount the root and home partitions by removing the UUID references and replacing them with partition references as follows. Delete the red text and replace it with the blue text:
    Code:
    [COLOR="Red"]UUID=a687cec6-aa7e-4889-a06d-77ec5950e265[/COLOR] / ext3 relatime,errors=remount-ro 0 1
    
    changes to this:
    [COLOR="Blue"]/dev/sda10[/COLOR] / ext3 relatime,errors=remount-ro 0 1
    
    and:
    [COLOR="red"]UUID=f89bf350-77e2-458b-b54d-1d64f9176e1a[/COLOR] /home ext3 relatime 0  2
    
    changes to this:
    [COLOR="blue"]/dev/sda11[/COLOR] /home ext3 relatime 0 2
    Since the swap partition is already referenced by partition, no changes are needed there. Click OK to save changes to the file.

    2. Next step is to edit /boot/grub/menu.lst to remove any UUID references. Look through the file for any line containing root=UUID=a687cec6-aa7e-4889-a06d-77ec5950e265, which is referencing the old UUID of your root partition, and replace it with root=/dev/sda10. You will probably find one entry near the beginning of the file that looks like this:
    #kopt=root=UUID=a687cec6-aa7e-4889-a06d-77ec5950e265

    And you will find two or more entries near the end of the file that start with:
    kernel /boot/vmlinuz..... that contain UUIDs. Delete the UUIDs and instead reference the root partition by name; root=/dev/sda10. Save changes to the file.

    That should make Ubuntu boot again, providing that OS selector still recognizes its entry. I don't use OS Selector so I'll have to plead ignorance, but if it doesn't work you may need to delete the former OS Selector entry for Linux and then detect it again.

    3. Once you boot into Ubuntu you may need to make another edit to fix hibernation (suspend to disk). First, start gedit:
    Code:
    gksudo gedit /etc/initramfs-tools/conf.d/resume
    Change the line RESUME=UUID=xxxxx to reference your swap partition directly: RESUME=/dev/sda12. Close the editor and enter the following command in the terminal:
    Code:
    sudo update-initramfs -u
    These steps write a new Initial RAM disk file, initrd.gz, with swap correctly referenced so that you can hibernate correctly. If you find the file is already correct then skip step 3 entirely.

    If you want to now return to using UUIDs in the files that you have edited, you can figure out the partition's new UUIDs with the following command:
    Code:
    blkid
    Copy/paste the UUIDs into the appropriate places. Personally, I hate the UUID referencing method so if it were my system I'd just leave the references as /dev/sdax because it's easier to interpret if you ever need to fix things again. Also, you can now move any of your partitions around and as long as they don't change partition number the system will still boot and work correctly.

    I deleted all of the UUID references from my Linux system a long time ago. Good riddance!

    Let me know if this works.
     
  7. LesBG

    LesBG Registered Member

    Joined:
    Jan 6, 2007
    Posts:
    7
    Location:
    Midwest
    Mark,

    Updated fstab and menu.lst to replace UUIDs with device paths. Ubuntu still did not boot, so I deleted the entry from OSS menu and tried to re-establish it but OSS says there is no operating system on the partition (sda10) I am telling it to look at.

    I have a feeling the boot sector on sda10 is not what it is supposed to be. All I saw when I attempted to reboot into Ubuntu was the blinking cursor - grub menu or messages whatsoever.

    Is there some way to re-write the boot sector at the beginning of sda10?

    Thanks for all your help,
    Les
     
  8. K0LO

    K0LO Registered Member

    Joined:
    Mar 9, 2006
    Posts:
    2,591
    Location:
    State College, Pennsylvania
    Yes there is, Les. Do you have an Ubuntu Live CD that you can boot from?

    If so, do this:

    1. Boot your PC from the Ubuntu Live CD.
    2. In a terminal window type the following. (Do not type the comments in blue):
    Code:
    sudo grub                  [color=blue]Start GRUB in command mode[/color]
    find /boot/grub/stage1     [COLOR="Blue"]Confirm that grub returns (hd0,9) as the location of its files[/COLOR]
    root (hd0,9)               [color=blue]Point to the partition containing GRUB's files[/color]
    setup (hd0,9)              [color=blue]Install GRUB to the boot sector of the Ubuntu partition, sda10[/color]
    quit                       [color=blue]Exit GRUB[/color]
    3. Reboot the PC to test.
     
    Last edited: Jun 13, 2009
  9. LesBG

    LesBG Registered Member

    Joined:
    Jan 6, 2007
    Posts:
    7
    Location:
    Midwest
    When I tried setup (hd0,9) I got a GRUB error. Here is my terminal window display:

    grub> find /boot/grub/stage1
    (hd0,9)

    grub> setup (hd0,9)

    Error 12: Invalid device requested

    grub>


    UPDATE:
    I tried setting root to (hd0,0) using "root (hd0,9)" command and then tried the setup command. It appeared to work! Here is screen display:

    grub> root (hd0,9)

    grub> setup (hd0,9)
    Checking if "/boot/grub/stage1" exists... yes
    Checking if "/boot/grub/stage2" exists... yes
    Checking if "/boot/grub/e2fs_stage1_5" exists... yes
    Running "embed /boot/grub/e2fs_stage1_5 (hd0,9)"... failed (this is not fatal)
    Running "embed /boot/grub/e2fs_stage1_5 (hd0,9)"... failed (this is not fatal)
    Running "install /boot/grub/stage1 (hd0,9) /boot/grub/stage2 p /boot/grub/menu
    .lst "... succeeded
    Done.

    grub>
     
    Last edited: Jun 13, 2009
  10. K0LO

    K0LO Registered Member

    Joined:
    Mar 9, 2006
    Posts:
    2,591
    Location:
    State College, Pennsylvania
    Les:

    You are correct - I forgot to include the step to first reference the partition with the grub files, root (hd0,9), before running setup (hd0,9). I'll edit post 8 in case someone else reads this later.

    With GRUB installed, does your machine now boot into Ubuntu correctly?
     
  11. LesBG

    LesBG Registered Member

    Joined:
    Jan 6, 2007
    Posts:
    7
    Location:
    Midwest
    YES IT DOES!

    Thanks a bunch for all of your expert help. I will certainly take some notes on how to do this so I can fix the problem myself in the future.

    System working just fine now. OSS auto-detected the "new" Linux partition and added an entry for it in the menu.

    Again, thanks!

    Les
    :D
     
  12. K0LO

    K0LO Registered Member

    Joined:
    Mar 9, 2006
    Posts:
    2,591
    Location:
    State College, Pennsylvania
    Les:

    Excellent! I'm glad that worked out for you.

    I meant to make an editorial comment earlier. One of my favorite features of Acronis Disk Director is its ability to directly view and edit files on both Windows and Linux partitions even while running DD in Windows. I find that very handy when rearranging the disk layout or setting up a multiboot system.

    And while I'm editorializing, Ubuntu's decision to change to referencing partitions by UUID was a serious error, in my opinion. I realize that it makes life easier for people with multiple hard disks since you can rearrange the order of disks and even plug and unplug USB external disks with Ubuntu installed on them and each partition's UUID stays the same. So this method solves that issue but it makes life much more complicated for those (like me and you) who occasionally want to rearrange partition layouts on their disk.

    Note, however, that Ubuntu also allows reference by partition label. For example, if you label your Ubuntu root partition "/" and the home partition "home" you can refer to them in /etc/fstab as label=/ and label=home instead of by device path or UUID. In boot/grub/menu.lst you can refer to the root partition as root=label=/. This is another way to make the references independent of the partition location, allowing you to move or relocate partitions without running into the problems that you experienced. Ubuntu should have made that method the default.
     
Thread Status:
Not open for further replies.