27

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.

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

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

17

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.

9

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.

  • 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. – Alexej Magura Dec 24 '14 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 '14 at 20:38
  • 1
    Use pciconf -l or pciconf -lv – Yvon Feb 25 at 2:22
3

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.