Tag Info

Hot answers tagged

15

loop device is a pseudo ("fake") device (actually just a file) that acts as a block-based device. You want to mount a file (disk1.iso) that will act as entire filesystem, so you use loop. The -o comes from the -options. And the last thing, if you want to search for "-o" you need to escape the '-'. Try: man mount | grep "\-o"


10

Traditionally, UNIX systems have had various types of nodes in their filesystems: directory file symlink block device character device FIFO UNIX domain socket While there are now exceptions, generally block devices containing filesystems are mounted on directories. Since you want to mount a file, you must first create a loop block device that is backed ...


8

I don't think you can do it in place but if you have enough space this should work: # Create the files that will hold your data dd if=/dev/zero of=part-00 bs=1M count=4k dd if=/dev/zero of=part-01 bs=1M count=4k # Create the loop devices losetup /dev/loop0 part-00 losetup /dev/loop1 part-01 # Create a RAID array mdadm --create /dev/md0 --level=linear ...


8

If on Linux, when loading the loop module, make sure you pass a max_part option to the module so that the loop devices are partitionable. Check the current value: cat /sys/module/loop/parameters/max_part If it's 0: modprobe -r loop # unload the module modprobe loop max_part=31 To make this setting persistent, add the following line to ...


7

Technically a loop device is a block device that writes to a file, rather than a piece of hardware. So you always use/need to use the loop back device when mounting a file. So much for a direct answer. Maybe this serves as an explanation: The kernel implements several layers of abstraction so that it can treat different hardware the same way. Imagine if ...


7

Create a sparse-file device, using dd. df -hm # to show where we started dd of=sparse-file bs=1k seek=102400 count=0 # creates a 100Meg sparsefile mkfs.ext4 sparse-file mkdir blah mount sparse-file blah cp somefile blah ls -lahts sparse-file # The 's' option will report the actual space taken in the first column ls -lahts blah df -hm # doublecheck my work ...


6

You can do that with the device mapper and its snapshot target. Basically, you'd do the same as what LVM does when you create a writable snapshot. dev=/dev/read-only-device ovl=/path/to/overlay.file newdevname=newdevice size=$(blockdev --getsize -- "$dev") loop=$(losetup -f --show -- "$ovl") printf '%s\n' "0 $size snapshot $dev $loop P 8" | dmsetup ...


6

Parted should be able to read disk image from file and interpret the partition table. So use parted -s disk.img unit s print For my (testing) disk image it gives: # parted -s /root/sdd.img unit s print Model: (file) Disk /root/sdd.img: 16384s Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File ...


5

Make sure you are running mknod -m 660 /dev/loop10 b 7 10. The format is mknod -m 660 /dev/loop<ID> b 7 <ID> where ID is the same. Update [07/10/2014] I also found a good blog post to always have more at boot. See https://yeri.be/xen-failed-to-find-an-unused-loop-device


5

That's just grub2's loop device feature. grub is able to read a number of filesystems and in addition to that to nest them, in that it is able to read files (an initrd and linux kernel above) inside a filesystem inside a file inside another file system. I has nothing to do with linux loop devices. Grub uses it just to load those kernel and initrd files in ...


5

I think this is obvious, but typeset -i M=1 while [ $M -le 102 ] do mount mysourcedevice$M targetdir$M & let M++ done wait Should do the job. The wait will wait until all sub-processess are finished, before executing the next command.


5

losetup (the command normally used to set them up) will tell you: $ /sbin/losetup --list NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE /dev/loop0 0 0 0 0 /var/tmp/jigdo/debian-7.6.0-amd64-CD-1.iso Note that with older versions you may hat to use use -a instead of --list, and this outputs in a different and now deprecated ...


4

With recent kernels (≥ 2.6.37), see Petr Uzel's answer. With older kernels, this length limit is inherent. Strace shows that losetup -a obtains the name through the LOOP_GET_STATUS ioctl, which calls loop_get_status_old, which gets its data from a struct loop_info. The name field in that kernel data structure is limited to LO_NAME_SIZE = 64 bytes. (There's ...


4

This should be a comment to mrb's answer. But I am not allowed to add comments, so adding this as another answer. We can use the following dd command for the 100GB image creation to save some time. dd if=/dev/zero of=/mnt/hetzner_backup/backup-fs.image bs=1024 count=0 seek=$[1024*1024*100] This finishes in a fraction of a second, while the one in mrb's ...


4

Mount your network location with whichever protocol you're using: # smbfs example: mount -o username=your_hetzner_username //server.or.ip.addr/sharename /mnt/server-mountpoint Create an ext2fs image (or another filesystem, if you prefer) inside a file on that share. Do this only the first time, as it wipes the data in backup-fs.image: # create a 1000 MB ...


4

Maybe a threaded version could be a bit faster, you've to adjust the mount() parameters yourself. #include <stdio.h> #include <pthread.h> #include <sys/mount.h> #include <string.h> #include <errno.h> #define DEVS 100 static void *mountt(void *d) { int i = (int)d; char loop[48], mp[48]; snprintf(loop, 47, ...


3

It's possible to do with fuse, but would probably be cleaner with custom tools. Solution With apt-get-able tools the following kludge is possible: mkdir mnt xmount --in dd --out vdi disk.img mnt mkdir mnt2 vdfuse -f mnt/disk.vdi mkdir mnt3 fuseext2 -o "rw" mnt2/Partition1 mnt3 Explanation The basic idea is that fuse can be used to separate a full ...


3

GRUB 2 is able to mount ISOs in loopback. This is not relevant to to-be-loaded OS.


3

losetup /dev/loop0 file -o 1048576 --sizelimit limit Offset specified should be in bytes (1048576 = 2048 sectors * 512 bytes per sector). mount -o loop,offset=1048576,sizelimit=limit For more information see losetup and mount.


3

The long way around. But for the fun of it: 1. Create a temporary image: $ truncate -s64MiB tmp.img 2. Create two partitions using fdisk: Rather detailed, but OK. $ fdisk tmp.img First partition: : n <Enter> : <Enter> (p) : <Enter> (1) : <Enter> (2048) : +40M <Enter> Second partition: : n <Enter> : ...


3

From http://stackoverflow.com/questions/10832350/howto-find-the-file-for-a-loopmounted-device: From losetup(8) man page If only the loopdev argument is given, the status of the corresponding loop device is shown. So you only need to use $ losetup /dev/loop1 /dev/loop1: [0802]:4751362 (/volumes/jfs.dsk) If you have a recent kernel (2.6.37 or ...


3

By your question, I presume that you either have default xtables policies of DROP on your chains, or you have explicit DROP/REJECT rules near the end of your chains. Any ACCEPT rules must come before these. Rule examples: -A INPUT -i lo -j ACCEPT # accept any traffic coming from lo. -A OUTPUT -o lo -j ACCEPT # accept any traffic sent to lo. If you want ...


3

You'll want to do something more like this: for i in $(cat /tmp/10218.after) do grep $(echo ${i} | cut -f1) /tmp/10218.before done If you want to get a bit more fancy and output something if the grep fails you cand do something like: for i in $(cat /tmp/10218.after) do COUNT=grep -c $(echo ${i} | cut -f1) /tmp/10218.before if [[ ${COUNT} ...


3

In bash while read -r word do grep -q "$word" file.before if [ $? -ne "0" ] then echo "$word not in file" fi done < <(cut -f1 -d" " file.after) The -q to grep tells it to be quiet, you can then interrogate $? to see if there was a match 0 or not 1.


3

What you want to do could be accomplished using Device Mapper (to be configured via dmsetup(8)). If the data in the two files is really a linear dump of your volume, you could create a DM device composed of several block devices which you could create from the files from loop-devices, similar to this: # losetup /dev/loop0 /path/to/Backup-LUN-itmp-lun-0.000 ...


3

Use losetup's --list option: $ losetup --list /dev/loop0 NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE /dev/loop0 0 0 0 0 /tmp/backing-file If you only want the file, use the -O option to pick the column: losetup --list -O BACK-FILE /dev/loop0 | tail -n 1 /tmp/backing-file This option is part of recent versions of util-linux. ...


2

I'm not sure how GRUB comes into this, as you don't explain the connection, but you can increase the number of simultaneously usable loop devices using the loop module. modprobe loop max_loop=64 You can then manually make more loop devices with mknod like so: mknod -m 660 /dev/loop8 b 7 8


2

There is no specific command that may stop the file to be mounted several times with different mountpoints, but you may use this script to not mount it if it is already mounted: #!/bin/bash mount |grep -qF "$1" || mount "$1" $2 -o loop the first parameter is a file to mount, and second is a mount point to use.


2

Since kernel 2.6.37, you can look up the name of underlying file (without the length limitation) via /sys/block/loopX/loop/backing_file. The losetup command supports this method since util-linux 2.19.


2

Routing table → device → device driver (loopback) UPD. (2012-10-20): Recently ran into sysctl's doc.: «… accept_local - BOOLEAN Accept packets with local source addresses. In combination with suitable routing, this can be used to direct packets between two local interfaces over the wire and have them accepted properly. rp_filter must ...



Only top voted, non community-wiki answers of a minimum length are eligible