Quote:
Originally Posted by abhijeetsn
Write a script to list the USB devices mounted on a Linux system?
I am using command "ls -l /dev/disk/by-id/usb*" to find usb mounted on system
|
The entries in /dev/disk/by-id/usb* do
not reflect if they are mounted. These entries show the device, the available partitions on them (if any) and the /dev/xyz entries they can be reached at.
A lot of distro's use automount and this might give the impression that you are looking at mounted entries, which is not the case.
You need to check the ../../sdXY entries shown in /dev/disk/by-id/usb* to the /dev/sdXY entries shown in the output of the mount command to make sure they are actually mounted.
Code:
lrwxrwxrwx 1 root root 9 jul 30 14:26 usb-KDT_410_001A92053B6ABAA0813400B2-0:0 -> ../../sdf
lrwxrwxrwx 1 root root 10 jul 30 14:26 usb-KDT_410_001A92053B6ABAA0813400B2-0:0-part1 -> ../../sdf1
The red entry is the device itself and not of any interest in this case. The green part is.
Code:
mount | grep sdf1
/dev/sdf1 on /mnt type ext3 (rw)
If the above command shows an entry then it is mounted. This also shows you its mountpoint (the blue part), which can be used to list what is on it.
Up to you to try to accomplish this. We are willing to help if you get stuck, but won't do the assignment for you.