Tag Info

Hot answers tagged

13

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"


9

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

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


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


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.


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


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


3

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

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


3

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


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

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


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

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

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

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


2

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


2

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


2

I'm not really sure I inderstand your question correctly. If you are trying to partition VM image, you have several options: use loops or device mapper in linear mode for each partition. You don't need to have these set-up in parallel for formatting; partx/kpartx to tell kernel what partitions it should consider on a loop/device mapper devices or even a ...


2

GNU coreutils cp works because it was written that way. Writing to block devices isn't complicated, it's essentially the same operation as writing to a regular file. However, you shouldn't use cp that way. You can do it if you're sure it's GNU coreutils, which works. But there are other flavours of cp around, for example busybox cp does not support writing ...


2

Well as far as I know, all that cp does is open the target file in write mode write the data from the source file to the target file (not sure about the chunk size though, but that's just details) With normal files, this can result in either creating a new file that will grow with each write call Overwriting an existing file that will be overwritten: ...


2

Your expectation differs from program / system design. What shall we say about that? :-) "Everything is a file"... You could run cp and/or dd through strace -e trace=open and will see that the syscall is the same for both regular files and block devices. If the syscall does not tell them apart, why should cp care?


2

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


1

Take a look and see if there are any mounts using any of the above loopback devices. You can use the mount command to see this: $ mount If they are mounted, they you'll likely need to unmount (umount) them prior to getting losetup -d <loopdevice> to detaching them. $ umount /dev/some/mount As to if it's safe or not, that really depends on what ...



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