Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: chroot then "update-grub" gives errors

  1. #1
    Join Date
    Mar 2007
    Beans
    1,016

    chroot then "update-grub" gives errors

    Ok so I have a USB external hard drive with Ubuntu 10.04 LTS on it but I did something to ruin it's grub or something.

    So what I did to make my USB HDD bootable again is:

    Code:
    sudo mkdir -p /mnt/chroot
    sudo mount /dev/sdc1 /mnt/chroot
    sudo mkdir -p /mnt/dev
    sudo mount --bind /dev /mnt/dev
    sudo mkdir -p /mnt/proc
    sudo mount --bind /proc /mnt/proc
    sudo mkdir -p /mnt/sys
    sudo mount --bind /sys /mnt/sys
    sudo chroot /mnt/chroot
    After that I did:
    Code:
    root@ubuntu:/# update-grub
    /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).
    root@ubuntu:/# sudo update-grub
    sudo: unable to resolve host ubuntu
    /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).
    root@ubuntu:/#
    I don't know what to do about that error. It took me a while to understand how to learn chroot and thanks to some youtube videos I finally learned how and then it felt like a climax when I was about to issue the update-grub command and then when it didn't work, I felt bad lol .

    So if someone could help me, it would be GREATLY appreciated!
    Thanks in advance!
    Apps for Ubuntu (outdated) ---> http://cid-23a283fc1010a1bb.skydrive...%20Wine|6?uc=1
    Use Mnemosyne to Study for School!

  2. #2
    Join Date
    Jun 2009
    Beans
    329
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: chroot then "update-grub" gives errors

    that seems strange...

    i like to chroot a little differently:
    http://mrclark.ath.cx/linux/linux/howchroot.html
    always learning more every day.
    this is the best tech community i have ever known.

  3. #3
    Join Date
    Sep 2009
    Beans
    8,874
    Distro
    Ubuntu Development Release

    Re: chroot then "update-grub" gives errors

    It is easier to just reinstall grub2 with the two commands from this link. You don't have to chroot.
    https://help.ubuntu.com/community/Gr...ing%20GRUB%202

    If you really want to fix this, post the bootscript in my sig with the external plugged in. Post it in code tags.
    Last edited by wilee-nilee; June 24th, 2010 at 10:33 PM.





  4. #4
    Join Date
    Mar 2007
    Beans
    1,016

    Re: chroot then "update-grub" gives errors

    Ok first of all, thanks for both your responses. I tried the other chroot method and it gave me problems (it didn't even let me get into the chroot). But nobody knows what I'm doing wrong with my method? As for the grub installing, I'll keep that in mind too but I actually want to learn how to do this the chroot way because this is not the only thing that I need to chroot for but at the moment, I'd just like it if someone could tell me why I'm getting that error with my method and tell me how to solve it without making me attempt completely different solutions.
    Apps for Ubuntu (outdated) ---> http://cid-23a283fc1010a1bb.skydrive...%20Wine|6?uc=1
    Use Mnemosyne to Study for School!

  5. #5
    Join Date
    Apr 2010
    Location
    England
    Beans
    3,286

    Re: chroot then "update-grub" gives errors

    The problem with what you've listed above is that you're not mounting /dev and /proc inside the mounted filesystem, you're mounting the file system in one folder, proc in a completely unrelated folder, and /dev in another unrelated folder. You should mount /proc in /mnt/chroot/proc, and /dev in /mnt/chroot/dev

    Oh, and /sys too, if you want. I've never bothered with it though, and I've never had any problems.
    http://xkcd.com/293/
    There are 10 kinds of people in this world: Those who understand ternary, those who don't, and those who confuse it with binary.

  6. #6
    Join Date
    Mar 2007
    Beans
    1,016

    Re: chroot then "update-grub" gives errors

    WorMzy: I tried what you said in Ubuntu 10.04 and then just in case it was a bug, I also tried it in Ubuntu 9.04. Sadly, your suggestion is not working. Am I doing something wrong?

    Here is what I get:
    ubuntu@ubuntu:~$ sudo -i
    root@ubuntu:~# mkdir -p /mnt/chroot
    root@ubuntu:~# mkdir -p /mnt/chroot/dev
    root@ubuntu:~# mkdir -p /mnt/chroot/sys
    root@ubuntu:~# mkdir -p /mnt/chroot/proc
    root@ubuntu:~# mount -o bind /dev /mnt/chroot/dev
    root@ubuntu:~# mount -o bind /sys /mnt/chroot/sys
    root@ubuntu:~# mount -o bind /proc /mnt/chroot/proc
    root@ubuntu:~# mount /dev/sda1 /mnt/chroot
    root@ubuntu:~# chroot /mnt/chroot
    root@ubuntu:/# update-grub
    /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).

    Edit: I think I'm doing something wrong because it seems that the system does not control the chrooted operating system. I tested this by doing uname -r which gave me the kernel of Ubuntu 9.04 which is the live CD I'm running right now instead of that of the chrooted Ubuntu 10.04 system.

    Edit 2: Actually, I tried installing pidgin through the chroot and it worked like normal. Something does seem off though.
    Last edited by s3a; June 26th, 2010 at 05:28 AM.
    Apps for Ubuntu (outdated) ---> http://cid-23a283fc1010a1bb.skydrive...%20Wine|6?uc=1
    Use Mnemosyne to Study for School!

  7. #7
    Join Date
    Apr 2010
    Location
    England
    Beans
    3,286

    Re: chroot then "update-grub" gives errors

    You had the order right the first time: Mount sdc1, then proc, dev and sys. Now what you're doing is mounting proc, dev and sys, then immediately mounting over them with sdc1. You don't need to make the directories for proc, dev and sys either, they'll exist once you mount sdc1.

    So the following will work:
    Code:
    ubuntu@ubuntu:~$ sudo -i
    root@ubuntu:~# mkdir /mnt/chroot
    root@ubuntu:~# mount /dev/sda1 /mnt/chroot
    root@ubuntu:~# mount -o bind /dev /mnt/chroot/dev
    root@ubuntu:~# mount -o bind /sys /mnt/chroot/sys
    root@ubuntu:~# mount -o bind /proc /mnt/chroot/proc
    root@ubuntu:~# chroot /mnt/chroot
    root@ubuntu:/# update-grub
    http://xkcd.com/293/
    There are 10 kinds of people in this world: Those who understand ternary, those who don't, and those who confuse it with binary.

  8. #8
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: chroot then "update-grub" gives errors

    Here is a "one-liner" to chroot for sdc1:
    Code:
    sudo mount /dev/sdc1 /mnt && sudo mount --bind /dev /mnt/dev && sudo mount --bind /proc /mnt/proc && sudo mount --bind /sys /mnt/sys  && sudo mount --bind /dev/pts /mnt/dev/pts && sudo cp /etc/resolv.conf /mnt/etc/resolv.conf && sudo chroot /mnt
    After running the command you will be in the chroot environment and any commands run will affect your real installation on sdc1.
    GRUB2

    Retired.

  9. #9
    Join Date
    Mar 2007
    Beans
    1,016

    Re: chroot then "update-grub" gives errors

    drs305: It worked flawlessly! I have a few questions though.

    Firstly, to mount things, I thought I had to first create the directories with "mkdir" but it seems that I don't need to; does mounting auto-create the directories required?

    Secondly, what's the point of /etc/resolv.conf? I noticed that, like previously mentionned, the /dev /proc and /sys need to be within the chroot mount point but I also noticed the /etc/resolv.conf and I'm trying to make sense of it.

    Lastly, is there an important difference between mount -o bind and mount --bind. What if I did just mount by completely ignoring the "bind" part, would that make the command not work?

    Sorry for the additional questions but I would just like to understand this instead of just memorize it.

    Thanks!
    Apps for Ubuntu (outdated) ---> http://cid-23a283fc1010a1bb.skydrive...%20Wine|6?uc=1
    Use Mnemosyne to Study for School!

  10. #10
    Join Date
    Apr 2010
    Location
    England
    Beans
    3,286

    Re: chroot then "update-grub" gives errors

    -o bind and --bind do the same thing: bind an already existing folder to another location. A normal mount (mount -t) mounts a partition, not a folder, which is why you can't use it instead of --bind (or -o bind).

    When you mount a partition with Linux installed on it, all the files and folders on that partition get mounted too, which is why you don't need to create /dev /proc or /sys -- they already exist on the partition.
    http://xkcd.com/293/
    There are 10 kinds of people in this world: Those who understand ternary, those who don't, and those who confuse it with binary.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •