Sudo chown the whole system? :(

  • I was not totally awake when I was about to change ownership of a single folder.

    I was cd into the folder in question and I ran this:

    Code
    sudo chown -R docker:user /


    I just used the single slash, which seemed to cover the whole filesystem :( I lost connection to my server, I guess because of a crash.

    Is there any hope in restoring this?


    I have regular backups done with the OMV 4 Backup plugin. But I have never tried restoring, is it hard to do? How is it done when I cannot reach the NAS?

  • Can I use some kind of live linux on an USB and somehow get the permissions from the backup and restore them on the disk with OMV?

    Or is there any easy way to restore OMV from a backup when the OS is broken?

  • You can reinstall all packages, if you have physical or remote access to the system. That should fix the ownership issues for many files, because all files (except for configuration files, created files, etc.) should be reinstalled with their default ownership and permissions. For configuration files you will probably have to make educated guesses. I would probably do:


    dpkg -l | awk '$1 == "ii" {print $2"="$3}' > package.list

    sudo apt-get clean

    cat package.list | xargs sudo apt-get install --reinstall -d -y


    That downloads all still available packages with the installed version into /var/cache/apt/archives/. Now you can try to reinstall all of these packages. This will fix at least all non-configuration files and all non-created and non-user files. Alternatively you can iterate over all the .deb files in this directory, extract the contents including permissions/ownership information via dpkg-deb -c <package>.deb 2>/dev/null, and apply them to your filesystem. This should fix shipped configuration files as well. You'll still have to fix all file permissions for files not shipped by a package but created (e.g. a lot of the files in /var, /home, etc.). The cruft/ctuft-ng packages can help you to find all files not shipped by a package.


    Please note, this is a complex task and you can damage your system even further. You should definitely make a backup before attempting to salvage the system.


    EDIT: I just read, that you have a backup. Then I would reinstall all packages (in bunches, not all at once). At last I would compare the backup with the system and apply the missing ownerships as well. (something like sudo find <backup-dir> -exec chown --reference="{}" "/{}" \;). Then I would check for files not in the backup and fix their permissions manually as well. Or if the backup is not too old: Just play back the backup.

  • Unless you have a known to be restorable backup of the entire system disk there is no way to recover from this.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • joq3 I agree with gderf. We had this before in the forum and the only approach which makes sense is a complete reinstallation, because the whole debian system is affected not only the OMV installation. Therefore you will not be able to restore the earlier state with the OMV backup plugin.

    OMV 3.0.100 (Gray style)

    ASRock Rack C2550D4I C0-stepping - 16GB ECC - 6x WD RED 3TB (ZFS 2x3 Striped RaidZ1) - Fractal Design Node 304 -

    3x WD80EMAZ Snapraid / MergerFS-pool via eSATA - 4-Bay ICYCube MB561U3S-4S with fan-mod

    Einmal editiert, zuletzt von cabrio_leo ()

  • Can I use some kind of live linux on an USB and somehow get the permissions from the backup and restore them on the disk with OMV?

    Do you understand that the ownership of perhaps hundreds of thousands of files were changed?

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • I am basing my statement on many years of Linux experience and direct knowledge that perhaps hundreds of thousands or even millions of files had their ownership changed.


    How long do you think it would take for you to reset each of those files by hand in the shell?

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

    Einmal editiert, zuletzt von gderf ()

  • I am basing my statement on many years of Linux experience and direct knowledge that perhaps hundreds of thousands or even millions of files had their ownership changed.


    How long do you think it would take for you to reset each of those files by hand in the shell?

    Every Debian package comes with the ownership and permissions for each file in there pre-set. That is why you'd need dpkg-statoverride to make a permissions or ownership change persistent. I have described the way above. So again: There is no need to reset each file by hand. It would probably leave a handful of files left. You speak like you know nothing about Debian packages. And I have also answered the first part of your question in the message you replied to.

  • If you have a backup, just restore it.


    Unfortunately, from what you have written so far, you have never tried to restore any of your backups. So you have no idea if they are any good or not.


    IMHO, you do not have backups unless you have verified that they can be restored. In other words you have tested them. And the time to test them is before you really need them.


    You need to figure out how to restore one of your backups. And if you can't successfully do this then your OMV is toast. That's all there is to it.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • Why isn't it possible to use the backup to restore the system?

    You would need an image backup of your installation e.g. created with CloneZilla. With such an image you would be able to restore the complete system. As I know the OMV backup plugin does create a backup of the OMV settings or maybe of the OMV installation, not of the whole system. But maybe I am wrong and someone else can give a correct answer. I have never used the OMV backup plugin. I always use CloneZilla.

    OMV 3.0.100 (Gray style)

    ASRock Rack C2550D4I C0-stepping - 16GB ECC - 6x WD RED 3TB (ZFS 2x3 Striped RaidZ1) - Fractal Design Node 304 -

    3x WD80EMAZ Snapraid / MergerFS-pool via eSATA - 4-Bay ICYCube MB561U3S-4S with fan-mod

  • What's the best way to restore a backup when I cannot reach the system via SSH?

    Then you need physical access or a rescue system. Providers usually have rescue systems, from which one can mount the data partitions in question. SSH relies on several permissions/ownership values and refuses to start otherwise. If you can gain access to the system, you can check the logs, find the issue, fix it.


    What kind of backup is this? What did you use to create it?

  • If I'm not mistaken, the default settings in OMV Backup are to use 'dd' to save a (compressed) image of the entire system partition, although fsarchiver is another option.

    So chances are that the OP can restore the backup, maybe through Clonezilla (?) or, if all else fails, from a Debian live session booted from a USB stick.

    • Offizieller Beitrag

    Why isn't it possible to use the backup to restore the system? It is just a week old. Or does that require a working system?

    If it is a backup from before you did this, I don't see any reason the backup wouldn't work.


    Let this be a lesson to use root/and sudo with great caution.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!