X
    Categories: Linux

3 Simple ways to find Linux current boot disk path.

Some times it’s become necessary to find Linux current boot disk path. The linux Boot disk path can be used for troubleshooting purpose in case of any issues. This Boot partition or path contains the GRUB configuration which is bootloader in Linux.

Basically there are three ways to find Linux current boot disk path.

1.fdisk

It’s become very difficult to find current linux boot disk path  if you have multiple hard-disks installed on the server. e.g. only fdisk -l gives this longer output if you have multiple HDD.

[root@RHEL2 ~]# fdisk -l |grep Disk
Disk /dev/sda: 21.5 GB, 21474836480 bytes
Disk identifier: 0x000542e1
Disk /dev/sdb: 12.9 GB, 12884901888 bytes
Disk identifier: 0xc237894b
Disk /dev/mapper/vg_rhel2-lv_root: 16.7 GB, 16718495744 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_rhel2-lv_swap: 4227 MB, 4227858432 bytes
Disk identifier: 0x00000000
[root@RHEL2 ~]#

To get the one liner output for Linux current boot disk path you need to fine tune the command as below:

[root@RHEL2 ~]# fdisk -l |grep dev|grep "*"
/dev/sda1 * 1 64 512000 83 Linux
[root@RHEL2 ~]#

The “*” in the above output indicates linux current boot disk path which is /dev/sda1.

2.  sfdisk -l : This command also gives longer output as below:

[root@RHEL2 ~]# sfdisk -l

Disk /dev/sda: 2610 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 63- 64- 512000 83 Linux
/dev/sda2 63+ 2610- 2547- 20458496 8e Linux LVM
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty

Disk /dev/sdb: 1566 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sdb1 0+ 6 7- 56196 83 Linux
/dev/sdb2 0 - 0 0 0 Empty
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty

Here also * indicates linux boot partition. so filter out further simply give below command:

[root@RHEL2 ~]# sfdisk -l|grep dev|grep "*"
/dev/sda1 * 0+ 63- 64- 512000 83 Linux
[root@RHEL2 ~]#

3. lsblk or lsblk -l command help us to Linux current boot disk path as below:

[root@RHEL2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─vg_rhel2-lv_root (dm-0) 253:0 0 15.6G 0 lvm /
└─vg_rhel2-lv_swap (dm-1) 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 12G 0 disk
└─sdb1 8:17 0 54.9M 0 part
sr0 11:0 1 3.4G 0 rom

[root@RHEL2 ~]# lsblk -l
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
sda1 8:1 0 500M 0 part /boot
sda2 8:2 0 19.5G 0 part
vg_rhel2-lv_root (dm-0) 253:0 0 15.6G 0 lvm /
vg_rhel2-lv_swap (dm-1) 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 12G 0 disk
sdb1 8:17 0 54.9M 0 part
sr0 11:0 1 3.4G 0 rom
[root@RHEL2 ~]#

 

Related Post