Menu

How to reuse nbd0?

Anonymous
2014-06-27
2014-07-13
  • Anonymous

    Anonymous - 2014-06-27

    Hi,

    to mount an image I use this commands:
    modprobe nbd
    imagemount -d /dev/nbd0 -f /media/Backup/image1.img -r -m /media/MountedImage -t ext4
    It works fine.

    Now I want to switch off the mounted image1 and to mount another image2. How should I proceed?

    I tried:
    umount /media/MountedImage
    imagemount -d /dev/nbd0 -f /media/Backup/image2.img -r -m /media/MountedImage -t ext4
    Result:
    /media/MountedImage is cleared
    imagemont ...: nothing happens, /media/MountedImage remains empty.

    Additionally I tried to delete nbd before this, and then to proceed as described at first. But this is refused:
    modprobe nbd -r => modprobe: FATAL: Module nbd is in use.

    Once having used nbd0, only rebooting the system makes it possible to mount another image ... a little bit unpractical.

    What can I do to switch off or reuse nbd0 and to mount different images on the fly?

    Perhaps a silly question but I'm still a linux beginner just having migrated from XP ...

    Greetings from Bonn, Germany
    wolf

     
    • P

      P - 2014-06-30

      You probably need to kill the imagemount process (kill -HUP $(cat /var/run/imagemount.nbd0.pid) in most instances) after unmounting the first image.

      Let me know if that does not work.

       
  • Anonymous

    Anonymous - 2014-07-10

    Thank you for hint - it works!

    However I used command 'sudo kill $(cat /var/run/imagemount.nbd1.pid)'
    Differences:
    - no options -HUP because I didn't understand them due to missing explanation in man page
    - '/var/run/imagemount.nbd0.pid' didn't exist

    Sorry for late reply ... I'd been out for a couple of days

     
    • P

      P - 2014-07-13

      kill -HUP <pid> is the same as kill -s SIGHUP <pid> or kill -s 1 <pid> - the first form is built in to bash.</pid></pid></pid>

       
  • Anonymous

    Anonymous - 2014-07-12

    Subsequently noticed:

    Isn‘t there a proper regular command to stop nbd instead of this brute force ‚kill'-method?

    With ‚rmmod nbd‘ it‘s the same as with ‚modprobe nbd -r‘: command is refused with error message ‚Module nbd is in use‘.

     
  • P

    P - 2014-07-13

    There is no built in method to stop the device. Sorry.

     

Anonymous
Anonymous

Add attachments
Cancel