40

What's the FreeBSD variant of Linux's lsblk and blkid?

I want something that provides the same sort of information as lsblk does in the example below:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
/dev/sda      8:0    0 465.8G  0 disk 
├─/dev/sda1   8:1    0  1007K  0 part 
├─/dev/sda2   8:2    0   256M  0 part /boot
├─/dev/sda3   8:3    0   9.8G  0 part [SWAP]
├─/dev/sda4   8:4    0  29.3G  0 part /
├─/dev/sda5   8:5    0  29.3G  0 part /var
├─/dev/sda6   8:6    0 297.6G  0 part /home
└─/dev/sda9   8:9    0  16.3G  0 part 
/dev/sr0     11:0    1  1024M  0 rom  

I've tried running commands like man -k blk and apropos dev. There's devinfo, but I'm not sure if that's what I'm really looking for since it doesn't seem to give me to /dev/<DEVICE> path for the devices listed.

I even tried devstat, but that seems equally unhelpful

EDIT:

All I really need to know is the /dev/<DEVICE> path for each block device connected, and maybe the label of said device (if any); regardless of whether or not they have been mounted yet.

2
  • 1
    I think I may have figured it out... I think camcontrol devlist is probably what I want. Dec 24, 2014 at 21:17
  • lsblk is very essential and FreeBSD shold really consider adapting it.
    – neverMind9
    Jul 2, 2019 at 15:04

6 Answers 6

59

Use geom disk list. This will show all disk-like devices (technically, every instance of GEOM "DISK" class).

For more information: geom | FreeBSD Manual Pages

0
22

From what I can tell, camcontrol devlist is the closest thing to a lsblk variant for FreeBSD. I'm not 100% sure that this is the best method, but its output is very close to what lsblk gives you, if you only care about /dev/<DEV-PATH> and device names:

$ camcontrol devlist
<VBOX HARDDISK 1.0>   at scbus0 target 0 lun 0 (ada0,pass0)
<VBOX CD-ROM 1.0>     at scbus1 target 0 lun 0 (pass1,cd0)

The position of the /dev/DEV-PATH in the output of camcontrol devlist seems to vary. For example, on the FreeBSD wiki, the example camcontrol devlist output on one of the pages lists the devpath for the CD-ROM drive in the opposite order: (cd0,pass0) instead of (pass1,cd0).

I'm not sure if or what the significance of this difference is. So if you aren't familiar with devpaths in *BSD you may need to play around with it a bit in order to get it to work.

0
10

Adding to trasz' answer, geom part list shows the partitions in FreeBSD. Similarly geom md list will get you the "memory disk" devices (similar to some uses of loop mounts in linux which are also listed by lsblk(8) - in other words block devices created by mdconfig(8) on FreeBSD and losetup(8) on linux). See geom(8) for a list of classes (each of which can be listed if the geom class is loaded).

This is not quite the same experience that lsblk(8) and blkid(8) provide in linux, but provides much of the same information. There's no direct linkage from geom(4) instances & providers to mountpoint currently in FreeBSD (cf., mountpoint(1) and findmnt(8) on linux).

4

Give pciconf or kldstat a try.

3
  • 1
    no, I wasn't aware of either of them, but neither of them seem to be what I want. This may just be a case of me being unfamiliar with the naming conventions used by *BSD for devices, but I doubt it. Dec 24, 2014 at 20:24
  • 1
    Log files should also list detected devices, but not sure that will help you. What do you want to achieve ?
    – Uriel
    Dec 24, 2014 at 20:38
  • 1
    Use pciconf -l or pciconf -lv
    – Yvon
    Feb 25, 2019 at 2:22
4

I think gpart list is the closest thing to lsblk. It will show you all devices and their partitions (and a lot of extra information as well).

2

all of the FreeBSD tools are "unreadable", this script mimics lsblk well: https://forums.freebsd.org/threads/lsblk-8-command-for-freebsd.56008/

wget https://forums.freebsd.org/attachments/lsblk-sh-txt.3085/
cp index.html /usr/local/bin/lsblk.sh
chmod +x /usr/local/bin/lsblk.sh
6
  • What do you mean "unreadable", in what way are they unreadable? Nov 8, 2019 at 18:39
  • 1
    I notice that this post is essentially a link to a form post that contains an attachment. Could you instead post the contents of that script here, so that your answer is self-contained? Thank you.
    – Jeff Schaller
    Nov 8, 2019 at 18:44
  • lsblk has a readable form of displaying drive hierarchy, just look at the question. i understand people don't want to look at df / mount and other nauseating tool outputs, and so far this is the best option.
    – user533385
    Nov 21, 2019 at 18:44
  • @user533385 I can't speak for other users, but I'd hardly call df/mount's default output nauseating. Perhaps it's harder to understand at a glance, but then again it's the sort of thing you should take the time to understand irrespective of format. Dec 9, 2019 at 19:47
  • this lsblk script is now also available on ports and can be installed via pkg install lsblk
    – ArtiZirk
    Mar 1, 2020 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .