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 ...


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

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 ...


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

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 ...


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.


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

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 ...


2

On a very basic level, it's a device that's implemented purely in software. Similar to the way that a VM is entirely software, so is the loopback (although using quite different mechanisms). Ordinarily when an interface sends a packet it eventually is put to the wire and flushed. The loopback on the other hand, instead of being put to the wire the outgoing ...


2

One way to do this would be to make each file an LVM physical volume, and join those physical volumes in a volume group and make an LVM logical volume using that space. But it's cumbersome: you need to associate the file with a loop device. dd if=/dev/zero of=0.file bs=1024k count=4 losetup /dev/loop0 0.file pvcreate /dev/loop0 # … repeat for all parts … ...


2

In case somebody has the same problem: All I needed was to move the mount point of the host file system to a place outside the root file system in the shutdown script (that's fine, because it runs in a tmpfs pivot root) before any unmounting takes place: mount --move /oldroot/run/initramfs/host /host This allows /oldroot to unmount cleanly. The host file ...



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