Linux mount which device

How do I figure out which /dev is a USB flash drive?

I want to mount a USB drive, two of them and I need two different mount points. Unfortunately, the Linux kernel underwent a name change and I can’t figure out which /dev location is the right one. Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive. (I’m using ArchLinux if that helps any. /dev/sda is the first hard drive, /dev/sr0 is a dvd drive, etc.) edit: The USB drive is connected to a USB hub. I looked through dmesg and it says the hub was connected and it scanned for the 3 devices connected to it. Still can’t see where my USB drive is though.

Can’t see it? Maybe wait for a bit. Or try another USB port. See what differences there is in ‘lsusb’

13 Answers 13

Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.

dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb .

Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!

All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:

which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).

Читайте также:  Полное имя компьютера linux

No, it doesn’t magically mount your device. You have to specify it with mount /dev/id /mount/point , so that doesn’t work.

My answer addresses the user’s question ‘Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.’, and is not intended to provide guidance on the practicality of mounting a drive under Linux.

As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.

Here’s a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays «/dev/sde«, while readlink -e /root/disk3 produces no output whatsoever.

Try the command udevinfo -q all -n /dev/sda , where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you’re looking at — there’s an entry that tells you about the bus it’s connected to.

This of course saves you from having to grep through dmesg and/or logs.

udevadm info --query=all -n /dev/sda 

From at least Jul 2010 [1] udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:

In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.

Источник

Читайте также:  Пользователь www data linux

How do I check where devices are mounted?

What is the command that lets me see what and where devices are mounted? I’m having trouble changing songs on my old iPod, and I have a feeling it’s because of the mount point.

3 Answers 3

There are at least three programs I know of that list device mount points:

    mount — mount a filesystem (used for general mount info too):

$ mount /dev/sda3 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) . /dev/mapper/lvmg-homelvm on /home type btrfs (rw,relatime,compress=lzo,space_cache) /dev/sda5 on /home/muru/arch type btrfs (rw,relatime,compress=lzo,space_cache) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd) 
$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 30832636 11993480 17249912 42% / none 4 0 4 0% /sys/fs/cgroup . /dev/sda5 31457280 3948600 25396496 14% /home/bro3886/arch 
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 100M 0 part ├─sda2 8:2 0 58.5G 0 part ├─sda3 8:3 0 30G 0 part / ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 30G 0 part ├─sda6 8:6 0 339.2G 0 part │ └─lvmg-homelvm (dm-0) 252:0 0 1.2T 0 lvm └─sda7 8:7 0 8G 0 part [SWAP] sdb 8:16 0 931.5G 0 disk └─sdb1 8:17 0 931.5G 0 part └─lvmg-homelvm (dm-0) 252:0 0 1.2T 0 lvm 

Of these three, mount lists all the mountpoints, AFAICT. The others have their weaknesses.

    findmnt suggested by @webwurst is now my favourite tool for the job. It’s a Swiss Army knife when it comes to output control (newer versions can output in JSON too):

$ findmnt / TARGET SOURCE FSTYPE OPTIONS / /dev/sda1 ext4 rw,relatime,errors=remount-ro,data=ordered $ findmnt / -no source /dev/sda1 $ findmnt / --json < "filesystems": [ ] > $ findmnt / --df SOURCE FSTYPE SIZE USED AVAIL USE% TARGET /dev/sda1 ext4 40.2G 25.8G 12.5G 64% / 

Источник

How do I find on which physical device a folder is located?

Specifically: I did sudo mkdir /work , and would like to verify it indeed sits on my harddrive and not mapped to some other drive. How do I check where this folder is physically located?

Читайте также:  Удалить ненужные пакеты линукс

4 Answers 4

The df(1) command will tell you the device that a file or directory is on:

The first field has the device that the file or directory is on.

$ df /root Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 1043289 194300 795977 20% / 

If the device is a logical volume, you will need to determine which block device(s) the logical volume is on. For this, you can use the lvs(8) command:

# df /usr Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/orthanc-usr 8256952 4578000 3259524 59% /usr # lvs -o +devices /dev/mapper/orthanc-usr LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices usr orthanc -wi-ao 8.00g /dev/sda3(0) 

The last column tells you that the logical volume usr in the volume group orthanc ( /dev/mapper/orthanc-usr ) is on the device /dev/sda3 . Since a volume group can span multiple physical volumes, you may find that you have multiple devices listed.

Another type of logical block device is a md (Multiple Devices, and used to be called meta-disk I think) device, such as /dev/md2 . To look at the components of a md device, you can use mdadm —detail or look in /proc/mdstat

# df /srv Filesystem 1K-blocks Used Available Use% Mounted on /dev/md2 956626436 199340344 757286092 21% /srv # mdadm --detail /dev/md2 . details elided. Number Major Minor RaidDevice State 0 8 3 0 active sync /dev/sda3 1 8 19 1 active sync /dev/sdb3 

You can see that /dev/md2 is on the /dev/sda3 and /dev/sdb3 devices.

There are other methods that block devices can be nested (fuse, loopback filesystems) that will have their own methods for determining the underlying block device, and you can even nest multiple layers so you have to work your way down. You’ll have to take each case as it comes.

Источник

Оцените статью
Adblock
detector