How to check boot path (partition) in Linux

in Categories , , , , , last updated January 6, 2016

How 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:

  1. fdisk command – manipulate disk partition table
  2. sfdisk command – partition table manipulator for Linux.
  3. 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:

Linux lsblk command show boot device name
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
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
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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 6 comments/add one below):

6 comment

  1. my test on debian, that lsblk -l doesn’t show any boot information, there is no mount point at /boot

    1. You don’t provide how you ran the command, but I think you ran it as your regular user account; use sudo.

  2. If you don’t have a “/boot” mount point, then you haven’t set up a separate boot partition. You will have booted directly off the root file system, “/”, then.

  3. you can use “fdisk -l | awk ‘/^\/dev\/[a-z]*[0-9]/ && $2 ~ /\*/'” but from what I know, Linux can boots with boot flags on boot partition.

  4. In my system the command
    sudo fdisk -l
    produces the output

    Disk /dev/nvme0n1: 477 GiB, 512110190592 bytes, 1000215216 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: gpt
    Disk identifier: A5F89FA8-01CC-48F0-890F-5B4033C8EAC6
    
    Device             Start        End   Sectors   Size Type
    /dev/nvme0n1p1      2048    1026047   1024000   500M EFI System
    /dev/nvme0n1p2   1026048    1288191    262144   128M Microsoft reserved
    /dev/nvme0n1p3   1288192  200968191 199680000  95.2G Microsoft basic data
    /dev/nvme0n1p4 979740672  980662271    921600   450M Windows recovery environment
    /dev/nvme0n1p5 980662272 1000214527  19552256   9.3G Windows recovery environment
    /dev/nvme0n1p6 200968192  471980031 271011840 129.2G Linux filesystem
    
    Partition table entries are not in disk order.
    
    
    Disk /dev/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 33553920 bytes
    Disklabel type: dos
    Disk identifier: 0x1fc4ae9b
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sda1  *     2048 250066943 250064896 119.2G 83 Linux

    It falsely reports /dev/sda1 as boot; it is an external not bootable hard disk (formatted as ext4).

    Have a question? Post it on our forum!