Get all hardisk list (/dev/sd*)Using command line











up vote
3
down vote

favorite












I need to get all the hardisk connected to my PC like,



 /dev/sda
/dev/sdb
/dev/sdc


later I have to use it in script and monitor using iostat



I alrady found fdisk command, it seems to be hard for me to extract all the device from the output of fdisk using grep.



Is there any simple way ?










share|improve this question




























    up vote
    3
    down vote

    favorite












    I need to get all the hardisk connected to my PC like,



     /dev/sda
    /dev/sdb
    /dev/sdc


    later I have to use it in script and monitor using iostat



    I alrady found fdisk command, it seems to be hard for me to extract all the device from the output of fdisk using grep.



    Is there any simple way ?










    share|improve this question


























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I need to get all the hardisk connected to my PC like,



       /dev/sda
      /dev/sdb
      /dev/sdc


      later I have to use it in script and monitor using iostat



      I alrady found fdisk command, it seems to be hard for me to extract all the device from the output of fdisk using grep.



      Is there any simple way ?










      share|improve this question















      I need to get all the hardisk connected to my PC like,



       /dev/sda
      /dev/sdb
      /dev/sdc


      later I have to use it in script and monitor using iostat



      I alrady found fdisk command, it seems to be hard for me to extract all the device from the output of fdisk using grep.



      Is there any simple way ?







      linux command-line hard-disk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 at 19:39









      Rui F Ribeiro

      38.3k1475126




      38.3k1475126










      asked Apr 1 '15 at 9:56









      Haris

      14128




      14128






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          7
          down vote



          accepted










          easier than fdisk for your purpose is lsblk:



          $ lsblk --nodeps
          NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
          sda 8:0 0 223.6G 0 disk
          sdb 8:16 0 298.1G 0 disk
          sr0 11:0 1 12M 0 rom


          or if you just want the drives:



          $ lsblk --nodeps -n -o name
          sda
          sdb
          sr0





          share|improve this answer





















          • So I have to add /dev/ with the result manually.........?
            – Haris
            Apr 1 '15 at 10:24










          • yes, sorry to make it so hard, it's some homework for you ;-)
            – gogoud
            Apr 1 '15 at 11:09












          • Hi, thanks for reply....I already completed the homework... :-)
            – Haris
            Apr 1 '15 at 11:11




















          up vote
          1
          down vote













          Try this:



          blkid | awk -F":" '{print $1}'





          share|improve this answer





















          • Actually I don’t need partition only device, like sda,sdb,sdc etc
            – Haris
            Apr 1 '15 at 10:10













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          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',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f193776%2fget-all-hardisk-list-dev-sdusing-command-line%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          7
          down vote



          accepted










          easier than fdisk for your purpose is lsblk:



          $ lsblk --nodeps
          NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
          sda 8:0 0 223.6G 0 disk
          sdb 8:16 0 298.1G 0 disk
          sr0 11:0 1 12M 0 rom


          or if you just want the drives:



          $ lsblk --nodeps -n -o name
          sda
          sdb
          sr0





          share|improve this answer





















          • So I have to add /dev/ with the result manually.........?
            – Haris
            Apr 1 '15 at 10:24










          • yes, sorry to make it so hard, it's some homework for you ;-)
            – gogoud
            Apr 1 '15 at 11:09












          • Hi, thanks for reply....I already completed the homework... :-)
            – Haris
            Apr 1 '15 at 11:11

















          up vote
          7
          down vote



          accepted










          easier than fdisk for your purpose is lsblk:



          $ lsblk --nodeps
          NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
          sda 8:0 0 223.6G 0 disk
          sdb 8:16 0 298.1G 0 disk
          sr0 11:0 1 12M 0 rom


          or if you just want the drives:



          $ lsblk --nodeps -n -o name
          sda
          sdb
          sr0





          share|improve this answer





















          • So I have to add /dev/ with the result manually.........?
            – Haris
            Apr 1 '15 at 10:24










          • yes, sorry to make it so hard, it's some homework for you ;-)
            – gogoud
            Apr 1 '15 at 11:09












          • Hi, thanks for reply....I already completed the homework... :-)
            – Haris
            Apr 1 '15 at 11:11















          up vote
          7
          down vote



          accepted







          up vote
          7
          down vote



          accepted






          easier than fdisk for your purpose is lsblk:



          $ lsblk --nodeps
          NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
          sda 8:0 0 223.6G 0 disk
          sdb 8:16 0 298.1G 0 disk
          sr0 11:0 1 12M 0 rom


          or if you just want the drives:



          $ lsblk --nodeps -n -o name
          sda
          sdb
          sr0





          share|improve this answer












          easier than fdisk for your purpose is lsblk:



          $ lsblk --nodeps
          NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
          sda 8:0 0 223.6G 0 disk
          sdb 8:16 0 298.1G 0 disk
          sr0 11:0 1 12M 0 rom


          or if you just want the drives:



          $ lsblk --nodeps -n -o name
          sda
          sdb
          sr0






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 1 '15 at 10:05









          gogoud

          1,690716




          1,690716












          • So I have to add /dev/ with the result manually.........?
            – Haris
            Apr 1 '15 at 10:24










          • yes, sorry to make it so hard, it's some homework for you ;-)
            – gogoud
            Apr 1 '15 at 11:09












          • Hi, thanks for reply....I already completed the homework... :-)
            – Haris
            Apr 1 '15 at 11:11




















          • So I have to add /dev/ with the result manually.........?
            – Haris
            Apr 1 '15 at 10:24










          • yes, sorry to make it so hard, it's some homework for you ;-)
            – gogoud
            Apr 1 '15 at 11:09












          • Hi, thanks for reply....I already completed the homework... :-)
            – Haris
            Apr 1 '15 at 11:11


















          So I have to add /dev/ with the result manually.........?
          – Haris
          Apr 1 '15 at 10:24




          So I have to add /dev/ with the result manually.........?
          – Haris
          Apr 1 '15 at 10:24












          yes, sorry to make it so hard, it's some homework for you ;-)
          – gogoud
          Apr 1 '15 at 11:09






          yes, sorry to make it so hard, it's some homework for you ;-)
          – gogoud
          Apr 1 '15 at 11:09














          Hi, thanks for reply....I already completed the homework... :-)
          – Haris
          Apr 1 '15 at 11:11






          Hi, thanks for reply....I already completed the homework... :-)
          – Haris
          Apr 1 '15 at 11:11














          up vote
          1
          down vote













          Try this:



          blkid | awk -F":" '{print $1}'





          share|improve this answer





















          • Actually I don’t need partition only device, like sda,sdb,sdc etc
            – Haris
            Apr 1 '15 at 10:10

















          up vote
          1
          down vote













          Try this:



          blkid | awk -F":" '{print $1}'





          share|improve this answer





















          • Actually I don’t need partition only device, like sda,sdb,sdc etc
            – Haris
            Apr 1 '15 at 10:10















          up vote
          1
          down vote










          up vote
          1
          down vote









          Try this:



          blkid | awk -F":" '{print $1}'





          share|improve this answer












          Try this:



          blkid | awk -F":" '{print $1}'






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 1 '15 at 10:09









          jcbermu

          3,292719




          3,292719












          • Actually I don’t need partition only device, like sda,sdb,sdc etc
            – Haris
            Apr 1 '15 at 10:10




















          • Actually I don’t need partition only device, like sda,sdb,sdc etc
            – Haris
            Apr 1 '15 at 10:10


















          Actually I don’t need partition only device, like sda,sdb,sdc etc
          – Haris
          Apr 1 '15 at 10:10






          Actually I don’t need partition only device, like sda,sdb,sdc etc
          – Haris
          Apr 1 '15 at 10:10




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f193776%2fget-all-hardisk-list-dev-sdusing-command-line%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

          サソリ

          広島県道265号伴広島線

          Accessing regular linux commands in Huawei's Dopra Linux