LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2016, 03:53 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
Learning Linux: Unable to touch file in newly mounted filesystem


Here is what I did:

-Create an image file
-put a filesystem on it, ext4
-mount it to a mount point directory using a loop device
-then cd into the mount point
-touch a file, text.txt <<=== I was denied permission to touch a file.

But when I looked at the ownership permission at mount point, mntpoint, the current user can do rwx.

Below are the sequential command line operations:
Quote:
user1@localhost ~/lflab $ ls
user1@localhost ~/lflab $ dd if=/dev/zero of=imagefile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 7.06019 s, 152 MB/s
user1@localhost ~/lflab $ ls -alh
total 1.1G
drwxr-xr-x 2 user1 user1 4.0K Apr 14 14:32 .
drwxr-xr-x 103 user1 user1 4.0K Apr 14 14:07 ..
-rw-r--r-- 1 user1 user1 1.0G Apr 14 14:32 imagefile
user1@localhost ~/lflab $ mkfs.ext4 imagefile
mke2fs 1.42.9 (4-Feb-2014)
imagefile is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

user1@localhost ~/lflab $ mkdir mntpoint
user1@localhost ~/lflab $ ls -alh
total 33M
drwxr-xr-x 3 user1 user1 4.0K Apr 14 14:37 .
drwxr-xr-x 103 user1 user1 4.0K Apr 14 14:07 ..
-rw-r--r-- 1 user1 user1 1.0G Apr 14 14:35 imagefile
drwxr-xr-x 2 user1 user1 4.0K Apr 14 14:37 mntpoint
user1@localhost ~/lflab $ cd mntpoint/
user1@localhost ~/lflab/mntpoint $ ls
user1@localhost ~/lflab/mntpoint $ cd ..
user1@localhost ~/lflab $ sudo mount -o loop imagefile mntpoint/
user1@localhost ~/lflab $ cd mntpoint/
user1@localhost ~/lflab/mntpoint $ ls
lost+found
user1@localhost ~/lflab/mntpoint $ ls -alh
total 24K
drwxr-xr-x 3 root root 4.0K Apr 14 14:35 .
drwxr-xr-x 3 user1 user1 4.0K Apr 14 14:37 ..
drwx------ 2 root root 16K Apr 14 14:35 lost+found
user1@localhost ~/lflab/mntpoint $ touch text.txt
touch: cannot touch ‘text.txt’: Permission denied
user1@localhost ~/lflab/mntpoint $ cd ..
user1@localhost ~/lflab $ ls -alh
total 33M
drwxr-xr-x 3 user1 user1 4.0K Apr 14 14:37 .
drwxr-xr-x 103 user1 user1 4.0K Apr 14 14:07 ..
-rw-r--r-- 1 user1 user1 1.0G Apr 14 14:40 imagefile
drwxr-xr-x 3 root root 4.0K Apr 14 14:35 mntpoint
user1@localhost ~/lflab $
Please advice?
Thank you.
 
Old 04-14-2016, 03:59 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Code:
user1@localhost ~/lflab $ ls -alh
total 33M
drwxr-xr-x 3 user1 user1 4.0K Apr 14 14:37 .
drwxr-xr-x 103 user1 user1 4.0K Apr 14 14:07 ..
-rw-r--r-- 1 user1 user1 1.0G Apr 14 14:40 imagefile
drwxr-xr-x 3 root root 4.0K Apr 14 14:35 mntpoint
You highlighted the owner permissions in the output, but user1 is not the owner of the directory, root is. user1 would qualify as "other", which is the third set of permissions and is simply "r-x". Since user1 doesn't have write permission in the directory, user1 can't write a file in that directory.

Use sudo to change the ownership or permissions of mntpoint appropriately.
 
1 members found this post helpful.
Old 04-14-2016, 04:26 PM   #3
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
suicidaleggroll :

Thanks.
chown user1 mntpoint/

fixed it.

Just curious, Which part of CO are you in?
 
Old 04-14-2016, 04:31 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
I'm in the Boulder area
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
smarty Warning: touch(): Unable to create file... dussel Linux - Software 2 12-29-2006 06:17 PM
Can Linux reiser filesystem be mounted under Solaris? lyonsd Solaris / OpenSolaris 1 06-06-2005 01:53 AM
unable to write to mounted .img file decaf Linux - General 10 03-21-2005 05:15 PM
Error - can't touch touch: /var/lock - filesystem problem? xanas3712 Linux - Newbie 0 05-10-2004 05:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:14 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