Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to mount loop device

Status
Not open for further replies.

selena1

Programmer
Apr 7, 2003
69
0
0
Hi.

I've installed linux server (Linux Version 2.6.18-1.2798. fc6) with small /tmp partition (it happens that it is 100% full).

So, I've decided to create my own loop device on /var partition (which is very large) and replace /tmp partition with that new partition on loop device.

I've done these steps:

1)
dd if=/dev/zero of=/var/disk-image count=204800000
2)
mkfs.ext3 -q /var/disk_image
3)
mkdir /virtual_fs
mount -o loop=/dev/loop0 /var/disk-image /virtual_fs

(These last two commands are only for testing and everthing works ok - I see partition with df -h, can read and write to it).

Here is the problem: what line do I need to to put in /etc/fstab so that partition is mounted at startup?
I tried with:

/var/disk-image /virtual_fs ext3 rw,loop,auto 0 0

, and got error on startup:

Mounting local file system: /var/disk_image Permission denied

I also have tried with other options in fstab with same result.

I need to fix this so that I can remove from fstab line for /tmp partition and replace it with line:

/var/disk-image /tmp rw,loop,auto 0 0

Can anybody help me with this?

Thanks!







 
/var/disk-image /virtual_fs ext3 rw,loop,auto 0 0

That line looks correct to me. Does it fail only when you restart the server? what if you run mount:

mount /var/disk-image

after the server has booted. Does that still fail with the error message? or does that work?

What does your entire fstab look like? Could you be mounting it before /var is mounted? or is still read-only?

-d.
 
If I run

mount /var/disk-image

it mounts OK.

After I reboot I got the error:

kernel: audit(1205150270.175:4): avc: denied { read write } for pid=1570 comm="mount" name="disk-image" dev=hda6 ino=26346456 scontext=system_u:system_r:mount_t:s0 tcontext=root:eek:bject_r:var_t:s0 tclass=file

Output of df -ha is:

Filesystem Size Used Avail Use% Mounted on
/dev/hda6 222G 2.6G 208G 2% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/hda1 494M 15M 454M 4% /boot
tmpfs 501M 0 501M 0% /dev/shm
/dev/hda3 996M 34M 911M 4% /opt
/dev/hda5 494M 11M 458M 3% /tmp
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs

My fstab is:

LABEL=/1 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
LABEL=/opt /opt ext3 defaults 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=SWAP-hda2 swap swap defaults 0 0
/var/disk-image /virtual_fs ext3 rw,loop,auto 0 0


"Could you be mounting it before /var is mounted? or is still read-only?"

Maybe you are up to something here?

How can I check this?



 

I am pretty sure your problem is the selinux components are disallowing that mount. I don't know much about the selinux stuff, but a quick google search of:
audit avc denied mount

turned up lots of pointers. It looks like maybe you can run that message though a program called audit2allow and it will create the rule to allow it. I assume you then put that rule somewhere so the selinux components can see it.

I hope that gets you pointed in a direction.

-d.

 
You are up to something here. I had run audit2alloow and got some policy rule. Now I need to find out how to apply that rule. I'll inform you about that.


Thanks!
 
You were right here. I applied rules that I got from audit2llow and everything works great. Only error I get now is when I restart server - unable to umount loop device, device busy. Maybe thats OK, because that is now /tmp partition so it can't be unmounted at that time.

But after restart it is mounted OK.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top