grub rescue / move folder

12,634

If you have direct access to this machine (perhaps via this browser terminal popup thing (?)), you could try to load your kernel and the initramfs and boot it.

This won't bring up your system again (because the boot process doesn't only depend on /boot) but you can get into a shell.

If you have full access to GRUB this may work:

linux /<path>/boot/vmlinuz<...>
initrd /<path>/boot/initrd<...>

Because you haven't specified a root file system (via root=...) - because you currently don't have a usable one -, your system will run a busybox shell right from the initramfs.

This (initramfs) prompt is a complete shell. You need to create a folder - run mkdir /rootfs). Then you would need to mount your root file system (mount -o rw /dev/<...> /rootfs) and chroot into it (chroot /rootfs /bin/bash).

Then you can mount your other file systems (mount -a). Then you are able to do whatever you want.

Disclaimer: This is - as the question is, too - a cross-post from Super User.

Share:
12,634

Related videos on Youtube

Alexphys
Author by

Alexphys

Updated on September 18, 2022

Comments

  • Alexphys
    Alexphys over 1 year

    I made a really silly

    sudo mv /* /some_folder

    move command on my remote server vm ubuntu 12.04

    that moved my boot folder to

    /home/.../somefolder/boot

    I can access this folder via a browser terminal that gives me grub rescue.

    How can I move the entire folder back to root location so to boot normally?

    If that is impossible then if I boot from this location , will I be able to traverse to folders higher than the boot folder, as to at least copy my files via ssh?

    UPDATE

    I manage to do the following

     grub rescue> set prefix=(hd0,1)/home/path_to_boot/boot/grub
     grub rescue> set root=(hd0,1)/home/path_to_boot/
     grub rescue> insmod normal
     grub rescue> normal
    

    Which launches a menu with options in choosing Ubuntu boot. I press c to enter console and get to grub mode to issue linux command.

    grub> linux /home/path_to_boot/boot/vmlinuz-3.xx.x-67-generic
    grub> initrd /home/path_to_boot/boot/initrd.img-3.xx.x-67-generic
    grub> boot
    

    After that I get stuck at

    (initramfs)

    At this point I have no access to /home folder, only to folders inside /home/path_to_boot/boot.

    Any ideas how to proceed?

    UPDATE 2

    I contacted my servers company and got the option to boot via a live cd.

    With it I did a

    gksudo nautilus

    And managed to copy my files.

    Unfortunately though I wasn't able to save my system via grub, but so I got the files I needed.

    • Tim
      Tim almost 10 years
      If you boot via live cd, you can access the files.
    • Alexphys
      Alexphys almost 10 years
      @Tim True but its on a remote server and I don't have physical access to it
    • Tim
      Tim almost 10 years
      Ahh, okay. Google isn't returning anything for me. Very interesting Q btw.
  • Alexphys
    Alexphys almost 10 years
    I've updated my answer
  • YtvwlD
    YtvwlD almost 10 years
    @Alexphys I'm glad that you have secured your files.
  • YtvwlD
    YtvwlD almost 10 years
    @Alexphys But theoretically: The (initramfs) prompt is a complete shell. Then you would need to mount your root file system (mount -o remount,rw /) and your other file systems (mount -a). Then you are able to do whatever you want.
  • YtvwlD
    YtvwlD almost 10 years
    Added the last comment to the answer and changed it.
  • Alexphys
    Alexphys almost 10 years
    Since I can't anymore check the way you propose as a solution, I will just upvote your answer. Thank you for your time into this.
  • xealits
    xealits over 7 years
    I wonder, can you just do mv /some_folder/* / in (initramfs) then?
  • YtvwlD
    YtvwlD over 7 years
    @xealits Yeah, that should be possible. But you have to mount the root filesystem, before.
  • Solomon Ucko
    Solomon Ucko over 3 years
    FWIW, there's also cat.