Page 1 of 1

Linux question

Posted: Tue Feb 27, 2007 10:53 pm
by uglyoldbob
Is it possible to modify a floppy disk image from linux without calling commands as root?
Right now I use:
losetup /dev/loop0 skeleton.img
sudo mount -t msdos /dev/loop0 /mnt/floppy
sudo cp kernel.bin /mnt/floppy/kernel.bin
sudo umount -d /dev/loop0

Is there a way to do this without doing anything as root?

Re: Linux question

Posted: Tue Feb 27, 2007 11:01 pm
by Brynet-Inc
uglyoldbob wrote:Is it possible to modify a floppy disk image from linux without calling commands as root?
Right now I use:
losetup /dev/loop0 skeleton.img
sudo mount -t msdos /dev/loop0 /mnt/floppy
sudo cp kernel.bin /mnt/floppy/kernel.bin
sudo umount -d /dev/loop0

Is there a way to do this without doing anything as root?
Root access, or being able to su/sudo to the root account (Right group perms) It necessary to be able to write to a device.

Allowing any user to write to a device wouldn't be very sane..

Although the Windows users here wouldn't understand this method of sanity.. ;)

Posted: Tue Feb 27, 2007 11:06 pm
by uglyoldbob
That doesn't surprise me as far as security precautions go. I was just wondering if I could achieve the same thing without using mount and still have a floppy disk image with a filesystem on it.

Posted: Wed Feb 28, 2007 2:34 am
by nick8325
You could try mtools. Your distribution will probably have a package for it.

Posted: Wed Feb 28, 2007 2:48 am
by Solar
The commands losetup and mount are non-optional, because you have to link the image file to a device, and you have to mount that.

But you don't have to su / sudo each time! :shock:

Add the losetup line to wherever your distro allows you to extend the boot process. (Since you only have to do that once.) For Gentoo Linux, that'd be /etc/conf.d/local.start. /dev/loop0 is now added at boot time.

Then add a line to /etc/fstab:

Code: Select all

# <fs>        <mountpoint>  <type>  <options>       <dump/pass>
/dev/loop0    /mnt/image    auto    noauto,users    0 0
Now, users (or Makefiles... ;) ) can mount the image file with "mount /mnt/image", and unmount it again, without root being involved anymore.