a

The Big Linux Oopsie™

What happened?!

Aah, it was a beautiful sunny day outside, and I was screwing around on my Linux workstation. I was trying to modify some file permissions, and everything went fine until disaster struck!
erynn@workstation:/usr/lib$ sudo chmod -R 664 .
erynn@workstation:/usr/lib$
"Alright", I thought. "That should do the trick".

And a trick it did...
I had yet to come to the realization that I was in fact not in the directory I intended to do this in. This realization came to me when I tried to run- well- anything at all, really.
erynn@workstation:/usr/lib$ ls -la
-bash: /usr/bin/ls: Permission denied
erynn@workstation:/usr/lib$
Uh oh... I appear to have removed all of my permissions 🤠
Since 'sudo' won't work either, let's try SSH as root.
C:\Users\erynn>ssh root@192.168.178.143
Enter passphrase for key 'C:\Users\erynn/.ssh/id_rsa':
/bin/bash: Permission denied
Connection to 192.168.178.143 closed.
C:\Users\erynn>

That complicates things...

Sooo, how do we fix this?

My workstation is on a VM on my server. If your first thought was that I'd try to find a backup, then you're correct! :)

Now, I did have a backup, however that one was six days old, and I had done a bunch of stuff since that point. What I tried instead was- since it's a VM- create a new VM and move the contents of the old one to the new one. I still kept the backup as a fallback though.

I use a Proxmox node, so to create a new VM I logged into the webUI and did just that. A new VM with the same specs as the old machine. The only difference is that I did not assign it the 256GiB drive that my bricked station has. This will be important later.

The disk partitions on my old station were set up as follows: A 32GiB SSD for everything but the /home directory. The /home directory had the 256GiB HDD mounted to it.

What I did for the new machine was assign just an SSD. Later, once it was installed, I would move the HDD from the bricked machine to the new machine by using zfs drive utilities on the Proxmode node's terminal.
root@proxmox:~# zfs rename HDD-RAIDZ2/vm-999-disk-0 HDD-RAIDZ2/vm-100-disk-1
root@proxmox:~# nano /etc/pve/qemu-server/999.conf
root@proxmox:~# nano /etc/pve/qemu-server/100.conf
After changing some VM confguration files and mounting the newly moved HDD onto /home (via /etc/fstab, so it would stay properly mounted), I was almost ready to use my workstation once again.
The only thing still missing is the contents of the old SSD. To fix this issue, I mounted that drive to a temporary location on my new machine. I then proceeded to copy all of the files over from the new mount to the root of the filesystem.
erynn@workstation:~$ mkdir THEDRIVE && sudo mount /dev/sdc1 /home/erynn/THEDRIVE
erynn@workstation:~$ cd THEDRIVE
erynn@workstation:~/THEDRIVE$ sudo cp -n * /
erynn@workstation:~/THEDRIVE$
I used the '-n' option to copy only files that didn't exist yet. I didn't want to overwrite any files just in case. This did however mean that services like SSH would need to be reconfigured, but this fortunately does not take much time.

Copying everything over took a good five seconds, but after that time I had regained access to my glorious(ly bad) C++ code and other files at last.

What did you learn from this??

    • Make more backups, more frequently
    • The Proxmox terminal is by far not as scary as it initially seemed 💀
    • PAY. ATTENTION. TO. CURRENT WORKING DIRECTORY.
        (also, do not use 'chmod ***' recursively. There's practically no reason to do that 😭)

Add my button to your website!

(or download the image and use your own HTML!)

Ad powered by: translink

Ad powered by: johnvertisement