Code: Select all
losetup /dev/loop0 image
mount /dev/loop0 tmp
cp kernel tmp/
umount tmp
losetup -d /dev/loop0
Any suggestion?
Code: Select all
losetup /dev/loop0 image
mount /dev/loop0 tmp
cp kernel tmp/
umount tmp
losetup -d /dev/loop0
Code: Select all
dd if=/dev/zero of=floppy.img bs=512 count=2880
sudo losetup /dev/loop0 floppy.img
sudo mkfs -t ext2 floppy.img
sudo losetup -d /dev/loop0
Code: Select all
/home/$USER/floppy.img /mnt/wherever ext2 loop,users 0 0
Oops. Yeah. It's not chown you need, it's a file in /etc/udev/rules.d .AlfaOmega08 wrote:Ok, the fstab thing works good, but the losetup still needs "sudo". Changing the group to loop0 didn't change anythings as it changes back to root:disk after a try. Even if I add myself to group disk, it still says "Permission denied". I'm on Ubuntu 11.10...
Code: Select all
KERNEL=="loop[0-9]*", GROUP="loop"
It depends on your loop device usage patterns. It probably works well in AlfaOmega's case, where there's one image that's getting mounted alot, but in my case I have a fair number of images, with each individual one not being mounted very frequently (and quite a few being deleted after a few uses), and I have a feeling that my fstab would get cluttered with image files quite quickly. So I just have a few generic loop device entries in fstab, loop device ownership set to root:loop, and myself in loop.Solar wrote:Gosh, what do they teach the kids these days?
1) Generate and format image file.
2) Add to /etc/fstab:Code: Select all
dd if=/dev/zero of=floppy.img bs=512 count=2880 sudo losetup /dev/loop0 floppy.img sudo mkfs -t ext2 floppy.img sudo losetup -d /dev/loop0
Code: Select all
/home/$USER/floppy.img /mnt/wherever ext2 loop,users 0 0
Well, it's possible (whether wise or not) to get around the "sudo" part of "sudo losetup" there. The initial losetup does have to be done, whether with sudo or not.3) Use "mount /mnt/wherever" and "umount /mnt/wherever" at your leisure, no need for "losetup" anymore.
In case you're looking for a way around the initial "sudo losetup", that won't work.
In the OP's case you're probably right, and your solution is probably better. In my own case I feel that I'm avoiding more than a single sudo. If I break my system I give you permission to mock me mercilessly, but it hasn't happened yet.Solar wrote:Guys, step down before you hurt yourselves. You don't poke around in UDEV rules in order to avoid one single sudo.