Linux question

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
uglyoldbob
Member
Member
Posts: 62
Joined: Tue Feb 13, 2007 10:46 am

Linux question

Post 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?
I have an 80386SX 20MHz 2MB RAM.
It is my testbed platform. Only has the 3.5" and 5.25" floppy drives.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Linux question

Post 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.. ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
uglyoldbob
Member
Member
Posts: 62
Joined: Tue Feb 13, 2007 10:46 am

Post 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.
I have an 80386SX 20MHz 2MB RAM.
It is my testbed platform. Only has the 3.5" and 5.25" floppy drives.
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Post by nick8325 »

You could try mtools. Your distribution will probably have a package for it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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.
Every good solution is obvious once you've found it.
Post Reply