Esteemed Forum Participants and Lurkers:
=============================================
Linux Mint 8, Mint 10, & Mint 13 LiveDVD systems
I have a drive drawer on my system which is cabled to the SATA-0 channel and which I use to load and remove various hard drives from my system. Adding the powered up drive to the running system is no problem with:
echo "scsi add-single-device 0 0 0 0" > /proc/scsi/scsi
Once the drive is mounted, if it is my "StarTrek" drive as an example, I can access it with:
ls /media/StarTrek
However, in order to remove the drive from the system so that I can replace it with a different drive requires that I know the "Device Name" - sd? where ? is the device letter index - for the drive in order to use the commands:
hdparm -y /dev/sd? <-- Spin down the drive
echo offline > /sys/block/sd?/device/state <-- Prevent the drive from being restarted and remounted
echo 1 > /sys/block/sd?/device/delete <-- Totally remove all traces of the drive from the system
QUESTION:
Since my drive configuration varies, how do I "Quickly & Easily" determine what device name is mapped to SCSI channel 0 0 0 0 or to /media/StarTrek (as an example) for any given system configuration? SDA, SDB, SDC, and SDD are generally reserved for the 4 flash card slots on my MultiMedia interface. The next open letter gets assigned when I load the hard drive, but it depends on what USB drives I have added or removed from the system before I load the hard drive.
Surely there has to be a simple terminal command line to show the map of SCSI Channels or Media Names to Device Names. Thank you for any and all comments, suggestions, and assistance.
Blessings in abundance, all the best, & ENJOY!
Art in Carlisle PA USA
RESOLVED: Find "Device Name" for dynamically loaded drive?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
RESOLVED: Find "Device Name" for dynamically loaded drive?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
BOAT - a hole in the water that you pour money into
LINUX - a hole in your life that you pour TIME into
HP dx2400 Core 2 Duo 8 GB. Mint 13/15/17.x/18.x Mate <on LOCKED SD cards, and Kanguru USB drives> No Hard Drive / No SSD
LINUX - a hole in your life that you pour TIME into
HP dx2400 Core 2 Duo 8 GB. Mint 13/15/17.x/18.x Mate <on LOCKED SD cards, and Kanguru USB drives> No Hard Drive / No SSD
Re: How to: Find "Device Name" for dynamically loaded drive?
Hi Art,
If I understand you correctly, I think the mount command will give you what you want. Just open a terminal and type mount.
If I understand you correctly, I think the mount command will give you what you want. Just open a terminal and type mount.
Re: How to: Find "Device Name" for dynamically loaded drive?
Thank You dwasifar ...So ... Thanks, and Mission Accomplished! Now I can figure out EXACTLY which device name to use in my commands when I want to pull the hard drive out of the drawer.
By the way, is there a 'grep' type of program that actually does use the REAL Regular Expressions? Being able to use the \S (not whitespace) term would be really helpful in allowing for special characters in names.
(EDIT: The command for grep with RegEx is egrep)
Blessings in abundance, all the best, & ENJOY!
Art in Carlisle, PA USA
The mount command has exactly what I need plus a lot extra. I discovered that the 'file' /proc/mounts is mostly the same thing (just 2 extra lines and a slightly different format). I munged around with RegEx, which I haven't used in years, and then discovered that grep doesn't even use RegEx (really). So, then I munged around with grep expressions (GrepEx?) and came up with this:by dwasifar
If I understand you correctly, I think the mount command will give you what you want. Just open a terminal and type mount.
Code: Select all
mint@mint ~ $ mount | egrep -o '^/dev/\w+(\W[[:alnum:]/]+){2}'
/dev/sdc1 on /cdrom
/dev/loop0 on /rofs
/dev/sde1 on /media/HOME
/dev/sdf1 on /media/StarTrek
. . . OR . . .
mint@mint ~ $ egrep -o '^/dev/\w+\W[[:alnum:]/]+' /proc/mounts
/dev/sdc1 /cdrom
/dev/loop0 /rofs
/dev/sde1 /media/HOME
/dev/sdf1 /media/StarTrek
By the way, is there a 'grep' type of program that actually does use the REAL Regular Expressions? Being able to use the \S (not whitespace) term would be really helpful in allowing for special characters in names.
(EDIT: The command for grep with RegEx is egrep)
Blessings in abundance, all the best, & ENJOY!
Art in Carlisle, PA USA
Last edited by Webtest on Wed Aug 08, 2012 9:20 am, edited 1 time in total.
BOAT - a hole in the water that you pour money into
LINUX - a hole in your life that you pour TIME into
HP dx2400 Core 2 Duo 8 GB. Mint 13/15/17.x/18.x Mate <on LOCKED SD cards, and Kanguru USB drives> No Hard Drive / No SSD
LINUX - a hole in your life that you pour TIME into
HP dx2400 Core 2 Duo 8 GB. Mint 13/15/17.x/18.x Mate <on LOCKED SD cards, and Kanguru USB drives> No Hard Drive / No SSD
Re: RESOLVED: Find "Device Name" for dynamically loaded driv
Hello,
if you give the filesystem a name (label; using tune2fs) you can enumerate the corresponding device name (/dev/sdX) using the command 'blkid'.
egrath
if you give the filesystem a name (label; using tune2fs) you can enumerate the corresponding device name (/dev/sdX) using the command 'blkid'.
egrath
Re: RESOLVED: Find "Device Name" for dynamically loaded driv
Esteemed Forum Participants and Lurkers:
========================================
Just to wrap things up, I occasionally add in 2 drives temporarily, and I needed to figure out the mapping from SATA channel number on the motherboard to SCSI channel for the "add-single-device" command. A google search for "linux map sata to scsi" led me to http://www.webmaster-forums.net/server- ... -sata-port where Natcoweb.com posted about the lsscsi command which lists all installed scsi port type devices. Of course, lsscsi is not avaiable in Mint distros, so it has to be installed first. So, if you want to map your SATA ports to SCSI "Host - Bus - Target - LogicaUnitNumber", you have to either make a lucky guess, or plug a drive into each channel and look at either /var/log/dmesg (the command "dmesg" achieves this, but the log is very long) or run lsscsi (which gives a perfect list). Here are typical results on my system. Note that "Host 4" is my factory installed multimedia panel where I insert my Boot device ... a locked SD card:
The bottom line is that I now have my SATA ports mapped so that I can dynamically add drives to my system on any vacant SATA channel:
So, now I can add a drive on any SATA port with the following command, where "H B T L" is the SCSI device ID from the above map:
echo "scsi add-single-device H B T L" > /proc/scsi/scsi
As I have posted elsewhere in this forum, if you want to dynamically REMOVE a drive without stopping the system, just replace "sda" in the following with the proper device id from mount, dmesg, or lsscsi:
I hope this might be helpful to anyone else trying to dynamically install and remove hard drives on a system.
Blessings in abundance, all the best, & ENJOY!
Art in Carlisle PA USA
========================================
Just to wrap things up, I occasionally add in 2 drives temporarily, and I needed to figure out the mapping from SATA channel number on the motherboard to SCSI channel for the "add-single-device" command. A google search for "linux map sata to scsi" led me to http://www.webmaster-forums.net/server- ... -sata-port where Natcoweb.com posted about the lsscsi command which lists all installed scsi port type devices. Of course, lsscsi is not avaiable in Mint distros, so it has to be installed first. So, if you want to map your SATA ports to SCSI "Host - Bus - Target - LogicaUnitNumber", you have to either make a lucky guess, or plug a drive into each channel and look at either /var/log/dmesg (the command "dmesg" achieves this, but the log is very long) or run lsscsi (which gives a perfect list). Here are typical results on my system. Note that "Host 4" is my factory installed multimedia panel where I insert my Boot device ... a locked SD card:
Code: Select all
mint ~ # apt-get install lsscsi
. . .
mint ~ # lsscsi
[1:0:0:0] cd/dvd TSSTcorp CDDVDW TS-H653N hb02 /dev/sr0
[1:0:1:0] disk ATA ST3250410AS 3.AA /dev/sda
[4:0:0:0] disk Generic- Compact Flash 1.00 /dev/sdb
[4:0:0:1] disk Generic- SM/xD-Picture 1.00 /dev/sdc
[4:0:0:2] disk Generic- SD/MMC 1.00 /dev/sdd
[4:0:0:3] disk Generic- MS/MS-Pro 1.00 /dev/sde
Code: Select all
H B T L
SATA0 (Dark Blue) - SCSI 0 0 0 0 (Normally, Windows Boot Drive - unpowered)
SATA1 (White) - SCSI 1 0 0 0 (Normallly, CD-ROM)
SATA2 (Light Blue) - SCSI 0 0 1 0 (Normally vacant)
SATA3 (Orange) - SCSI 1 0 1 0 (Normally vacant)
echo "scsi add-single-device H B T L" > /proc/scsi/scsi
As I have posted elsewhere in this forum, if you want to dynamically REMOVE a drive without stopping the system, just replace "sda" in the following with the proper device id from mount, dmesg, or lsscsi:
Code: Select all
hdparm -y /dev/sda (NOTE: daemons can spin the drive back up at ANY time ... even immediately after you issue this command!)
echo offline > /sys/block/sda/device/state
echo 1 > /sys/block/sda/device/delete
Blessings in abundance, all the best, & ENJOY!
Art in Carlisle PA USA
BOAT - a hole in the water that you pour money into
LINUX - a hole in your life that you pour TIME into
HP dx2400 Core 2 Duo 8 GB. Mint 13/15/17.x/18.x Mate <on LOCKED SD cards, and Kanguru USB drives> No Hard Drive / No SSD
LINUX - a hole in your life that you pour TIME into
HP dx2400 Core 2 Duo 8 GB. Mint 13/15/17.x/18.x Mate <on LOCKED SD cards, and Kanguru USB drives> No Hard Drive / No SSD