-   CentOS (
-   -   Can only write to mounted IMG file as root. (

LanceK 11-05-2017 11:14 AM

Can only write to mounted IMG file as root.

I've run into a slight issue on Centos 7. I can mount an IMG file with sudo mount -o loop ..., but I cannot write anything to the mounted image unless I'm root. I've noticed that when I mount the image, the ownership of the mount point changes to root:root. I'm not an expert at *NIX, but not a newbie, either. Somewhere in the middle. But I'm sure I'm overlooking something here. I shouldn't have to sudo every time I want to write to a floppy image. I even tried adding rw to the mount command. No luck. Any and all help appreciated.

Thanks in advance,

business_kid 11-05-2017 12:35 PM

It's heads, the box wins, tails you lose :-/

To use mount -o you need to be root. What root mounts, only root can write to. I have lines like this in /etc/fstab

/dev/sdb1        /mnt/hd          auto              relatime,diratime,user,exec,dev,suid,nofail    0  0
If sdb is there on bootup / mounts it and a luser can't write. But if (as luser) I run

sudo umount /dev/sdb1
mount /dev/sdb1

Any user can write to it. Trust me, it's time to follow a basic motto of sanity

If at first you don't succeed, give up!

hazel 11-05-2017 12:36 PM

If you put the image in fstab with the user option, then anyone can mount it and the files should belong to that user.

LanceK 11-05-2017 06:24 PM

I know about fstab, but these are IMG files of floppies that I want to be able to mount/unmount on the fly. These have to be mounted on the loop device. It works fine, as long as I'm root. I know that only root can mount/unmount, but I find it strange that other users can't have write access to the mounted image. I've tried setting both the mount point and image files to 666, as well as adding my non-root user to the "disk" group, as /dev/loop0 ownership is root:disk. Still no luck. :(

ondoho 11-06-2017 12:52 AM

so you need to do some work on these images.
fire up a terminal, enter this:

su -
now do your work (don't have to prepend sudo to commands anymore).
finished, enter

- all done.
where's the problem.

business_kid 11-06-2017 04:53 AM

Yes, me too. You just have to live with the trade-off between ease of ingress and insecurity. Anyone with a usb drive could hack windows for decades. They're making it inconvenient now, but not difficult. It's not easy in linux.

LanceK 11-06-2017 05:36 PM

I wrote scripts to do what I need.

All times are GMT -5. The time now is 04:42 AM.