Guest User

Untitled

a guest
Jun 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. mkdir sysroot
  2. dd if=/dev/urandom of=sysroot/myfile bs=1024 count=1024
  3. virt-make-fs --format=raw --type=ext2 sysroot sysroot.ext2
  4.  
  5. $ mkdir mnt
  6. $ # mount can deduce "-o loop -t ext2" nowadays.
  7. $ sudo mount sysroot.ext2 mnt
  8. $ # Mount worked fine.
  9. $ cmp mnt/myfile sysroot/myfile
  10. $ losetup
  11. NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
  12. /dev/loop0 0 0 1 0 /home/ciro/sysroot.ext2 0 512
  13. $ # I don't trust userland.
  14. $ cat /sys/devices/virtual/block/loop0/loop/autoclear
  15. 1
  16. $ sudo umount
  17. $ losetp
  18. $
  19.  
  20. $ sudo losetup /dev/loop0 sysroot.ext2
  21. losetup: sysroot.ext2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
  22. $ losetup
  23. NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
  24. /dev/loop0 0 0 0 0 /home/ciro/sysroot.ext2 0 512
  25. $ cat /sys/devices/virtual/block/loop0/loop/autoclear
  26. 0
  27. $ sudo mount /dev/loop0 mnt
  28. $ cmp mnt/myfile sysroot/myfile
  29. $ sudo umount mnt
  30. $ losetup
  31. NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
  32. /dev/loop0 0 0 0 0 /home/ciro/sysroot.ext2 0 512
  33. $ sudo mount /dev/loop0 mnt
  34. $ sudo umount -d mnt
  35. $ losetup
  36.  
  37. sudo mount /dev/loop0 mnt
  38. sudo umount mnt
  39. sudo losetup -d /dev/loop0
  40.  
  41. $ sudo losetup /dev/loop0 sysroot.ext2
  42. $ sudo mount /dev/loop0 mnt
  43. $ cat /sys/devices/virtual/block/loop0/loop/autoclear
  44. 0
  45. $ sudo losetup -d /dev/loop0
  46. $ cat /sys/devices/virtual/block/loop0/loop/autoclear
  47. 1
  48. $ # Still mounted.
  49. $ cmp mnt/myfile sysroot/myfile
  50. $ sudo umount mnt
  51. $ losetup
  52. $
  53.  
  54. sudo strace mount sysroot.ext2 mnt
  55.  
  56. openat(AT_FDCWD, "/dev/loop0", O_RDWR|O_CLOEXEC) = 4
  57. ioctl(4, LOOP_SET_STATUS64, {lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/home/ciro/sysroot.ext2", ...}) = 0
  58. mount("/dev/loop0", "/home/ciro/test/libguestfs/mnt", "ext2", MS_MGC_VAL, NULL) = 0
Add Comment
Please, Sign In to add comment