Tag Info

Hot answers tagged

18

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"


12

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


10

This is a classic problem in concurrency: when allocating a resource, you need to atomically determine that the resource is free and reserve it, otherwise another process could reserve the resource between the time you check that it's free and the time you reserve it. Do use losetup's automatic allocation mode (-f), and pass the --show option to make it ...


9

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


9

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


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

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


8

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


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


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

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

You have to create device nodes into /dev with mknod. The device nodes in dev have a type (block, character and so on), a major number and a minor number. You can find out the type and the major number by doing ls -l /dev/loop0: user@foo:/sys# ls -l /dev/loop0 brw-rw---- 1 root disk 7, 0 Oct 8 08:12 /dev/loop0 This means loop device nodes should have the ...


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


5

I figured it out. While I am not sure how the issue with the permission thing is, I can instead shoot first and ask later like this: sudo losetup -f myfile.img ld=$(losetup -j myfile.img | grep -o "/dev/loop[0-9]*") dostuffwith $ld


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

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

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


4

push(){ shuttle push note Chrome \ "Aurora: $1" \ "Battery is at $percent percent" } full=0 while percent=$(acpi | awk '{ print $4}' | sed 's/[,%]//g') do case $percent:$full in (100:1) ;; (100:0) full=1 push 'Battery charged';; (?:*|1?:*|20:*) full=0 ...


3

Splitting a string at a particular character is built into the shell at a very deep level: if you write $var without any surrounding quotes, then it is expanded as follows: Take the value of the var variable. Split this value into a list of fields. The field separator is any character in the value of the IFS variable. If IFS contains whitespace characters, ...


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

Heh, incomplete :) Simply use this script for adding new /dev/loops. Remember for changing numbers, script makes to 63'th loop, starts from 8'th because 0-7 is made by default. Notice, rights are copied from /dev/loop0 :) for i in {8..63}; do if [ -e /dev/loop$i ]; then continue; fi; \ mknod /dev/loop$i b 7 $i; chown --reference=/dev/loop0 /dev/loop$i; \ ...


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.



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