LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 11-05-2017, 11:14 AM   #1
LanceK
LQ Newbie
 
Registered: Nov 2017
Distribution: Centos 7
Posts: 3

Rep: Reputation: Disabled
Question Can only write to mounted IMG file as root.


Hi,

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,
--Lance
 
Old 11-05-2017, 12:35 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,454

Rep: Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342
Certainly.
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
Code:
/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
Code:
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
Quote:
If at first you don't succeed, give up!
 
Old 11-05-2017, 12:36 PM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,680
Blog Entries: 19

Rep: Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492
If you put the image in fstab with the user option, then anyone can mount it and the files should belong to that user.
 
Old 11-05-2017, 06:24 PM   #4
LanceK
LQ Newbie
 
Registered: Nov 2017
Distribution: Centos 7
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-06-2017, 12:52 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
so you need to do some work on these images.
ok.
fire up a terminal, enter this:
Code:
su -
now do your work (don't have to prepend sudo to commands anymore).
finished, enter
Code:
exit
- all done.
where's the problem.
 
Old 11-06-2017, 04:53 AM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,454

Rep: Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342Reputation: 2342
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.
 
Old 11-06-2017, 05:36 PM   #7
LanceK
LQ Newbie
 
Registered: Nov 2017
Distribution: Centos 7
Posts: 3

Original Poster
Rep: Reputation: Disabled
I wrote scripts to do what I need.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I write an IMG file to a HDD? Docky Linux - Newbie 1 10-11-2012 11:01 PM
root unable to write on drive mounted with read/write perrmission aquash2000 Linux - Server 5 07-19-2008 12:20 PM
Mounted a filesystem as root.How does one give write-permission to a user? Mr.DeVillie Linux - Software 4 02-08-2006 07:20 AM
unable to write to mounted .img file decaf Linux - General 10 03-21-2005 05:15 PM
how to write an .img file to floppy? ghostboarder Linux - Newbie 7 09-11-2004 10:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration