LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-01-2015, 08:08 AM   #1
vjlxmi
Member
 
Registered: Aug 2014
Posts: 38

Rep: Reputation: Disabled
how to exclude external disk/usb from fdisk command


fdisk -l command displays all the hard disks in the system.. but I want to exclude the external hard disks and store only the internal hard disk's value in a variable.. Is there a command to do so??

Thankyou
 
Old 07-01-2015, 08:50 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Just run fdisk on the hard disk you want to see information for, like if it is /dev/sdb, then run:
Code:
fdisk -l /dev/sdb
 
Old 07-02-2015, 02:45 AM   #3
vjlxmi
Member
 
Registered: Aug 2014
Posts: 38

Original Poster
Rep: Reputation: Disabled
yeah.. but that is possible only if I know that sdb is an external or internal disk.. Is there a general way to know/identify which disks are internal and which are external??
 
Old 07-02-2015, 02:49 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,841

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
the only way is I think to know which one is built into it - and all the others are external. So you need a list.
 
Old 07-02-2015, 03:18 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Code:
cat /sys/block/sdb/removable
 
1 members found this post helpful.
Old 07-02-2015, 04:18 AM   #6
vjlxmi
Member
 
Registered: Aug 2014
Posts: 38

Original Poster
Rep: Reputation: Disabled
Thank you..
The command gives out value "1" if the disk is external, and value "0" if the disk is internal..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to partitioning the hard disk using fdisk command Prabhu.Are Linux - Desktop 8 12-21-2012 06:32 AM
confusion on listing disk by fdisk -l command ouput. bharatlalgupta Red Hat 2 04-11-2012 04:07 AM
fdisk don't show external usb device soidamientrung Linux - Newbie 7 06-01-2010 09:35 PM
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 12:36 AM
usb controller dies mounting external usb hard disk komasoftware Linux - Hardware 4 11-30-2005 01:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration