How to check boot path (partition) in Linux

H

ow do I identify the boot device or boot path in Linux operating system?

 

You can find the boot device or boot path in Linux using any one of the following command:

fdisk command – manipulate disk partition table

sfdisk command – partition table manipulator for Linux.

lsblk command – list block devices.

Open the terminal app or login to the remote server using ssh command. You must be root user.

How to use lsblk to display boot partition

Simply type the following command:

$ lsblk

 

OR

$ lsblk -l

 

OR

$ lsblk /dev/sda

 

Sample outputs:

Fig.01: Linux lsblk command show boot device name

 

The following line (/boot or BOOT) indicates the information about my boot device on Linux:

|-sda1   8:1    1   243M  0 part /boot

How to use fdisk command to display boot partition

Type the following command:

# fdisk -l

# fdisk -l /dev/sda

 

Sample outputs:

Fig.02: Linux fdisk command show boot device name

 

You will find this information at the line starting with Device Boot and marked with *. In this example output, my /dev/sda1 is boot device or partition on Linux.

How to use sfdisk command to display boot partition

Type the following command:

# sfdisk -l

# sfdisk -l /dev/sda

 

Sample outputs:

Fig.03: Linux use sfdisk command show boot device name

A note about multiple devices (HDD/RAID)

If you’ve multiple hard drives or Linux software raid, it is going to be hard to find out this information. Consider the following:

# fdisk -l | grep  ^Disk /dev

 

Sample outputs:

Disk /dev/sdd: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors

Disk /dev/sdc: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors

Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors

Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors

Disk /dev/sde: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors

Disk /dev/md2: 1.5 TiB, 1610636328960 bytes, 3145774080 sectors

Disk /dev/md1: 1.5 GiB, 1602748416 bytes, 3130368 sectors

Disk /dev/md0: 120 GiB, 128877330432 bytes, 251713536 sectors

Disk /dev/md3: 600 GiB, 644257677312 bytes, 1258315776 sectors

Disk /dev/sdf: 492 MiB, 515899392 bytes, 1007616 sectors

Disk /dev/mapper/securebackup: 600 GiB, 644256104448 bytes, 1258312704 sectors

Disk /dev/mapper/cryptvg-mybackup: 600 GiB, 644253483008 bytes, 1258307584 sectors

I’ve multiple disk installed and Linux software RAID devices too. Here is a quick way to find out boot path or partition:

fdisk -l | grep  ^/dev/[a-z]*[0-9]  | awk  $2 ==  *

OR ##

fdisk -l | grep  ^/dev/[a-z]*[0-9]  | awk  $2 ==  *  { print $0}

Sample outputs:

/dev/sdf1  *       62 1006879 1006818 491.6M 83 Linux

/dev/sdf1 is my boot path and to verify the same:

# fdisk -l /dev/sdf

 

Sample outputs:

 

Disk /dev/sdf: 492 MiB, 515899392 bytes, 1007616 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: 0x000e31b0

 

Device     Boot Start     End Sectors   Size Id Type

/dev/sdf1  *       62 1006879 1006818 491.6M 83 Linux

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *