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:
|-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:
How to use sfdisk command to display boot partition
Type the following command:
# sfdisk -l
# sfdisk -l /dev/sda
Sample outputs:
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
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 6 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
my test on debian, that lsblk -l doesn’t show any boot information, there is no mount point at /boot
You don’t provide how you ran the command, but I think you ran it as your regular user account; use sudo.
nyu@ What about fdisk command?
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.
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.
In my system the command
sudo fdisk -l
produces the output
It falsely reports /dev/sda1 as boot; it is an external not bootable hard disk (formatted as ext4).