Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mkdir sysroot
- dd if=/dev/urandom of=sysroot/myfile bs=1024 count=1024
- virt-make-fs --format=raw --type=ext2 sysroot sysroot.ext2
- $ mkdir mnt
- $ # mount can deduce "-o loop -t ext2" nowadays.
- $ sudo mount sysroot.ext2 mnt
- $ # Mount worked fine.
- $ cmp mnt/myfile sysroot/myfile
- $ losetup
- NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
- /dev/loop0 0 0 1 0 /home/ciro/sysroot.ext2 0 512
- $ # I don't trust userland.
- $ cat /sys/devices/virtual/block/loop0/loop/autoclear
- 1
- $ sudo umount
- $ losetp
- $
- $ sudo losetup /dev/loop0 sysroot.ext2
- losetup: sysroot.ext2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
- $ losetup
- NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
- /dev/loop0 0 0 0 0 /home/ciro/sysroot.ext2 0 512
- $ cat /sys/devices/virtual/block/loop0/loop/autoclear
- 0
- $ sudo mount /dev/loop0 mnt
- $ cmp mnt/myfile sysroot/myfile
- $ sudo umount mnt
- $ losetup
- NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
- /dev/loop0 0 0 0 0 /home/ciro/sysroot.ext2 0 512
- $ sudo mount /dev/loop0 mnt
- $ sudo umount -d mnt
- $ losetup
- sudo mount /dev/loop0 mnt
- sudo umount mnt
- sudo losetup -d /dev/loop0
- $ sudo losetup /dev/loop0 sysroot.ext2
- $ sudo mount /dev/loop0 mnt
- $ cat /sys/devices/virtual/block/loop0/loop/autoclear
- 0
- $ sudo losetup -d /dev/loop0
- $ cat /sys/devices/virtual/block/loop0/loop/autoclear
- 1
- $ # Still mounted.
- $ cmp mnt/myfile sysroot/myfile
- $ sudo umount mnt
- $ losetup
- $
- sudo strace mount sysroot.ext2 mnt
- openat(AT_FDCWD, "/dev/loop0", O_RDWR|O_CLOEXEC) = 4
- ioctl(4, LOOP_SET_STATUS64, {lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/home/ciro/sysroot.ext2", ...}) = 0
- mount("/dev/loop0", "/home/ciro/test/libguestfs/mnt", "ext2", MS_MGC_VAL, NULL) = 0
Add Comment
Please, Sign In to add comment