Which Disk a Device Lives on

sco-unixsybase

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 <IBM-DNES-309170-SA30 cyl 11195 alt 2 hd 5 sec 320>
   /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@0,0
1. c0t3d0 <SEAGATE-ST34520N-1206 cyl 9004 alt 2 hd 4 sec 246>
   /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?

Best Answer

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 bytes
Disklabel type: dos
Disk identifier: 0x000bbe80

Device    Boot     Start       End   Blocks  Id System
/dev/sda1 *         2048    206847   102400   7 HPFS/NTFS/exFAT
/dev/sda2         206848 122882047 61337600   7 HPFS/NTFS/exFAT
/dev/sda3      122882048 123906047   512000  83 Linux
/dev/sda4      123906048 234441647 55267800   5 Extended
/dev/sda5      123908096 234440703 55266304  8e Linux LVM


Disk /dev/mapper/fedora-swap: 2 GiB, 2164260864 bytes, 4227072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/fedora-root: 34.1 GiB, 36570136576 bytes, 71426048 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/fedora-home: 16.6 GiB, 17855152128 bytes, 34873344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sdc: 465.8 GiB, 500107859968 bytes, 976773164 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf29eb7a1

Device    Boot Start       End    Blocks  Id System
/dev/sdc1       2048 976768064 488383008+  c W95 FAT32 (LBA)


Disk /dev/mapper/docker-253:1-1064987-pool: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 65536 bytes

Disk /dev/mapper/docker-253:1-1064987-base: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 65536 bytes
[pol@localhost inst]$

and sample of more /proc/diskstats:

[pol@localhost datamodeller]$ more /proc/diskstats 
  11       0 sr0 29 0 232 4629 0 0 0 0 0 4629 4629
   8       0 sda 410458 263717 20392196 10898025 1245895 706584 24393828 59601990 0 10815598 70583361
   8       1 sda1 117 110 1816 3037 0 0 0 0 0 2773 3037
   8       2 sda2 111 110 1768 2632 0 0 0 0 0 2528 2632
   8       3 sda3 246 563 3636 6071 7 1 28 275 0 4779 6346
   8       4 sda4 6 0 30 156 0 0 0 0 0 156 156
   8       5 sda5 409862 262815 20383066 10884215 1066584 706583 24393800 52959483 0 5001674 63942507
 253       0 dm-0 147434 0 1179472 2314861 233219 0 1865752 675534980 0 437014 677849853
 253       1 dm-1 402913 0 16674730 12727464 543716 0 7478728 27512250 0 3889832 40239738
 253       2 dm-2 126146 0 2528176 2158551 1064161 0 15049320 37801569 0 7863269 39960160
  11       1 sr1 0 0 0 0 0 0 0 0 0 0 0
   8      16 sdb 0 0 0 0 0 0 0 0 0 0 0
   8      32 sdc 4698 120153 459862 36086 3 0 3 4 0 12517 36087
   8      33 sdc1 4633 119985 458930 32188 3 0 3 4 0 10451 32189
   7       0 loop0 0 0 0 0 0 0 0 0 0 0 0
   7       1 loop1 0 0 0 0 0 0 0 0 0 0 0
 253       3 dm-3 4412 0 100098 19616 88640 0 1041112 849625 0 46499 869245
 253       4 dm-4 367 0 2936 11243 74438 0 595472 166950100 0 22800 166961349
[pol@localhost datamodeller]$ 

Sample of sudo lshw -class disk -short:

[pol@localhost inst]$ sudo lshw -class disk -short
H/W path                 Device         Class          Description
==================================================================
/0/100/1d.7/1/2/0.0.0    /dev/sdc       disk           500GB External USB 3.0
/0/100/1d.7/1/3/0        /dev/sr1       disk           Mass Storage
/0/100/1d.7/1/3/0/0      /dev/sr1       disk           
/0/100/1d.7/1/3/1        /dev/sdb       disk           SCSI Disk
/0/1/0.0.0               /dev/cdrom     disk           DVD-RAM UJ-850S
/0/1/0.0.0/0             /dev/cdrom     disk           
/0/2/0.0.0               /dev/sda       disk           120GB TOSHIBA MK1234GS

Or a bit more verbose:

[pol@localhost inst]$ sudo lshw -class disk
  *-disk                  
       description: SCSI Disk
       product: External USB 3.0
       vendor: Intenso
       physical id: 0.0.0
       bus info: scsi@67:0.0.0
       logical name: /dev/sdc
       version: 0101
       serial: E1407473
       size: 465GiB (500GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=6 logicalsectorsize=512 sectorsize=512 signature=f29eb7a1
  *-cdrom
       description: SCSI CD-ROM
       product: Mass Storage
       vendor: HUAWEI
       physical id: 0
       bus info: scsi@65:0.0.0
       logical name: /dev/sr1
       version: 2.31
       capabilities: removable audio
       configuration: ansiversion=2 status=ready
     *-medium
          physical id: 0
          logical name: /dev/sr1
          capabilities: partitioned partitioned:mac
  *-disk
       description: SCSI Disk
       physical id: 1
       bus info: scsi@66:0.0.0
       logical name: /dev/sdb
       configuration: logicalsectorsize=512 sectorsize=512
  *-cdrom
       description: DVD-RAM writer
       product: DVD-RAM UJ-850S
       vendor: MATSHITA
       physical id: 0.0.0
       bus info: scsi@0:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/sr0
       version: 1.20
       capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
       configuration: ansiversion=5 status=ready
     *-medium
          physical id: 0
          logical name: /dev/cdrom
  *-disk
       description: ATA Disk
       product: TOSHIBA MK1234GS
       vendor: Toshiba
       physical id: 0.0.0
       bus info: scsi@2:0.0.0
       logical name: /dev/sda
       version: AH00
       serial: X6PHF4EUS
       size: 111GiB (120GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=000bbe80
[pol@localhost inst]$

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).

[EDIT2].

filefrag - report on file fragmentation.

stat - display file or file system status.

pvs - report information about physical volumes.

dmsetup - low level logical volume management.

For RAID devices, you might want to look at md/mdmon/mdadm /proc/mdstat. md - Multiple Device driver aka Linux Software RAID.

[EDIT3]

From here and here, it appears that SCO Unix has very little to do with SunOS 5/Solaris. I assume that you are in fact using Solaris of some sort - SunOS hasn't been released under that name for more than 2 decades.

When you say "database device" - do you mean the data files or the server software itself? What RDBMS are you using? Maybe your RDBMS's documentation could help in this regard? And/or newsgroups/lists specialising in that particular server?

I'm afraid I don't have a working version of Solaris to hand (soon - I mean to challenge myself! :-)). I Googled "Solaris which disk is a file on" and found several links which might be useful. Also, check out @mustaccio 's post and this link in it.

I do mean to get into ZFS (are you using that?) and all of this (horribly complex) disk config stuff in "proper" Unix :-), but that's all the help I can be at the moment I'm afraid.