KingDariush
Posts: 13
Joined: Tue Aug 21, 2018 8:45 pm

Mistakenly moved system folders in Raspbian Buster. System failure

Sat Feb 08, 2020 2:19 pm

I was working on OpenVpn connection settings. Mistakenly I moved system folders in Raspbian Buster by:
sudo mv -r /* /etc/openvpn

Now, raspberry pi isn't boot. How to edit partition or restore?

tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Mistakenly moved system folders in Raspbian Buster. System failure

Sat Feb 08, 2020 2:20 pm

At that point it is a matter of reinstallation and then restoring from backup.

User avatar
jojopi
Posts: 3193
Joined: Tue Oct 11, 2011 8:38 pm

Re: Mistakenly moved system folders in Raspbian Buster. System failure

Sat Feb 08, 2020 3:10 pm

KingDariush wrote:
Sat Feb 08, 2020 2:19 pm
sudo mv -r /* /etc/openvpn
mv does not accept the -r option. It is always recursive because there is no way to move a directory without the contents also moving.

Assuming you mean "mv /* /etc/openvpn/", that is easy to undo if you have root access to another Linux machine. Otherwise install a new Raspbian image on a spare card, and mount the original card in a USB card reader.

Code: Select all

sudo mount /dev/sdX2 /mnt
sudo mv /mnt/etc/openvpn/*/ /mnt/

ejolson
Posts: 4923
Joined: Tue Mar 18, 2014 11:47 am

Re: Mistakenly moved system folders in Raspbian Buster. System failure

Sat Feb 08, 2020 3:37 pm

jojopi wrote:
Sat Feb 08, 2020 3:10 pm
KingDariush wrote:
Sat Feb 08, 2020 2:19 pm
sudo mv -r /* /etc/openvpn
mv does not accept the -r option. It is always recursive because there is no way to move a directory without the contents also moving.

Assuming you mean "mv /* /etc/openvpn/", that is easy to undo if you have root access to another Linux machine. Otherwise install a new Raspbian image on a spare card, and mount the original card in a USB card reader.

Code: Select all

sudo mount /dev/sdX2 /mnt
sudo mv /mnt/etc/openvpn/*/ /mnt/
That should recover it. There was a thread not too long ago on the dangers and benefits of passwordless sudo. The present thread would serve nicely as an example of one of the dangers.

KingDariush
Posts: 13
Joined: Tue Aug 21, 2018 8:45 pm

Re: Mistakenly moved system folders in Raspbian Buster. System failure

Sat Feb 08, 2020 4:12 pm

Thanks guys, I'm installing Raspbian Lite. Will let you know after mounting and moving folders back.

Return to “Troubleshooting”