Detecting only external hard drives

General support questions
Post Reply
erkutr
Posts: 7
Joined: 2021/07/16 12:11:59

Detecting only external hard drives

Post by erkutr » 2021/07/16 12:21:35

Hi everyone,
I have a project which works on centos 7.It's basically about disk management and i also wanted to show the user the external hard drives.But first i need to detect those devices using commands.Is there a specific command/script that shows only the storage devices among all usb devices.

I know about the "df" command but i can't test that if centos auto-mount the external hard drives when plugged.

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: Detecting only external hard drives

Post by Whoever » 2021/07/17 01:58:40

erkutr wrote:
2021/07/16 12:21:35
Hi everyone,
I have a project which works on centos 7.It's basically about disk management and i also wanted to show the user the external hard drives.But first i need to detect those devices using commands.Is there a specific command/script that shows only the storage devices among all usb devices.

I know about the "df" command but i can't test that if centos auto-mount the external hard drives when plugged.
Have you looked at the command "lsblk"?

erkutr
Posts: 7
Joined: 2021/07/16 12:11:59

Re: Detecting only external hard drives

Post by erkutr » 2021/08/04 13:46:19

Whoever wrote:
2021/07/17 01:58:40
erkutr wrote:
2021/07/16 12:21:35
Hi everyone,
I have a project which works on centos 7.It's basically about disk management and i also wanted to show the user the external hard drives.But first i need to detect those devices using commands.Is there a specific command/script that shows only the storage devices among all usb devices.

I know about the "df" command but i can't test that if centos auto-mount the external hard drives when plugged.
Have you looked at the command "lsblk"?
I know about "lsblk" but i need to distinguish the external hard drive from internal ones.Is there a way?

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: Detecting only external hard drives

Post by Whoever » 2021/08/04 14:28:51

The "external" hard drives are mounted by the desktop system.

If you don't have a desktop running, they won't be mounted. This would identify external drives.

If you do have a desktop running, then you could look at where the drives are mounted and use that to identify external drives,

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Detecting only external hard drives

Post by jlehtone » 2021/08/04 14:47:20

It is hard for a machine to know what is "inside" and what is "outside".

There have been USB, Firewire, eSATA, SCSI external drives. Probably some others too.
(Some SCSI controllers have both internal and external ports.)
You can probably put NVME drive on PCIe outside of case (just like you can have GPU in external box).

GNOME automounts under /media, does it? (But CD/DVD/Bluray might show there too?)

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Detecting only external hard drives

Post by TrevorH » 2021/08/04 16:56:10

You can probably put NVME drive on PCIe outside of case (just like you can have GPU in external box).
Well you can certainly attach them via USB. I see nothing in the output from lshw -class disk to indicate that it's removeable:

Code: Select all

  *-disk
       description: SCSI Disk
       product: SSD 960 EVO
       vendor: Samsung
       physical id: 0.0.0
       bus info: scsi@11:0.0.0
       logical name: /dev/sdd
       version: 0209
       serial: DD564198838A6
       size: 931GiB (1TB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=6 logicalsectorsize=512 sectorsize=4096 signature=000ca4b0
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

erkutr
Posts: 7
Joined: 2021/07/16 12:11:59

Re: Detecting only external hard drives

Post by erkutr » 2021/08/06 13:34:38

TrevorH wrote:
2021/08/04 16:56:10
You can probably put NVME drive on PCIe outside of case (just like you can have GPU in external box).
Well you can certainly attach them via USB. I see nothing in the output from lshw -class disk to indicate that it's removeable:

Code: Select all

  *-disk
       description: SCSI Disk
       product: SSD 960 EVO
       vendor: Samsung
       physical id: 0.0.0
       bus info: scsi@11:0.0.0
       logical name: /dev/sdd
       version: 0209
       serial: DD564198838A6
       size: 931GiB (1TB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=6 logicalsectorsize=512 sectorsize=4096 signature=000ca4b0
This capability parameter actually saved me.I can seperate external storage by this way for my project.
Thank you guys for your help.

erkutr
Posts: 7
Joined: 2021/07/16 12:11:59

Re: Detecting only external hard drives

Post by erkutr » 2021/08/06 13:37:51

Whoever wrote:
2021/08/04 14:28:51
The "external" hard drives are mounted by the desktop system.

If you don't have a desktop running, they won't be mounted. This would identify external drives.

If you do have a desktop running, then you could look at where the drives are mounted and use that to identify external drives,
I use minimal centos 7 and it didnt mount external hard drives that i've tried, and i've tried many.

Post Reply