Failing to encrypt volume due to it being mapped or mounted












0















I have an Ubuntu 18.04 server VM that I need to encrypt some volumes on. This server has 8 disks attached to it. I'm a Linux newbie so I'm just trying to go with the most straight forward solution for now which seems to be Cryptsetup with LUKS.



I created a keyfile containing a passphrase:



echo -n 'your_passphrase' > /path/to/<keyfile>
chown root:root /path/to/<keyfile>; chmod 400 /path/to/<keyfile>


ran sudo fdisk -l to verify the disks attached so I could find the one I need to encrypt.



I then ran the following command, which if I understanding the docs correctly should encrypt the drive using my keyfile.



sudo cryptsetup luksFormat --type luks2 /dev/sde /tmp/keyfile


I'm getting an error when I try to run this though stating that
Cannot use device /dev/sde which is in use (already mapped or mounted).



This confuses me a bit as I'm not aware of how you would encrypt a drive from a machine if it's not attached to it. Perhaps I'm mixed up in that you can have a drive attached to a VM but not mounted? If that's the case do I need to unmount the drive, run my encryption command and then remount it and use the key to make sure it can be accessed? I appreciate any guidance given, Thanks!










share|improve this question







New contributor




Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I have an Ubuntu 18.04 server VM that I need to encrypt some volumes on. This server has 8 disks attached to it. I'm a Linux newbie so I'm just trying to go with the most straight forward solution for now which seems to be Cryptsetup with LUKS.



    I created a keyfile containing a passphrase:



    echo -n 'your_passphrase' > /path/to/<keyfile>
    chown root:root /path/to/<keyfile>; chmod 400 /path/to/<keyfile>


    ran sudo fdisk -l to verify the disks attached so I could find the one I need to encrypt.



    I then ran the following command, which if I understanding the docs correctly should encrypt the drive using my keyfile.



    sudo cryptsetup luksFormat --type luks2 /dev/sde /tmp/keyfile


    I'm getting an error when I try to run this though stating that
    Cannot use device /dev/sde which is in use (already mapped or mounted).



    This confuses me a bit as I'm not aware of how you would encrypt a drive from a machine if it's not attached to it. Perhaps I'm mixed up in that you can have a drive attached to a VM but not mounted? If that's the case do I need to unmount the drive, run my encryption command and then remount it and use the key to make sure it can be accessed? I appreciate any guidance given, Thanks!










    share|improve this question







    New contributor




    Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I have an Ubuntu 18.04 server VM that I need to encrypt some volumes on. This server has 8 disks attached to it. I'm a Linux newbie so I'm just trying to go with the most straight forward solution for now which seems to be Cryptsetup with LUKS.



      I created a keyfile containing a passphrase:



      echo -n 'your_passphrase' > /path/to/<keyfile>
      chown root:root /path/to/<keyfile>; chmod 400 /path/to/<keyfile>


      ran sudo fdisk -l to verify the disks attached so I could find the one I need to encrypt.



      I then ran the following command, which if I understanding the docs correctly should encrypt the drive using my keyfile.



      sudo cryptsetup luksFormat --type luks2 /dev/sde /tmp/keyfile


      I'm getting an error when I try to run this though stating that
      Cannot use device /dev/sde which is in use (already mapped or mounted).



      This confuses me a bit as I'm not aware of how you would encrypt a drive from a machine if it's not attached to it. Perhaps I'm mixed up in that you can have a drive attached to a VM but not mounted? If that's the case do I need to unmount the drive, run my encryption command and then remount it and use the key to make sure it can be accessed? I appreciate any guidance given, Thanks!










      share|improve this question







      New contributor




      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have an Ubuntu 18.04 server VM that I need to encrypt some volumes on. This server has 8 disks attached to it. I'm a Linux newbie so I'm just trying to go with the most straight forward solution for now which seems to be Cryptsetup with LUKS.



      I created a keyfile containing a passphrase:



      echo -n 'your_passphrase' > /path/to/<keyfile>
      chown root:root /path/to/<keyfile>; chmod 400 /path/to/<keyfile>


      ran sudo fdisk -l to verify the disks attached so I could find the one I need to encrypt.



      I then ran the following command, which if I understanding the docs correctly should encrypt the drive using my keyfile.



      sudo cryptsetup luksFormat --type luks2 /dev/sde /tmp/keyfile


      I'm getting an error when I try to run this though stating that
      Cannot use device /dev/sde which is in use (already mapped or mounted).



      This confuses me a bit as I'm not aware of how you would encrypt a drive from a machine if it's not attached to it. Perhaps I'm mixed up in that you can have a drive attached to a VM but not mounted? If that's the case do I need to unmount the drive, run my encryption command and then remount it and use the key to make sure it can be accessed? I appreciate any guidance given, Thanks!







      encryption luks






      share|improve this question







      New contributor




      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 10 hours ago









      Stavros_SStavros_S

      1011




      1011




      New contributor




      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Stavros_S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Stavros_S is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1122016%2ffailing-to-encrypt-volume-due-to-it-being-mapped-or-mounted%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Stavros_S is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Stavros_S is a new contributor. Be nice, and check out our Code of Conduct.













          Stavros_S is a new contributor. Be nice, and check out our Code of Conduct.












          Stavros_S is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1122016%2ffailing-to-encrypt-volume-due-to-it-being-mapped-or-mounted%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          數位音樂下載

          When can things happen in Etherscan, such as the picture below?

          格利澤436b