Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 526  / 3 Years ago, thu, august 26, 2021, 1:15:57

Let's start with saying that I'm a very inexperienced not-so-poweruser. Last night I was trying to move every file in a directory to another location, but accidentally did this:




mv stuff /* /home/user/Downloads




I was connected to the remote VM through SSH, and from that command onward, everything started crashing and burning. No command on the terminal would be recognised, not ls, not cd, nothing, and the left part of the console, which usually stated something like




Dimitris#>_




Had turned to just




#>_




I restarted the machine and now it boots me into




grub rescue>_




first pic



I tried ls, I've got three hd()s:




hd(0), hd(0,msdos1), fd(0)





  • First one has an unrecognized filesystem (possibly the normal hd that
    I messed up since I moved everything to /home/user/Downloads)

  • Second
    one has some directories: second pic

  • Third one's
    first sector cannot be read.



Anything I can do to revert the last change, or anything? Or is it a fatal messup?



I'm fine with just destroying the VM and creating again, but I'd rather not lose my /var/www/ directory.


More From » grubrescue

 Answers
3

Basically, since you moved all files required for boot (for instance... /boot), your current machine is in no state for boot. However, others are.



You may be able to restore your machine's previous state since you know what was done. Configure your VM to boot on a Ubuntu Live ISO, select Try Ubuntu and manually mount your "messed up" partitions :



# Create mount points (home only if necessary).
sudo mkdir /mount/old /mount/old/home

# Mount the former / partition on /mount/old.
sudo mount /mount/old /dev/sdaX # sdaX being your destroyed / partition.

# Mount the former /home partition (if you have one) on /mount/old/home.
sudo mount /mount/old/home /dev/sdaY # sdaY being your former /home partition, if necessary.


If you want to get more information about your partitions, type sudo fdisk -l. This will give you the virtual drive's partition scheme. Try to recognise your partitions according to their filesystems and sizes. In most usual cases, the / partition is a large ext4 partition. If your /home shares the same partition as /, then remove it from the commands below.



From there, try to revert your changes in /mount/old and /mount/old/home, then umount them, and reboot on the virtual drive. Before umount-ing, you can also go to /mount/old/var/www or /mount/old/home/user/Downloads/var/www to get your data back.



# Find all files owned by root in the former Downloads directory, and move them back to the root (mounted on /mount/old)
sudo find /mount/old/home/user/Downloads -type d -maxdepth 1 -user root -exec mv {} /mount/old ;

# Un-mount everything.
sudo umount /mount/old/home /mount/old

# Power off! Remove the ISO and power the machine back on.
sudo poweroff


This seems like the most obvious solution, yet I don't know if GRUB's configuration will be able to handle the recent changes. You can still give it a try!


[#24492] Friday, August 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
humbire

Total Points: 55
Total Questions: 93
Total Answers: 113

Location: Oman
Member since Fri, Dec 23, 2022
1 Year ago
humbire questions
Thu, May 13, 21, 02:28, 3 Years ago
Sun, Oct 24, 21, 14:23, 3 Years ago
Wed, May 17, 23, 22:16, 1 Year ago
;