HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Which Disk a Device Lives on?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
whichdevicedisklives

Problem

I would like to know which Disk a database device is being stored. When I use "format" command in SCO Unix command line, it shows that the system has two disks (Disk 0 and Disk 1). They are:

0. c0t0d0 
   /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@0,0
1. c0t3d0 
   /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@3,0


When I check my database using sp_helpdb, I find that its data is in "sybdbs" and its transaction log is in "syblogs". And then when I use sp_helpdevice to check, I find these:

device_name physical_name
----------- ------------------
sybdbs      /dev/rdsk/c0t0d0s1
syblogs     /dev/rdsk/c0t3d0s4


I have used "df /dev/rdsk" command and "df -F ufs" command and confirm that they are in local disks, not in network shared folders.

I would like to know which Disk that /dev/rdsk/c0t0d0s1 is on, and which Disk that /dev/rdsk/c0t3d0s4 is on. How do I do this?

Solution

The best thing to do to resolve your question is to run the lsblk command. Without any arguments, it gives a great tree view of the system's block devices (see below). Check the man page (lsblk(8)).

Then, use df -h on your file of interest (in this example, it's the MySQL server). df -ah gives more information - in this case, the mount point and the filesystem.

[pol@localhost inst]$ df -ah ./bin/mysqld
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-home   17G   16G  189M  99% /home
[pol@localhost inst]$


So, this tells us that mysqld is mounted on /home on the logical volume /dev/mapper/fedora-home. By checking the output of lsblk, it can be seen (check below) that it's on the sd5 partition of the sda device.

[EDIT - I've added new commands - and I'm giving this question a +1, since I've learnt a truckload trying to answer all of its possiblities! Check out the threads here (1, 2)]

[EDIT2]

Doing yet more exploring, I found these two threads (1, 2) - if you really want to get "down and dirty" with your file system :-). I won't list the output of all the commands found in them - just show some of the interesting ones (hopefully from your perspective). Search for the section also marked [EDIT2] below.

[EDIT3]

Check the end of this post for information I could find on SunOS/Solaris. Search for the section marked [EDIT3].

===============================

Sample output of df -h Note that without specifying the file, it gives the result for the entire operating system, but not the entire computer. I also have a Windows OS on the same machine, which does appear with the lsblk command.

[pol@localhost inst]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   34G   31G 1015M  97% /
devtmpfs                 994M     0  994M   0% /dev
tmpfs                   1002M   12M  990M   2% /dev/shm
tmpfs                   1002M  9.0M  993M   1% /run
tmpfs                   1002M     0 1002M   0% /sys/fs/cgroup
tmpfs                   1002M  308K 1001M   1% /tmp
/dev/mapper/fedora-home   17G   16G  193M  99% /home
/dev/sda3                477M  141M  307M  32% /boot
/dev/sdc1                466G   53G  414G  12% /run/media/pol/INTENSO
[pol@localhost inst]$ df -h /home
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-home   17G   16G  193M  99% /home
[pol@localhost inst]$ df -h /bin
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   34G   31G 1015M  97% /
[pol@localhost inst]$


So, in your particular case, you want:

`df -h  /dev/rdsk/c0t0d0s1`


and

`df -h  /dev/rdsk/c0t3d0s4`


For logical volumes, use the lvs command - as detailled in this post for more info.

i.e.

sudo lvs -o +devices /dev/rdsk/c0t3d0s4 &c.

Sample on my CentOS system:

sudo lvs -o +devices /dev/mapper/fedora-root 
[sudo] password for pol: 
  LV   VG     Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert Devices        
  root fedora -wi-ao---- 34.06g                                              /dev/sda5(4773)
[pol@localhost inst]$


So, /dev/mapper/fedora-root is on sda5.

On further investigation, I also found this thread and found 3 futher commands.

You could also look at the output of

`sudo fdisk -l`


and

`more /proc/diskstats`


And lshw -class disk -short or (verbose) lshw -class disk

Sample of lsblk output (really nice tree output!):

[pol@localhost inst]$ lsblk 
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                             8:0    0 111.8G  0 disk 
├─sda1                          8:1    0   100M  0 part 
├─sda2                          8:2    0  58.5G  0 part 
├─sda3                          8:3    0   500M  0 part /boot
├─sda4                          8:4    0     1K  0 part 
└─sda5                          8:5    0  52.7G  0 part 
  ├─fedora-swap               253:0    0     2G  0 lvm  [SWAP]
  ├─fedora-root               253:1    0  34.1G  0 lvm  /
  └─fedora-home               253:2    0  16.6G  0 lvm  /home
sdc                             8:32   0 465.8G  0 disk 
└─sdc1                          8:33   0 465.8G  0 part /run/media/pol/INTENSO
sr0                            11:0    1   1.5G  0 rom  
sr1                            11:1    1    97M  0 rom  
loop0                           7:0    0   100G  0 loop 
└─docker-253:1-1064987-pool   253:3    0   100G  0 dm   
  └─docker-253:1-1064987-base 253:4    0    10G  0 dm   
loop1                           7:1    0     2G  0 loop 
└─docker-253:1-1064987-pool   253:3    0   100G  0 dm   
  └─docker-253:1-1064987-base 253:4    0    10G  0 dm   
[pol@localhost inst]$


Sample of sudo fdisk -l:

```
[pol@localhost inst]$ sudo fdisk -l

Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512

Code Snippets

[pol@localhost inst]$ df -ah ./bin/mysqld
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-home   17G   16G  189M  99% /home
[pol@localhost inst]$
[pol@localhost inst]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   34G   31G 1015M  97% /
devtmpfs                 994M     0  994M   0% /dev
tmpfs                   1002M   12M  990M   2% /dev/shm
tmpfs                   1002M  9.0M  993M   1% /run
tmpfs                   1002M     0 1002M   0% /sys/fs/cgroup
tmpfs                   1002M  308K 1001M   1% /tmp
/dev/mapper/fedora-home   17G   16G  193M  99% /home
/dev/sda3                477M  141M  307M  32% /boot
/dev/sdc1                466G   53G  414G  12% /run/media/pol/INTENSO
[pol@localhost inst]$ df -h /home
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-home   17G   16G  193M  99% /home
[pol@localhost inst]$ df -h /bin
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   34G   31G 1015M  97% /
[pol@localhost inst]$
`df -h  /dev/rdsk/c0t0d0s1`
`df -h  /dev/rdsk/c0t3d0s4`
sudo lvs -o +devices /dev/mapper/fedora-root 
[sudo] password for pol: 
  LV   VG     Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert Devices        
  root fedora -wi-ao---- 34.06g                                              /dev/sda5(4773)
[pol@localhost inst]$

Context

StackExchange Database Administrators Q#104511, answer score: 4

Revisions (0)

No revisions yet.