Untar without running into "Cannot change ownership to uid NNN, gid NNN: Disk quota exceeded" on WHM/cpanel VPS accounts
When you untar large tar files even as the root user on your VPS you might run into the error "Cannot change ownership to uid NNN, gid NNN: Disk quota exceeded". This is because the extracted files from the tar archive is being attempted to be created with the original UID and GID as on the system where the tar archive was created. Now if the UID is not already present on the new VPS or if the UID corresponds to a user without a lot of disc quota available the above error will be triggered preventing extraction of the tar.gz archive.
Tar has some options that will allow you to work around this problem
If you already have root access on the VPS then the following command should take care of the issue:
tar -xvzf archive.tar.gz --owner root --group root --no-same-owner 2>&1 > tar2.log
The --owner root
and --group root
will try to set the new user and group as root. The --no-same-owner
will tell tar to not bother about restoring original UID and GIDs.
If you don't already have root access you can do the same as above with some user who has sufficient quota available instead of the root user in the command.