date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,379,695,526,000
I can't understand why my script, sometimes, won't recognize if my Firefox is running. Analyzing the stdout I could state that this condition (if ps cax | grep firefox > /dev/null) sometimes is skipped even when my Firefox is running. Currently using Xubuntu 18.10 Livecd The script called at startup. #!/bin/bash [[ ...
Ps has -C option without need to grep killall -0 firefox-bin will tell you if firefox-bin process exist by exit code. Without need of pipe and redirection in a raw. Just remove your if ps and leave killall -9 firefox-bin && firefox-bin &> /dev/null &. So if process will not be killed, it wouldn't be started.
Condition sometimes failing to test if a specific process is running or not
1,379,695,526,000
My desktop with i686 CPU is currently running macOS Mavericks and I'm trying to install Fedora 26 i386 via DVD. Unfortunately, when it boots the DVD and I select "Start Fedora-Workstation-Live 26" it returns me this error a couple of seconds later: dracut-pre-udev[358]: rpcbind: /run/rpcbind/rpcbind.lock: No such file...
I have not yet reached a direct answer to this issue, but I believe it's due to the fact the system is using a non-EFI motherboard. I was eventually able to install Fedora using a Netinstall version, however I had several attempts where the system either did not boot from disc or the disc was corrupt. However, during...
Fedora 26 i386 installation fails: "rpcbind.lock: No such file or directory"
1,379,695,526,000
I have a problem with my Linux Mint installation. So I'm thinking of backing up my files from a Linux Mint 17 live disk (which I'm using right now to post this). I'd like to back up my encfs container, but don't know how to do so without mounting it and copy the contents to an external drive. Is this possible, and how...
The directory ~/.zzz_encfs is located in your home directory. In the shell, ~ at the beginning of a path represents your home directory. If your live system mounts filesystems of your disk automatically, check the GUI or run cat /proc/mounts to see where they may be mounted. Usually the mount points are sudirectories ...
Can ENCFS container be mounted from live disk?
1,379,695,526,000
Whilst attempting to install Gentoo on my desktop, I ran into some trouble getting my wireless card to work. This is the card I am using. The modules included with the Live CD didn't detect my card, so I downloaded the drivers from the Rosewill website, and followed the build instructions.. up until it told me to use ...
I don't think it's typical that Live CD's include developer tools such as make and autoconf. Now I realize Gentoo is meant to be built from source but given your situation I think you're options are one of the following: Compile the drivers on another Gentoo system that does have make and then manually copy the kern...
Why is make unavailable on the default Gentoo liveCD?
1,379,695,526,000
After several failed attempts to burn an Ubuntu CD to live boot from (they wouldn't boot, maybe because my CD burning software wouldn't burn slower than 4X speed?), I've managed to get a boot disc working with Puppy linux ("Slacko"). My next task is to figure out how to print. I have an HP PSC2410 printer. The docume...
That error means that python isn't installed. Given you're a novice I'd be inclined to steer you towards either Ubuntu or Linux Mint.
An easier way to print from a live CD than Puppy?
1,379,695,526,000
I made a live.iso by livemedia-creator. I use it to make livecd. However, when I boot it, the disk(/dev/sda) is always controlled by /dev/mapper. I want to make my iso boot without /dev/mapper enabled. Is there any advice please? Thanks in advance.
We can disable device mapper by dracut. | https://man7.org/linux/man-pages/man7/dracut.cmdline.7.html
How to disable device mapper for live.iso?
1,379,695,526,000
I'm running on a fairly old HP Pavilion x360 - 13-a110dx (ENERGY STAR) with the newest BIOS firmware available. It has Intel HD 5500 graphics and 4 GB RAM. I'm currently trying to install ANY linux distribution to it from USB -- I can boot into the live USB just fine, however, whether I try to "Try it Without Installi...
So this is how I fixed it -- Upon booting the Ubuntu Live CD I had to changed the Linux boot parameter to have acpi=off nomodeset debug=. I believe this was overkill as to boot Ubuntu I had to just use acpi=off. Now -- this would disable all of my acpi so I had no battery stats and my computer thought it was in airpla...
Linux Live CD crash after GRUB selection
1,379,695,526,000
Wanted to create a list of all the benefits of always running from a live CD (with or without persistence/as long as personal data is saved on encrypted drive locally)?
Using a live ISO without persistence means the main filesystem is read-only, so nothing can be changed or "broken" permanently. It also means all changes (new files & data) are in ram and lost on reboot/shutdown. Saving your personal data manually could lead to better backup habits... If you have enough ram to use the...
what are the benefits of always running from live cd for data protection? [closed]
1,379,695,526,000
I am trying to understand about the file system of bootable system on CD. For CDs which can only be written once, how exactly does system boot? Aren't there any configuration parameters which need to be changed/added upon every boot? Or are there not folders like tmp which contains the temporary data (although it vani...
This is achieved using union mounts. The two main methods are OverlayFS and aufs. It works like any other file system in the Linux VFS but as part of its configuration will point to two other file systems. As part of the union fs mount configuration will determine where data written to it will go. This is usually to a...
How are Configuration Parameters 'written' on "Read Only" bootable Linux CD/USB, when plugged into any system?
1,379,695,526,000
I'm using Debian 9 Stretch Live from a USB Stick for testing hardware compatibility. The firmeware for the Intel Wireless 2230 was not included in the Live image. Therefore I installed it offline from Binary firmware for Intel Wireless cards with sudo dpkg -i firmware-iwlwifi_20161130-3_all.deb After that I reinsert ...
Normally to get iwlwifi to work you HAVE to reboot. BUT which ISO did you use? The official one which has "main" only? Where did you get it from? Can you provide a link. You could try the unofficial live+non-free, which includes the firmware, from here: https://cdimage.debian.org/cdimage/unofficial/non-free/cd-inclu...
Debian 9 Stretch firmware-iwlwifi unknown host
1,291,477,658,000
I am mounting an ISO file, and looking at this tutorial. They use the command: $ mount -o loop disk1.iso /mnt/disk I'm trying to understand the use of -o loop. I have two questions: When I look at the long man page for mount, it takes time to find that -o option. If I do man mount | grep "-o" I get an error, and whe...
A 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 an entire filesystem, so you use loop. The -o is short for --options. And the last thing, if you want to search for "-o" you need to escape the '-'. Try: man mount | g...
What is a "loop device" when mounting?
1,291,477,658,000
I've read that with qemu-nbd and the network block device kernel module, I can mount a qcow2 image. I haven't seen any tutorials on mounting a qcow2 via a loop device. Is it possible? If not, why? I don't really understand the difference between a qcow2 and an iso.
A loop device just turns a file into a block device. If the file has some special internal mapping of its blocks, the loop device won't translate any of it. qcow2 is special... it has special mapping inside that handles different snapshots of the same blocks stored in different places. If you mount that as a loop devi...
How to mount qcow2 image
1,291,477,658,000
I have a iso file named ubuntu.iso. I can mount it with the command: mount ubuntu.iso /mnt. After mounting it, I can see it from the outout of the command df -h: /dev/loop0 825M 825M 0 100% /mnt. However, if I execute the command mount -o loop ubuntu.iso /mnt, I'll get the same result. As I know, loop device...
Both versions use loop devices, and produce the same result; the short version relies on “cleverness” added to mount in recent years. mount -o loop tells mount explicitly to use a loop device; it leaves the loop device itself up to mount, which will look for an available device, set it up, and use that. (You can speci...
What is the difference between mount and mount -o loop
1,291,477,658,000
I know I can create and use a loopback device like this: # Create the file truncate disk.img --size 2G # Create a filesystem mkfs.ext4 disk.img # Mount to use mount disk.img /mnt # Clean up umount /mnt However in this case the disk image is fixed at 2GB. It's 2GB when it's empty, and it's 2GB when it's full. It will ...
@jordanm's comment nailed it. I assumed that the file size was fixed when I looked at the output of ls -lh disk.img. When I used ls -s disk.img like in @Stephan's answer the real file size is showed. As a test, I created an image file that is larger than my hard drive: truncate test.img -s 1000G And it works just fin...
How to setup a growable loopback device?
1,291,477,658,000
I previously used to create image files using dd, set up a filesystem on them using mkfsand mount them to access them as mounted partitions. Later on, I have seen on the internet that many examples use losetup beforehand to make a loop device entry under /dev, and then mount it. I could not tell why one would practica...
Mounts, typically, must be done on block devices. The loop driver puts a block device front-end onto your data file. If you do a loop mount without losetup then the OS does one in the background. eg $ dd if=/dev/zero of=/tmp/foo bs=1M count=100 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 0.079...
Why does one need a loop device at all?
1,291,477,658,000
According to the following question: What is a "loop device" when mounting? A loop device is a file that acts as a block-based device. While I can understand that conceptually, how is this different from mounting any other file? For example, if I take a dd image of an ext2 filesystem and then mount it, I don't have t...
If you don't have to use the loop option to mount a regular file, it is because mount is detecting this and activating it for you automatically. You used to have to specify it manually.
When mounting, when should I use a loop device?
1,291,477,658,000
Is there a way to take a disk img file that is broken up into parts and mount it as a single loop device?
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 mda...
Mounting multiple img files as single loop device
1,291,477,658,000
I need to create filesystem with just one partition from nothing (/dev/zero). I tried this sequence of commands: dd if=/dev/zero of=mountedImage.img bs=512 count=131072 fdisk mountedImage.img n p 2048 131072 Basically, I need to create 64MB image file filled with zeroes. Then I use fdisk to add a ne...
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 th...
How to create a formatted partition image file from scratch?
1,291,477,658,000
I am trying to mount root and boot partition of Raspbian image: mount -v -o offset="70254592" -t ext4 /mnt/X/raspbian-jessie.img /tmp/raspbian mount -v -o offset="4194304" -t vfat /mnt/X/raspbian-jessie.img /tmp/boot mounting boot, when root is mounted results in: mount: /mnt/X/raspbian-jessie.img: overlapping loop d...
losetup 2.21 -P option losetup -P -f --show my.img Creates one /dev/loopXpY per partition. Advantage: executable pre-installed in many distros (util-linux package). Disadvantage: quite recent option, not present in Ubuntu 14.04, before that just use kpartx: https://unix.stackexchange.com/a/405639/32558 losetup -P aut...
How to mount multiple partitions from disk image simultaneously?
1,291,477,658,000
GNU/Linux has union mount that overlays dirs. So you can mount a writeable dir on top of a read-only dir. When the writeable dir is unmounted the read-only dir is untouched. I am looking for the same functionality for block devices - preferably with the writeable part stored in a file. So I would like to run something...
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 --getsz "$dev") loop=$(losetup -f --show -- "$ovl") printf '%s\n' "0 $size snapsho...
GNU/Linux: overlay block device / stackable block device
1,291,477,658,000
I work a lot with imaged drives, meaning a do a dd-copy of the drive in question and then work on the image instead of the drive itself. For most work, I use kpartx to map the drive's partitions to a device under /dev/mapper/. What I'm wondering here is if there's a way to find which of the mapping belong to which ima...
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 i...
How to find which images belong to which /dev/loop?
1,291,477,658,000
How to add more /dev/loop* devices on Fedora 19? I do: # uname -r 3.11.2-201.fc19.x86_64 # lsmod |grep loop # ls /dev/loop* /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4 /dev/loop5 /dev/loop6 /dev/loop7 /dev/loop-control # modprobe loop max_loop=128 # ls /dev/loop* /dev/loop0 /dev/loop1 /dev/loop2 ...
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 ...
How to add more /dev/loop* devices on Fedora 19
1,291,477,658,000
I am writing some shell scripts to handle some disk image stuff, and I need to use loop devices to access some disk images. However, I am not sure how to properly allocate a loop device without exposing my program to a race condition. I know that I can use losetup -f to get the next unallocated loop device, and then a...
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), a...
How to atomically allocate a loop device?
1,291,477,658,000
Out of curiosity, I would like to know is there a way to find out the source of mounted partition? For example, output of df -h is: /dev/loop1 3M 3M 0 100% /media/loop From this output, I know a loop device of 3M is mounted at /media/loop, but I have no clue to determine the exact location of the /dev/loop1 device....
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 --noheadings -O BACK-FILE /dev/loop0 /tmp/backing-file This option i...
Source path of loop-device
1,291,477,658,000
I'm trying to mount and access a floppy image file in the .ima format (raw dump to floppy, similar to .img) on ArchLinux. This file is part of a set of 30. It is not bootable, but rather a continuation of a set. The purpose is not manipulation for the sake of installation or cloning. I'm interested in the documentatio...
If you can't mount the image you might still be able in some cases to "stream out" some of its data with cpio. Once you've ascertained whether the image is: An image using a supported filesystem and a partition --> mount An image using a supported filesystem and more than one partition --> mount with offset, or use d...
Mounting an old floppy image file (.ima format) - how hard can it be?
1,291,477,658,000
From this answer the solution is to modprobe loop max_loop=64 Which makes me allowed to use 64 loopback devices then mknod -m 660 /dev/loop8 b 7 8 To create the devices. I did this for 8, 9, 10 and 8,9 works but 10 does not. I then tried loopa to loopf and tried to mount a 11th device and i get the error Error: Fai...
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 Update [05/25/2016] I run a CentOS server, and I...
How do I setup more then 10 loopback device?
1,291,477,658,000
I like to create a LVM device where physical volumes are loopback devices. I have read lot of documents and tutorials, like this. Unfortunately all of them are based on the losetup command, which loses its configuration at next reboot. I would make the LVM settings using FSTAB in place of the RC.LOCAL (where the los...
I have found a convenient way to do this: two SystemD services: /mnt/systemd/system/loops-setup.service [Unit] Description=Setup loopback devices DefaultDependencies=no Conflicts=umount.target Requires=lvm2-lvmetad.service mnt-host.mount Before=local-fs.target umount.target After=lvm2-lvmetad.service mnt-host.mount ...
Persistent LVM device with loopback devices by fstab
1,291,477,658,000
Is there a CPU/RAM overhead associated with using loop-mounted images versus using a physical partition under Linux?
On Linux <4.4, there is significant overhead when using loop devices on Linux: data accessed through the loop device has to go through two filesystem layers, each doing its own caching so data ends up cached twice, wasting much memory (the infamous "double cache" issue) Aside from casual use, other alternatives would ...
Overhead of using loop-mounted images under Linux
1,291,477,658,000
I'm doing a study about how CD-ROM can be mounted virtually and all I could find out was mounting using loop devices. mount -o loop disk1.iso /mount-point This is fairly easy. I understand that /dev/sr0 is a block device and it point to some buffer in kernel and the kernel device driver puts the filesystem (ot whatev...
The thing here is that /dev/sr0 is linked to a kernel device driver. That device driver will allow access to a physical CDROM if available through that node; VMWare and VirtualBox emulate hardware as you mention and hence the kernel and device driver think they're communicating with hardware. The /dev/sr0 doesn't poin...
Mount an ISO virtually using /dev/sr0 device
1,291,477,658,000
I have a program which creates partitions and filesystems on a disk. To test it, I have created an image file: dd if=/dev/zero of=disk.img bs=1M count=100 and mounted: sudo losetup /dev/loop0 disk.img The partitioning process seemingly works, I get an error from mkfs: mkfs.vfat: unable to open /dev/loop0p2: No such ...
Try using partprobe(which is part of parted package) or kpartx so kernel will get info about partitions. Mounting / partitioning loopback devices not always causes kernel to re-read partition table. It is common situation when you've got info: Re-reading the partition table failed.: Device or resource busy. The kernel...
Loopdevice partitions do not show up
1,291,477,658,000
A couple of years ago I upgraded my netbook with a larger hard drive. I wanted to retain the contents of the old hard drive in case there was anything I still wanted off it. So I copied the the old hard-drive into a file on the new one: dd if=/dev/sdd5 of=~/fw-disk-image/fw-sdd5-linux-lvm-partition.raw and I wrote/co...
Below is a workaround: given LVM wants a read-write block device, we create one with an overlay block device based on the read-only block device (see this other question). As root: Create a sparse file with the same size as the read-only block device truncate -s`blockdev --getsize64 /dev/loop1` '/tmp/overlay.bin' (e...
Mount a PV image as a readonly loop device (again - it used to work)
1,291,477,658,000
i can include loop module for supporting loop files. loop module supports max_loop option. I've found examples with options loop max_loop 256 . My question, what is maximal supported loop devices? I can't belive, 256 is the hard limit, and creating more than 256 loop devices is impossible. Update: I didn't found nothi...
Before kernel 3.1, you had to set a fixed number of loop devices. Since 3.1 there is /dev/loop-control, and loop devices are allocated dynamically as needed, rather than a fixed number. So rather than having a hundred loop devices you never needed (just in case), it starts out with 0 devices (or an optional min count)...
what is maximum loop devices for linux kernel?
1,291,477,658,000
Using the losetup command, you can turn a regular file into a pretend block device. You can then partition and format it like any other device. Is there some way to make Linux pretend that this "device" has a 4K logical sector size?
Yes it's possible: If you run losetup --help you will notice the option -b, --sector-size I suggest also testing to use the direct-IO option too on the loop block device Here is how I create my loop devices : losetup --sector-size 4096 --direct-io=on $loop_device $diskfile But maybe in your case, only --sector-siz...
Loop device with 4K sectors
1,291,477,658,000
So my setup is like this. $ truncate -s 1T volume $ losetup -f --show volume /dev/loop0 $ mkfs.ext4 /dev/loop0 $ ls -sh volume 1.1G volume $ mount /dev/loop0 /mnt/loop Now I have a 1.1TB volume, as expected. The overhead of ext4 expanded the sparse file to 1.1G, but that's fine. Now to add a file. $ dd if=/dev/urando...
To automatically discard data blocks when they are no longer used, use mount -o discard .... Or you can manually run fstrim. This feature was apparently added to the loop device in Linux 3.2. https://outflux.net/blog/archives/2012/02/15/discard-hole-punching-and-trim/ In the general case, mount -o discard is not gu...
Can losetup be made efficient with sparse files?
1,291,477,658,000
It's a bit indirect, but it's possible to mount a partition with a disk image using mount or losetup's "offset" parameter. I'm looking to be able to use fuse to do the same thing in user space Use Case My use case is building disk images on an autobuild server where the build job is not allowed to have root permissio...
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 fu...
How can I mount partitions in a full disk image (i.e. image with partition table) with fuse?
1,291,477,658,000
I'm trying to figure out a clean and safe way to use loop devices inside of a build script. To the best of my knowledge loop devices are required if you want to (GPT) partition and (FAT32, EXT3) format a sparse file1. Eg: Let's say I have this script: #!/bin/bash set -ex truncate --size 4G target.img sfdisk target.im...
losetup -d disassociates a loop device lazily, so it can be used to remove a loop device as soon as it is no longer used. Instead of trapping, open a file descriptor to the loop device and disassociate it straight away: #!/bin/bash set -ex truncate --size 4G target.img sfdisk target.img < partitions loop_device=$(lose...
Can loop devices be automatically cleaned up when a process exits?
1,291,477,658,000
I have a dedicated Ubuntu server with hetzner.de. hetzner also provides a separate backup space accessible via samba/ftp/sftp/scp. In their support document about backups, the following line is mentioned. "The direct use of rsync is not possible. The backup space can however be locally mounted using smbfs, sshfs or ...
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 ...
creating a device image for a network location
1,291,477,658,000
Here's an Ubuntu How-to about booting from ISO-image on flash. http://ubuntuforums.org/showthread.php?t=1288604 What I don't get is creation of loop-device in GRUB2 prior to booting a kernel: menuentry "Ubuntu" { set isofile="/boot/isos/ubuntu.iso" loopback loop $isofile linux (loop)/casper/vmlinuz boot=...
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. It has nothing to do with linux loop devices. Grub uses it just t...
loop-device: is this a Linux entity or a lower-level one?
1,291,477,658,000
I'm trying to play around with OS development, and I started with a boot loader, where phase 0 loads phase 1 from a file (specified by inode) on an ext4 partition (specified by first LBA). Of course, I need something to boot from, so I grabbed QEMU. Now what? What has worked fine so far is this: truncate -s64M /tmp/So...
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> : <Enter> (p) ...
How can I partition a volume in a regular file without loop?
1,291,477,658,000
I'm trying to setup a Linux system that runs from an LVM-formatted image file. After some tinkering with the initramfs and boot options I managed to make it up and running by mounting the host file system to /run/initramfs/host, losetuping the image to /dev/loop0 and making sure the kernel and udev detect the LVM (and...
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 /old...
Ensure that loopback root and host are unmounted on shutdown
1,291,477,658,000
I'd like to recreate a feature of Mac OS X called sparse bundles (disk images made out of smaller files, making them easy to backup after a small change). For that I'm looking for a way to 'virtually' create a single file made by concatenation of smaller ones (big.file shouldn't use all this space, just link to .fil...
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 ...
Virtual file made out of smaller ones (for mac-like sparse bundle solution)
1,291,477,658,000
I was reading Trouble with understanding the concept of mounting and came across this explanation: By using mount -t iso9660 /dev/cdrom /media/cdrom, you tell the system: "take this very long string of bytes that you have in /dev/cdrom, interpret it as a directory tree in the iso9660 format, and allow me to access i...
Block devices are not normal files, they allow programs like mount to perform special functions on them that are required for it to correctly work. A loop device is a translation device, it translates block file calls into normal filesystem calls to a specific file. You can use losetup to create fully fledged loopback...
Loop mounting files vs mounting directories [duplicate]
1,291,477,658,000
I have to map several loopback devices via dmsetup. I could track which loopback device is mapped to a particular /dev/dm-X device file, but is there an easy way to get this info by the /dev/dm-X itself? dmsetup info was of no help for me here.
The constituent devices are under /sys/block/dm-X/slaves. E.g., $ ls /sys/block/dm-2/slaves/ loop0
Get target device by /dev/dm-X entry
1,291,477,658,000
Goal I'm trying to make a harddisk image from scratch using a file. This includes MBR, partition table, number of partitions, etc. I cannot for the life of me get Linux to mount the partitions I make though. edit: See end of question for update - seems to be related to vboxsf Procedure I've tried many different approa...
If the image file is hosted on a weird filesystem like e.g. vboxsf this could be the problem.
Cannot mount partition made on loop device (which is pointing to a file)
1,291,477,658,000
I have a disk image file I'm trying to mount locally using a loop device. Using parted I can see the image has two partitions, however, I'm not able to mount the first partition and losetup thinks the second partition doesn't exist. Anyone know how I can mount the second partition? /m/sf_VMShare ❯❯❯ sudo losetup /dev/...
How to mount a partition in a full disk image that contains a msdos partition table. Tools: fdisk mount calculator Get the partition layout of the image. sudo fdisk -l -u=sectors /work/loop_test/disk_image.img Example output: Disk /work/loop_test/disk_image.img: 29 MB, 29629952 bytes 255 heads, 63 sectors/track, 3 c...
Can't mount disk image
1,291,477,658,000
I have generated an image file with dd. The image contains two partitions. I created a loop virtual disk: losetup -P /dev/loop0 $image_file. I mounted the two loop created partitions (loop0p1, loop0p2) to two mounting points. My problem is the loop disk is too small for the files I want to add. I looked into the optio...
You cannot do that: the way the loopback device in the Linux kernel works it uses the image file size to operate on it and it won't write beyond it. The only way to achieve what you want is to umount the image, increase its size/repartition it, run resize2fs or whatever FS you're using to resize partitions and then mo...
How to increase the size of a loop virtual disk?
1,291,477,658,000
I have a iscsi disk 2TB large. I make backup of that disk every week. The backup script copies the image of the whole iscsi disk into a file on my NFS. Unfortunately, it does not copy the image in one piece, but splits it into chunks 1TB in size. So in my case, I have two 1TB files (plus one config file): -r--r----- 1...
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/...
mapping a split file to /dev/loop0
1,291,477,658,000
I have multiple external storage-spaces which can be mounted with samba/cifs. Over these spaces I want to create a raid device. My idea was the creation of data files with dd if=/dev/zero of=/extStorages/storage[0..x]/data Now I created loop devices with losetup /dev/loop[0..x] /extStorages/storage[0..x]/data And cr...
I wrote a init.d script which start and stop the volume: #! /bin/sh ### BEGIN INIT INFO # Provides: networkRaid # Required-Start: $network $named $remote_fs $syslog # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: handles the 'network raid' ### END INIT INFO P...
Persistent use of loop block device in mdadm
1,641,448,393,000
I discovered that is not possible to run fsck on a loopback device at boot by the fsck flag inside the fstab file, nor is it possible to accomplish this by manually running fsck when the loop device is mounted. Is there an alternative to check the device at boot time?
I found an elegant and reliable solution. I have writteng a script for then"/etc/initramfs-tools/scripts/local-premount/" boot phase in order to process my loop disk just before the file system mounting. Below the details: Create the script into /etc/initramfs-tools/scripts/local-premount/. Update the initrd.img by t...
Fsck at boot time for loopback device
1,641,448,393,000
Loop devices, i.e. for mounting raw disk images, can be managed without root privileges using udisks. For testing purposes, an image can be created and formatted like so: dd if=/dev/urandom of=img.img bs=1M count=16 mkfs.ext4 img.img And then setup using udisks udisksctl loop-setup -f img.img This creates a loop dev...
I had a detailed look into the udisks2 source code and found the solution there. The devices correctly mounted under user permissions were formatted with old filesystems, like fat. These accept uid= and gid= mount options to set the owner. Udisks automatically sets these options to user and group id of the user that i...
Mount image user-readable with udisks2
1,641,448,393,000
Let's suppose I create a file, map it to /dev/loop0, and create a LUKS partition inside dd if=/dev/zero of=myfile bs=1M count=1000 losetup /dev/loop0 myfile cryptsetup -c aes-cbc-essiv:sha256 -s 256 -v -y luksFormat /dev/loop0 I then open the encrypted partition cryptsetup luksOpen /dev/loop0 myfile Now, I have my ...
From my experience running an encrypted reiserfs with private information you should not put that on an journalling filesystem like ext3. I switched back from ext3 to having the file on an ext2 partition after I had to restore from a backup. Over the years ( I have had this file for 5 years ), I had to run recovery se...
File containing ext filesystem
1,641,448,393,000
I am doing a project in which I need to mount 100+ loop devices and merge it into AUFS mountpoint As an observation, for sequentially mounting 90 loop devices, it takes 25 seconds. I am looking for a solution which will minimize time by mounting loop devices in parallel
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.
Loop Mounting in Parallel
1,641,448,393,000
/dev/sda5 is mounted at / and it's my filesystem piotr@thinkpad:~$ sudo mkdir /home/mpoint piotr@thinkpad:~$ sudo mount /dev/sda5 /home/mpoint so now I can do: piotr@thinkpad:~$ cd /home/mpoint/home/mpoint and when I'm in second mpoint directory, it's empty. My questions are: Why is it possible to "loop" a filesyst...
When mounting a file system one add an extra layer for the system. The mount-point is an absolute path that normally hides the contents of the target. To have a closer look using stat can be of help. I.e: First prepare a test case: # mkdir /mnt/other # echo hi > /mnt/other/hello.txt # cat /mnt/other/hello.txt hi # sta...
Why is it possible to "loop" a filesystem by mounting it to one of its folders?
1,641,448,393,000
When I create a 400MB file called /tmp/foo, then call losetup -f /tmp/foo, this creates a loop device /dev/loop15. If I then partition the loopdevice and format it to contain ext4,ntfs, and fat32 filesystems respectively, then run lsblk, I get the following: loop15 7:15 0 390,6M 0 loop ├─loop15p1 259:8 ...
You need to run losetup with -P/--partscan to tell kernel to scan for partitions on the device, it's not enabled by default for loop devices so the partition device nodes are not created without this option.
Loop partitions disappear on rebind
1,641,448,393,000
I created a file touch /datastore/virtual/pseudoblock created a loop device with it sudo losetup /dev/loop0 /datastore/virtual/pseudoblock (although I got a warning about its size) and then initialized it with random data dd if=/dev/urandom of=/dev/loop0 bs=1M count=100 My questions are a) why is it not displayed ...
You're missing steps about creating a filesystem. dd if=/dev/urandom of=pseudoblock bs=1M count=100 losetup /dev/loop0 pseudoblock Now you can create a filesystem on it. mkfs.ext4 /dev/loop0 Once this is done, I can get an UUID (this identifies the filesystem, so if you haven't created one, you won't get an UUID), a...
Permanently mounting loop device
1,641,448,393,000
I'm using debootstrap to create a rootfs for a device that I want to then write to an image file. To calculate the size needed from my rootfs, I do the following: local SIZE_NEEDED=$(du -sb $CHROOT_DIR|awk '{print $1}') SIZE_NEEDED=$(($SIZE_NEEDED / 1048576 + 50)) # in MB + 50 MB space dd if=/dev/zero of=$ROOTFS_IMAG...
Possibly the simplest solution is to heavily overprovision the space initially, copy all the files, then use resize2fs -M to reduce the size to the minimum this utility can manage. Here's an example: dir=/home/meuh/some/dir rm -f /tmp/image size=$(du -sb $dir/ | awk '{print $1*2}') truncate -s $size /tmp/image mkfs.ex...
How to calculate the correct size of a loopback device filesystem image for debootstrap?
1,641,448,393,000
I'm trying to loop mount my root filesystem (a loop file) within a busybox initramfs. I try to run the command: mount /rootfs.raw /root ... which works on my Ubuntu laptop, however, I simply get mount: mounting /dev/loop0 on /root failed: Invalid argument No matter what combination of options I use, (including loading...
In order to solve this problem, I had to be more verbose about my mounting command. I ended up using: modprobe loop mount -t iso9660 -o loop /bootpart/rootfs.raw /root This worked properly.
busybox initramfs loop mount
1,641,448,393,000
I have a loop device which shows up when I do losetup --all that I have been unable to remove. So, I basically got myself into this issue because a created a raw image of a microSD card and then I used kpartx to mount the partitions contained within the image. The commands that I initially used to mount the image and ...
Since the PPID is 2, this process 10693 is a kernel process, and that explains why your kill -9 did not work. You said you have tried sudo losetup --detach /dev/mapper/loop1. That was almost but not quite correct: try sudo losetup -d /dev/loop1 instead. But it only works after the partition loop devices have already b...
Can't remove or unmount loop device on Debian
1,641,448,393,000
I want to mount the contents of an iso9600 (CD) image via a loop to access its contents. To do so I execute mount -r -t iso9600 -o loop file.iso mountpoint/ and would expect the contents in the (existing) directory mountpoint. However, I get mount: mounting /dev/loop0 on mountpoint/ failed: No such device. What are t...
There are multiple reasons I can think of. Probably the more common one is that something with the loop devices is not in order, e.g., there are too many loop device in use already. You can check if this is the case by setting up the loop device manually: # losetup --find --show file.iso /dev/loop0 # mount -o ro /dev/...
Why does mount -o loop return "No such device"?
1,641,448,393,000
I'm having an issue with loopback. It looks like there is only 8. I did a search and apparently the problem is grub by default only has 8 loopback (devices?). If i look in /dev/ i see loop 0-7 so that does seem to make sense. How do i change the amount of loopbacks?
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 (without a reboot). 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 Make sur...
Grub change loopback amount?
1,641,448,393,000
When mounting a filesystem image via mount -o loop, is there any mechanism to prevent the same file to be mounted a second time?
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.
How to make sure a loopfile is only mounted once?
1,641,448,393,000
To be able to test out of disk situations I tried to set up a file-based size-limited file system like this: $ dd if=/dev/zero of=file.fs bs=1MiB count=1 $ mkfs.ext4 file.fs $ udisksctl loop-setup -f file.fs Mapped file file.fs as /dev/loop1. $ udisksctl mount --options rw -b /dev/loop1 Mounted /dev/loop1 at /medi...
Yeah, that's kind of mean :) But you can work around: mkfs.ext4 takes a -d directory/ option with which you can specify a directory containing an initial content for the file system; if you already know which directories you'll later want to populate, that would be a good place to start. mkfs.xfs supports -p protofile...
Create writable file system using udisksctl
1,641,448,393,000
I tried the process from this post resize partition on an image file. I didn't succeed in understanding why it goes wrong in my case. I produced a 8GB image using dd. The image contains two partitions. I map the image with losetup -P /dev/loop0 $image-file. Then: resize2fs /dev/loop0p2 4000M resize2fs 1.44.1 (24-Mar-2...
Thank you @sudodus and @fra-san. I think there is a compatibility issue when combining resize2fs and parted for shrinking a fs/partition. resize2fs uses 4k blocks, when parted uses Byte or MB, GB etc. I eventually found another way to shrink the 2nd partition: gnome-disks. It is provided with Linux Mint and works pret...
How to shrink a file image, produced with dd?
1,641,448,393,000
By mistake, I deleted an lxc image file. The container is still running and the file is therefore not yet actually deleted until I stop the container. I'd like to avoid stopping the container as it is quite sensitive. I tried to find the deleted file with: for i in $(ls /proc/|grep '^[0-9]*$'); do ls -l /proc/$i/fd|gr...
[not a complete answer, but too long to put in a comment] You can find the inode of a (possibly deleted) backing file of a loop device with the LOOP_GET_STATUS or LOOP_GET_STATUS64 ioctls: it's the .lo_inode field of the loop_info and loop_info64 structs. As I wasn't able to find any command line utility exposing that...
Recover deleted but mounted loop file/filesystem
1,641,448,393,000
in an attempt to access a truecrypt container, I stumbled about the prerequisite of setting up a loop device... ncoghlan suggested in an earlier answer When you run it as root, losetup -f will automatically create loop devices as needed if there aren't any free ones available. So rather than doing it yourself with ...
Serge's comment made me do my homework - study the man page in more depth than before. The solution was simply to enter in the shell losetup (without any arguments). Then, afterwards, losetup -f resulted, successfully, in /dev/loop0
how to add a loop device on fedora 23 with losetup?
1,641,448,393,000
I want to create a loop device myself, I want it to have a special name, say /dev/loop-test-0. I want it to be up after I reboot the machine. I though that I can use mknod for this, but this doesn't seem to work. I look on the other loop device I have in the system and they all look like brw-rw----. 1 root disk 7, ...
A loop device is a particular type of block device, managed by the loop device driver. A loop device is a block device whose content is stored in a file, similar to the way a SCSI disk device is a block device whose content is stored on a SCSI disk, a USB storage device is a block device whose content is stored on a U...
What is the difference between loop device and block device? [closed]
1,641,448,393,000
busybox (at least version 1.7, which I'm bound to use) to not provide the losetup -a switch to obtain a list of currently used loop devices plus the associated filename. Is there any way to obtain such a list with busybox?
From https://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 h...
How to achieve `losetup -a` behaviour with busybox?
1,641,448,393,000
I have backed up a drive with all its partitions using the command dd if=/dev/sda of=/media/oshirowanen/external-drive/backups-2019/full_drive_backup.img /dev/sda is an ssd which has a Linux OS with full encryption. Before I wipe this drive and re-purpose it, I want to make sure the backup has worked. I have tried t...
Judging from the image, the partition seems to be a physical volume. This is verified by pvscan. lvs lists two logical volumes, one of them a swap partition (LV swap_1) it seems, and the other the actual file system (LV root). This is the relevant one, to be mounted by mount -o ro /dev/mapper/ubuntu--vg-root /mnt/img5...
Mounting a Luks partition
1,641,448,393,000
I am trying to set up a virtual drive from a file. This file will then be written to a flash device (not relevant). Because creating and manipulating the virtual drive will be in a script, I need to do it in user space, i.e., not as root. The script is for building and creating an image for a flash device; so, running...
The step you haven't mentioned is how you created the ext4 filesystem, which is the source of the problem. Using mkfs.ext4 /home/user/drive.img will create a root inode owned by root, so when you mount it, it will still belong to root. The solution is to add option -E root_owner to make it belong to the user running ...
Mounting as <user>, a loop still assigns root ownership
1,641,448,393,000
I wish to create a file to loop mount as a root filesystem that grows dynamically as required (up to a limit). The commonly quoted solution to this is to use a sparse file, which would do exactly what I want, however I wish to do this with fat32 / exfat (for compatibility across operating systems) as the host filesyst...
qemu-nbd can be used to bind a qemu image (a grow-on-demand qcow2 image) to a block device, which can then be mounted as a filesystem of choice. With this method however, performance as a root filesystem is very poor, and the image size grows very quickly with the resulting image being 6~7 times larger than an equival...
Creating a grow-on-demand loop filesystem without sparse files
1,514,882,843,000
I have a system that generates embedded Linux systems. The system outputs three files: a tarball containing rootfs excluding the kernel modules a tarball containing the kernel modules uImage The system is deployed on a 1 GB SD card, of which 10 MB is given to a FAT boot partition and the rest to an ext4 root partiti...
If you are sure that the SD card always is of the same size (or greater) as the one you actually have, and the 1G is enough for what you want to copy there, you could proceed as follows: Manually partition an appropriate SD card, but leave the partitions empty (but create the required filesystems on them) Copy the wh...
Creating dual-partition SD card image by a script
1,514,882,843,000
I have an interesting case, where e2fsck refuses to recognize the file system inside a qcow2 image file. Using testdisk I am able to see the partition, so some markers would be left. The reason this problem occurred in the first place was because the host of the virtual machine died. So I choose None as the "type" of ...
Okay, sorry for answering my own question so soon, but I noticed something flabbergasting. The .qcow2 file was of size 120400379904 Bytes, whereas the conversion of the image with qemu-img convert -O raw gave me an image of size 128849018880 Bytes. Quite a difference. Now, if we take the size in sectors found by testd...
How to find alternative superblocks in ext3 file system of partition-less qcow2?
1,514,882,843,000
I am trying to mount a bitlocker encrypted drive with dislocker. Here are the exact commands I ran: sudo dislocker -r -V /dev/sdb7 -u -- /media/bitlocker sudo mount -r -o loop /media/bitlocker/dislocker-file /media/mount After running the last one, I get mount: /media/mount: wrong fs type, bad option, bad superblock ...
I see that you are missing specify the filesystem of your device (this case NTFS). Let's try with this mounting command: sudo mount -t ntfs-3g -r -o loop /media/bitlocker/dislocker-file /media/mount Here are some sample parameters for tag -t: exFAT: exFAT-fuse NTFS: ntfs-3g
Cannot mount dislocker-file loop: wrong fs type, bad option, bad superblock
1,514,882,843,000
Debian 8.2. I want to umount the /dev/loop5 device that I mounted, but I can't. I'm getting the message that /dev/loop5 is not mounted. Could anyone explain to me what I'm doing wrong here, please? touch file mkdir /mnt/partition dd if=/dev/zero of=file bs=1M count=10 losetup /dev/loop5 file mkfs.ext2 /dev/loop5 ...
Because you didn't mount /dev/loop5. mount -oloop SRC MNT means to create a loop device for the file SRC, and then mount that loop device at MNT. Apparently SRC is allowed to be a loop device itself if you really want :). You could have seen this in the output of mount or findmnt; they would show that the loop device...
Debian. Can't umount loop device
1,514,882,843,000
How can I allow the traffic to be sent on the loopback device (lo)? What is the iptables command for it?
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 ...
How is the loopback device traffic allowed?
1,514,882,843,000
I'll start this question by listing all drives available on my system right after the login into my Linux Mint 19.2 Cinnamon: # fdisk -l Disk /dev/loop0: 89,1 MiB, 93454336 bytes, 182528 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512...
The existence of /dev/loop* devices doesn’t necessarily indicate anything; some systems pre-populate them, others don’t. However, if they show up in fdisk -l’s output, that means they’ve been set up to provide a loop device over either a file or another block device. You can see what loop devices are set up, and what ...
Why there are 3 loop devices on my system right after boot?
1,514,882,843,000
I'm working on a huge complex application. You connect a disk, press a button, and it partitions and formats the disk, mounts it, and copies some files onto it. To test this application, we have a test system which loop-mounts a disk image and runs through the same process. Except we changed the application logic, and...
I made a small change to the test framework, and the problem went away. Specifically, rather than calling kpartx -u /dev/vda after I repartition the device, I call kpartx -d followed by kpartx -a. And now everything is fine. Weird...
How does cfdisk fix my disk image?
1,514,882,843,000
Given any file on an ext4 filesystem, it is possible (using filefrag -v) to get the list of real offsets+lengths where that file is located on the underlying block device. Is it safe to open the device and write to them, all that while the filesystem is mounted read-write? Can it cause fs corruption? I'm asking becaus...
If the writes are only to the blocks of the file, then it wouldn't corrupt the ext4 filesystem. However, there is a definitely a bigger risk that some error in the code could corrupt the filesystem, which wouldn't happen with a regular loop device that is only using the file mapping. The question is whether writing d...
Is it safe to write to file's extents directly while the FS is r/w?
1,514,882,843,000
I have created a loop device and added it to /etc/fstab I got its UUID from the output of the blkid command (it does print a UUID for the particular device after running mkfs.ext4 /path/to/loop) However despite the fact that after editing /etc/fstab the command mount -a was successful, the system after the reboot halt...
Only block devices have UUIDs (that can be found). A file is not a block device, the loop device turns it into one. So for the UUID of an image file to be found, the loop device must exist first. However, your fstab entry is a loop mount, i.e. the loop device is only created when you mount it (and immediately removed ...
mounting loop not working with UUID
1,514,882,843,000
I have a file, called "some.img", created with fallocate, that has a filesystem on it. I can mount the img file using mount -o loop some.img /media/where, and I see the filesystem. When I reboot, however, the file is no longer mounted. How do I automatically mount this at boot? Update: SuSE Linux
Essentially, add the following to /etc/fstab: /path/to/file /path/to/mount ext4 loop 0 0 As described in https://superuser.com/questions/799162/permanent-loop-device
How to automatically mount at boot? [duplicate]
1,514,882,843,000
Dir created inside a loop fs denies access, but has correct permissions. init.sh - creates an fs image and mounts it (user and group ids are 1000): #!/bin/bash mkdir -p out-dir dd if=/dev/zero of=out-dir.img bs=1024 count=125 /sbin/mkfs.ext4 out-dir.img guestmount -o uid=$(id -u) -o gid=$(id -g) -a out-dir.img -m/de...
This is the option: -o default_permissions. guestmount --fuse-help: ... -o default_permissions enable permission checking by kernel
guestunmount: can't cd into a dir, but the permissions are ok
1,514,882,843,000
I'm having trouble with this piece of code: 22 for filename in "$( ls "$1" | grep ".*\.flac$" )"; do 23 file_path="$1${filename}" 24 ffmpeg -i "${file_path}" -f ffmetadata $HOME/metadata Instead of a metadata file on each iteration, I'm getting this error message: Downloads/Ariel Pin...
how about for filepath in "$1/"*.flac do ffmpeg -i "${file_path}" -f ... where "$1/"*.flac will garantee .flac suffix in the end be sure to quote "${file_path}" basename can be found using bn=$(basename "${file_path}") un flac'ed basename can be found using bnnf=$(basename "${file_path}" .flac) sample A >...
BASH: looping through ls [duplicate]
1,514,882,843,000
How to add files or directories to the qemu-img created raw disk file. For example. I use qemu-img create -f raw disk.raw 1G to generate a disk.raw file. I want to copy some /bin, /usr directories to the disk.raw file. I have tried the following commands. With the reference to here qemu-img create -f raw disk.raw 1G m...
To mount your /dev/mapper/loop0p1 partition, you must format it first. # mke2fs -t ext4 /dev/mapper/loop0p1 # mount /dev/mapper/loop0p1 /image
How to modify (add files or directories) to the qemu-img created raw disk file?
1,514,882,843,000
I installed a very old Slack version (3.2) on VirtualBox and then converted it to RAW format (ext2). However, for some reason I'm unable to mount it using losetup but qemu-nbd works fine. Why? I tried, losetup -P -f --show slack-3.2.img but it doesn't create partitions. I modified /etc/default/grub so that GRUB_CMDLIN...
read error, sector 0 This indicates trouble of the kernel to access your file and I have the strong suspicion that vboxfs is causing it. I have a long open bug about it not supporting symlinks and hardlinks and I think they only fixed the former. qemu-nbd OTOH will just read the file, so it is fine, but the kernel us...
Raw disk image from VDI file can be mounted using qemu-nbd but not loop device?
1,514,882,843,000
Since the kernel started supporting it, losetup was modified to enable direct IO by default. This can avoid having redundant page cache and also has performance advantages. http://man7.org/linux/man-pages/man8/losetup.8.html --direct-io[=on|off] Enable or disable direct I/O for the backing file. The ...
No, I don't think this has been implemented so far (util-linux v2.31.1). mount and losetup use common code to create loop devices, but the loopcxt_set_dio() function is only called inside the main() function of losetup.c. https://github.com/karelzak/util-linux/search?q=loopcxt_set_dio https://github.com/karelzak/util-...
Does `mount -oloop` use direct IO by default (when the kernel is new enough)?
1,300,135,516,000
I want to determine which process has the other end of a UNIX socket. Specifically, I'm asking about one that was created with socketpair(), though the problem is the same for any UNIX socket. I have a program parent which creates a socketpair(AF_UNIX, SOCK_STREAM, 0, fds), and fork()s. The parent process closes fds...
Since kernel 3.3, it is possible using ss or lsof-4.89 or above — see Stéphane Chazelas's answer. In older versions, according to the author of lsof, it was impossible to find this out: the Linux kernel does not expose this information. Source: 2003 thread on comp.unix.admin. The number shown in /proc/$pid/fd/$fd is ...
Who's got the other end of this unix socketpair?
1,300,135,516,000
I know I can view the open files of a process using lsof at that moment in time on my Linux machine. However, a process can open, alter and close a file so quickly that I won't be able to see it when monitoring it using standard shell scripting (e.g. watch) as explained in "monitor open process files on linux (real-ti...
Running it with strace -e trace=open,openat,close,read,write,connect,accept your-command-here would probably be sufficient. You'll need to use the -o option to put strace's output somewhere other than the console, if the process can print to stderr. If your process forks, you'll also need -f or -ff. Oh, and you might...
How do I monitor opened files of a process in realtime?
1,300,135,516,000
root@host [/home2]# lsof /home2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME php 3182 ctxmortg cwd DIR 8,17 4096 32858196 /home2/ctxmortg/public_html/hello php 3182 ctxmortg 3r REG 8,17 46404 55781766 /home2/ctxmortg/public_html/hello/cache/subprimemortgagemorgag...
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME webalizer 32342 ctxmortg 5uW REG 8,17 12288 32890954 /home2/ctxmortg/tmp/webalizer/eyebestdatedotcomauph.ctxmortgagemortgagerefi.com/dns_cache.db FD - File Descriptor If you are looking for file being written, look for following flag # - The ...
How to interpret this output of lsof command?
1,300,135,516,000
Hi I have many files that have been deleted but for some reason the disk space associated with the deleted files is unable to be utilized until I explicitly kill the process for the file taking the disk space $ lsof /tmp/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME cron 1623 root 5u REG 0,...
On unices, filenames are just pointers (inodes) that point to the memory where the file resides (which can be a hard drive or even a RAM-backed filesystem). Each file records the number of links to it: the links can be either the filename (plural, if there are multiple hard links to the same file), and also every time...
Best way to free disk space from deleted files that are held open
1,300,135,516,000
Is there a way to make lsof work continuously to monitor every file that is being opened in real time? I don't know the name of the process. I want lsof to work continuously for a period of time until I see the the list contains what I want.
I believe since you do not know the file name/process id, you could specify user name option as below. lsof -r 2 -u username The "-r 2" option puts lsof in repeat mode, with updates every 2 seconds. (Ctrl -c quits) The "-u' option can be used to keep an eye on a users activity. If you know the directory name unde...
Monitoring files continuously with lsof
1,300,135,516,000
In many cases lsof is not installed on the machines that I have to work with, but the "function" of lsof would be needed very much (for example on AIX). :\ Are there any lsof like applications in the non-Windows world? For example, I need to know which processes use the /home/username directory?
I know of fuser, see if it's available on your system.
Alternatives for "lsof" command?
1,300,135,516,000
Commands, for instance sed, are programs and programs are codified logic inside a file and these files are somewhere on the hard disk. However when commands are being run, a copy of their files from the hard disk is put into the RAM, where they come to life and can do stuff and are called processes. Processes can make...
However when commands are being run, a copy of their files from the hard disk is put into the RAM, This is wrong (in general). When a program is executed (thru execve(2)...) the process (running that program) is changing its virtual address space and the kernel is reconfiguring the MMU for that purpose. Read also ab...
Are files opened by processes loaded into RAM?
1,300,135,516,000
Is there any way to find some process which is periodically writing to disk (according to hdd led) on FreeBSD 10 with ZFS (maybe turn ZFS into verbose logging mode)? lsof and other instantly aggregating statistics utilities seems not able to catch anything due to a short time of a moment of a disk access.
DTrace is able to report on vfs information in FreeBSD (as well as a raft of other probes). DTrace is enabled by default in the 10 kernel so all you need to do is load the module then run the dtrace script. Load the DTrace module kldload dtraceall Get the vfssnoop.d script from the FreeBSD forums. The whole thread ...
FreeBSD 10 trace disk activity
1,300,135,516,000
I want to move large file created by external process as soon as it's closed. Is this test command correct? if lsof "/file/name" then # file is open, don't touch it! else if [ 1 -eq $? ] then # file is closed mv /file/name /other/file/name else ...
From the lsof man page Lsof returns a one (1) if any error was detected, including the failure to locate command names, file names, Internet addresses or files, login names, NFS files, PIDs, PGIDs, or UIDs it was asked to list. If the -V option is specified, lsof will indicate the search i...
Move file but only if it's closed
1,300,135,516,000
Consider this simple scenario: I open a text file ~/textfile.txt with vim in one terminal (tried with both edit and read-only modes). In a different terminal, I run /usr/sbin/lsof ~/textfile.txt Get no results Why?
When you use vi/vim to edit a file you aren't actually holding ~/<filename>open you are reading the file into ~/.<filename>.swp and then holding that temp file open. If you run lsof ~/.<filename>.swp it will show you the information you are looking for. NOTE: If you have multiple people editing the same file you will ...
lsof doesn't return files open by the same user
1,300,135,516,000
I want to extract the process id of a certain process in order to shut it down. The process is a local web server using a certain port (localhost:3000), and I am currently doing it like this to extract the relevant line: lsof|grep localhost:3000 but the lsof command is too slow. Is there a faster way to extract the p...
Try netstat, I cannot say whether its faster or slower, however. netstat -tanp | awk '$4 ~ /:8443$/ {sub(/\/.*/, "", $7); print $7}' | sort -u
Faster alternatives to lsof
1,300,135,516,000
On my CentOS 7, at one point, sudo ss -plt listed a port marked as LISTENING on *:30565, but there was no information whatsoever in the process column of its row. The other listening ports were showing their owning process as usual, like users:(("sshd",pid=1381,fd=3)), but that one row did not have any process informa...
The point on netstat not showing the process information on some situations, for instance NFS, is that NFS is a kernel module, and as such, it does not run as a normal process, and does not have a PID. You can regularly find threads about this situation if including NFS on your google searches: netstat doesn't report ...
"netstat -p"/"ss -p" not showing the process of a listening port
1,300,135,516,000
I want to know if my server establishes a connection to a remote server or if the remote server tries to reach my server. I tried to read the output of lsof and obtain this information: lsof -i TCP:25 USER FD TYPE DEVICE SIZE/OFF NODE NAME master 2657 root 12u IPv4 8086 0t0 TCP *:smtp (LISTE...
I think the clue is in the port numbers, take these two entries smtpd 12950 postfix 9u IPv4 35762406 0t0 TCP hostname:smtp->spe.cif.ic.IP:55277 (ESTABLISHED) smtp 13007 postfix 13u IPv4 35762309 0t0 TCP hostname:34434->fake.VVVVV.fr:smtp (ESTABLISHED) smtpd has received a connection on port sm...
How to use lsof to identify incoming TCP connections?
1,300,135,516,000
I was using lsof to track down deleted files that were still taking up space and I realized that I wasn't quite sure what an offset is with respect to a file. lsof's man page was less than helpful in this regard and searching around I couldn't get a clear picture of what it is. What is a file offset and why is it usef...
The offset is the current position in the file, as maintained by the kernel for a given file description (see the lseek(2) and open(2) manpages for details). As to why it's useful in lsof's output, I'm not really sure. It can give some idea of a process's progress through a file, although it won't cover all cases (mem...
What exactly is a file offset in lsof output?
1,300,135,516,000
I've been getting some suggestions on how to figure out why my serial port is busy. Specifically, when I try to start gammu-smsd, it refuses to start on /dev/ttyS0 because it says that port is busy: sudo /etc/init.d/gammu-smsd start Sep 30 16:16:51 porkypig gammu-smsd[25355]: Starting phone communication... Sep 30 16:...
The short answer is: screen. The slightly longer answer is that the -m flag to fuser tells it to list everything using the mountpoint. Depending on your setup, that probably means all of /dev, but it could also be /. Clearly not what you intended. You'll get a very long list if you do fuser -vm /dev/ttyS0, over 60 lin...
fuser vs lsof to check files in use