0

A normal flash drive gets recognized as /dev/sdX by linux.

What is this raw /dev/sdX is called, specially before mounting.

When it gets mounted it will be like /mountpath/sdX1 if it has one partition right?

What are the terminology here? how we name these?

What are other possibilities? I know sdX is supposed to mean SCSI, but what else can be expected when you attach a flash drive or external hard disk or maybe USB floppy drive/optical drive?

DEKKER
  • 948
  • 8
  • 20

2 Answers2

1

if you look in linux under /dev/disk you will see the following folders

  • by-id/
  • by-label/
  • by-partlabel/
  • by-partuuid/
  • by-path/
  • by-uuid/

mounting a device by name I believe is the convention of just referring to /dev/sdX# and how linux maps more than one disk to sdb and sdc and so on is not reliable.

Instead mount by a more explicit convention, such as by label if you know you haven't labeled other disks with the same label, so for that reason you cannot rely on by-label 100% of the time. I think the most common and most reliable is by-uuid.

the lsblk command is maybe the best tool to recognize disks connected to the system, but out of the box it comes up short. Use the following alias and run lsblk2 and you will get all the needed info to understand what's going on.

alias lsblk2='lsblk -o type,name,label,partlabel,size,fstype,model,serial,wwn,uuid'

then having the uuid to the disk you want to mount, you can then do so.

or see which /dev/sd?# it is linked to then do mount /dev/sd?# /whatever

ron
  • 6,575
1

The files in /dev are special files that represent the block device. These files are created by kernel when the device is connected (udev then creates multiple "user friendly" symlinks for them). You get separate device files for both the disk and partitions. The format/name depends on type of the device, most common are /dev/sdX for SATA/SCSI drives and /dev/nvmenX for NVMe drives (or to be more precise for NVMe namespaces), but other are also possible (/dev/vdX and /dev/xvdX for virtual drives, /dev/hdX for IDE drives, /dev/mmcblkX for eMMC cards etc.).

Partitions are always in format of disk name + number or disk name + p + number if the disk name ends with a number. So first partition will be /dev/sda1 for the sda drive and /dev/nvme0n1p1 for the nvme0n1 NVMe drive (first namespace on it).

You then mount these devices (or to be more precise filesystem on these devices) to a mount point to make content of the device (filesystem) available. Mount point is just a regular (empty) directory. You can name it whatever you want, the mount point name doesn't have to be related to the device at all -- when you mount the device, you specify the mount point like mount /dev/sdxY /my/shiny/little/mountpoint. Some user space tools that do the mounting from GUI use the filesystem label or UUID in the mount point, e.g. /media/<username>/<filesystem label>, but that's just a choice of the tool.