biker67
Posts: 59
Joined: Wed Oct 24, 2018 1:58 pm

Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 1:56 pm

i@pi:~ $ sudo apt purge -y gparted ["my entry to the left & the response follows"]
sudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

I was using gparted to install a 500 GB SSD on the RPi 4. Following an excellent write up from PiHut to do the job did not increase my success at installation of the SSD. I made 2 24hr efforts at installation. The second and third line above is what I get as response when trying to execute any terminal command. Can I go to /usr/bin and /etc/sudo.conf and delete something or reinstall the software?

User avatar
thagrol
Posts: 9840
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 3:00 pm

Have you at any point made any changes to those two files? If not the problem likely goes deeper and you may not find what else is broken until you stumble across it.

Is your root partition still on the SD card or have you moved it to the SSD?

If you have moved it to the SSD, how did you do that? What format is the root partition on the SSD?

The only fix may be as follows:
  1. Install a clean RPiOS on a different SD card
  2. Boot from it
  3. Connect the device containing the broken root partition via USB.
  4. Mount it e.g. on /mnt
  5. Execute the following commands:

    Code: Select all

    sudo chown root:root /mnt/etc/sudo.conf
    sudo chown root:root /mnt/usr/bin/sudo
    sudo chmod 4755 /mnt/usr/bin/sudo
    
    Replace /mnt with wherever you mounted the partition.
  6. Shutdown
  7. Swap boot media
  8. Boot
  9. See if the problem persists and what else is broken.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
DougieLawson
Posts: 42635
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 3:07 pm

thagrol wrote:
Mon Jun 05, 2023 3:00 pm
  • Execute the following commands:

    Code: Select all

    sudo chown root:root /mnt/etc/sudo.conf
    sudo chown root:root /mnt/usr/bin/sudo
    sudo chmod 4755 /mnt/usr/bin/sudo
    
    Replace /mnt with wherever you mounted the partition.
What worries me is that why does that file in /etc have the wrong ownership/permissions, what other files are wrong?

I would start with a fresh install on a new SDCard then add in the extra packages and copy over the files needed from the old SDCard.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
B.Goode
Posts: 15355
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 3:16 pm

biker67 wrote:
Mon Jun 05, 2023 1:56 pm
Following an excellent write up from PiHut to do the job

As a service to others, perhaps you could provide a reference to that 'excellent write up', because it seems it may contain a deadly flaw that should be flagged up to the authors?
Beware of the Leopard

User avatar
thagrol
Posts: 9840
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 3:26 pm

DougieLawson wrote:
Mon Jun 05, 2023 3:07 pm
What worries me is that why does that file in /etc have the wrong ownership/permissions, what other files are wrong?

I would start with a fresh install on a new SDCard then add in the extra packages and copy over the files needed from the old SDCard.
Indeed.

I suspect ownership, groups and permissions are broken throughout that root partition. My thinking was let's fix this then find out what else went wrong.

Why it's broken depends very much on the answers from the OP to my questions though I can think of a few posssibilities:
  • Owner, group and permissions have been changed on those files either manually or by some script OP has run.
  • The new root partition is not a Linux native format though if that were the case I'd expect boot to fail completely. (cmdline.txt and fstab would be wrong)
  • Whatever method was used to copy the contents of the root partition did not preserve owner, group, and permissions. Using cp would do that as would using rsync with incorrect options.
  • Corrupted SD card.
Some of those aren't relevant or likely if the root partition is still on the SD card.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
thagrol
Posts: 9840
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 3:30 pm

B.Goode wrote:
Mon Jun 05, 2023 3:16 pm
biker67 wrote:
Mon Jun 05, 2023 1:56 pm
Following an excellent write up from PiHut to do the job

As a service to others, perhaps you could provide a reference to that 'excellent write up', because it seems it may contain a deadly flaw that should be flagged up to the authors?
I'm guessing this one. Personally, I'd say it's far from execelent and nowhere does it say how to copy/move the OS to the new SSD.

Which is what I suspect the OP has tried to do.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

bjtheone
Posts: 2386
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: Terminal insists I fix a problem before it will take a command

Mon Jun 05, 2023 7:31 pm

Further to that, perhaps the OP could explain what he/she is trying to achieve, and then folks to provide the simplest and correct way to achieve it.

The OP does not mention if they are trying to add 500 GB of SSD storage to the PI and are ok with it automounting (simplest), want it mounted for some specific reason at some specific place in the file system, or want to move the entire OS and any data from the microSD to the SSD and then boot from the SSD. The solution is significantly different for each.

