How To Fix Server Ownership When Files Have Been Altered By Mistake
erics, Posted March 16th, 2022 at 12:19:54pm
Situation: Newbie mistake, used copy-and-paste to create a script that used variables with the incorrect variable name, then ran chown -R / OUCH
Resolution: Since I had aa clone host nearby, I decided to export the remote root fs via NFS, mount it on the fouled nnode, and use find magic to repair.
Here are the steps:
Bad host is nodeB, and good host is nodeG ;-}
Step 1. On nodeG, prepare NFS:
1 2 3 4 5 6 7 |
sudo -i service nfs start rpcinfo -p vi /etc/exports / *(ro,sync,no_root_squash) exportfs -a exportfs |
Step 2. On nodeB, mount the resource from nodeG and use it to set the ownership locally on nodeB via find -exec chown
:
1 2 3 4 5 |
sudo -i mkdir -p /volumes/nodeG/ mount nodeG:/ /volumes/nodeG/ mount find / -mount -exec chown -v --reference='/volumes/nodeG{}' '{}' \; |
Leave Your Comment
All fields marked with "*" are required.