As thagrol noted the OP likely used an incorrect method and trashed the ownership, and potentially permissions on all the files. Fastest solution would likely be to start over, if they still have the "source" microSD card.

biker67
Posts: 59
Joined: Wed Oct 24, 2018 1:58 pm

Re: Terminal insists I fix a problem before it will take a command

Tue Jun 06, 2023 1:28 pm

https://thepihut.com/blogs/raspberry-pi ... spberry-pi

This is "excellent write up" I followed. It doesn't tell what size SSD the program can handle. I was using BX500 Crucial SSD which it can't handle in 24 hrs of "setting up". It also doesn't give progress reports.
As a result, I have gone all the way back to day one on RPi 4.

User avatar
B.Goode
Posts: 15355
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Terminal insists I fix a problem before it will take a command

Tue Jun 06, 2023 1:53 pm

biker67 wrote:
Tue Jun 06, 2023 1:28 pm
https://thepihut.com/blogs/raspberry-pi ... spberry-pi

This is "excellent write up" I followed. It doesn't tell what size SSD the program can handle. I was using BX500 Crucial SSD which it can't handle in 24 hrs of "setting up". It also doesn't give progress reports.
As a result, I have gone all the way back to day one on RPi 4.
I don't see anything in the early sections of that 3rd-party document that could cause the symptoms in your initial post.

But looking at the section Create a Directory for Mounting the SSD I can see that a typing error in the first command could potentially break your system just as you describe.

Code: Select all

sudo chown pi:pi -R /home/pi/myssd/

Attempting to un-install the gparted package doesn't seem to be part of the tutorial, and will save very little space.

If your concern is with poor performance, this might be of interest: viewtopic.php?t=245931
Beware of the Leopard

User avatar
thagrol
Posts: 9840
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Terminal insists I fix a problem before it will take a command

Tue Jun 06, 2023 2:33 pm

B.Goode wrote:
Tue Jun 06, 2023 1:53 pm
biker67 wrote:
Tue Jun 06, 2023 1:28 pm
https://thepihut.com/blogs/raspberry-pi ... spberry-pi

This is "excellent write up" I followed. It doesn't tell what size SSD the program can handle. I was using BX500 Crucial SSD which it can't handle in 24 hrs of "setting up". It also doesn't give progress reports.
As a result, I have gone all the way back to day one on RPi 4.
I don't see anything in the early sections of that 3rd-party document that could cause the symptoms in your initial post.
That's the one I though it might be. I didn't see anything either but I did see some unnecessary and ill advised mount options in their suggested fstab entry (it doesn't need auto or rw, users is a bad idea unless you want every normal user to be able to mount/unmount it without sudo).
But looking at the section Create a Directory for Mounting the SSD I can see that a typing error in the first command could potentially break your system just as you describe.

Code: Select all

sudo chown pi:pi -R /home/pi/myssd/
Yeah, that would do it. Breaking much of the OS while it does so.

TBH, I'd temporarily mount it on /mnt (sudo mount /dev/sda1 /mnt), use rsync to copy the entire /home directory tree to it (sudo rsync -axrvH /home/* /mnt) then use fstab to mount the drive's single partition on /home (edit fstab and reboot). The primary advantage being that when/if you break your OS you can reflash the SD card without losing your user data. And no need to run a chown command that has the potential to break your entire OS.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

biker67
Posts: 59
Joined: Wed Oct 24, 2018 1:58 pm

Re: Terminal insists I fix a problem before it will take a command

Thu Jun 08, 2023 7:29 pm

https://peyanski.com/how-to-boot-raspbe ... from%20SSD.

This approach is very straight forward. Under Raspi-config , advanced options, setup boot software to latest and save. Then under advanced options, select boot from USB if available otherwise boot from SD card and save.
Before booting; Under Menu-accessories choose SD card copier. Copy SD card to SSD and the reboot..
done
EDIT:
Not quite. I have tried several combos of settings; such as do not check UUID partitions, disable screen blanking in raspi-config in order to prevent screen from blacking out. It is fortunate that I had touch screen because i lost mouse at the end of coping SD to SSD (1/2 TB) but with touch screen I was able to close down what appeared to be a sucessfull media transfer to the Crucial SSD. After pulling the SD card, A reboot to the Crucil SSD went a long way but has ultimately failed to boot.
I would not try this again without a better SSD card. I might have gotten my $ worth for $11.

Return to “Troubleshooting”