FreeBSD Challenge: Day 10 of 30

Tonight I decided to hit my trust scout master FreeBSD Handbook.  In tonight’s chapter of “Free BSD Bedtime Stories,” I take a look at working with disks and hardware inside your system.  Intrigued?  Amused?  Still laughing at my attempt to use BSD?  Great!

Working with devices

asfdasfsf

As with Linux, which is Unix-like, to a degree, files are stored in directories, file names are case sensitive, and ‘rm -rf *’ is still a death penalty.  Underneath a folder, follows the typically hierarchy, just as does Linux, but the way you interact with files, disks, and hardware is slightly different.  Though, it is true, that several ports of Linux utilities can be installed for BSD as well.  In fact, as many know, many of the utilities Linux uses, come straight from its Unix heritage.

One thing in particular that is nice about FreeBSD, is the ‘growfs‘ command utility.  The basic syntax for this is as follows:


growfs -s <size> /dev/device_name

Suppose, I wanted to grow the size of the device “ada0p1.”  The command is as simple as:

growfs -s 2G /dev/ada0p1

Simple right?  ‘growfs’ is an invaluable too, but please use it with caution.  If you wish to test the resizing before hand, you can use the -N option.  Keep in mind that FreeBSD currently follows UFS, a testament to its Unix roots.  It is important to recognize this fact.

Slices of awesome

FreeBSD refers to its partitions as “slices,” which is a little different from what you could be accustomed to as a Linux user.  Each disk carries a label standard, some of which you will see are a  bit different from Linux is.  IDE disks come labelled “ad,” SCSI disks “da” (which includes SATA disks), and ATAPI IDE CDROM’s as “acd.”  Had enough of spelling class yet? When referring a disk name, such as ad0s1a, the  “a” denotes the first partition on the first slice (s1) and on the disk “ad0.”  Following ok?

Once I had my device names down ok,  I took a look at mounting a USB device.  Wait a minute,  why does ‘lsusb’ work?  Hmm, remember, you are in another world.  A quick dig through the FreeBSD site brought me to ‘pciconf’, which lists PCI and USB devices.  There is a port of lsusb in the ports tree, but I have so far tried to stick to BSD utilities for core activities.

Thanks to a handy tech republic article that points out command “translations” between FreeBSD and Linux, I got the output I wanted with ‘pciconf -lv’.  The extra v option will give you the hand verbose output you need to determine the device you wish to find.  ‘usbconfig’ will also show some handy information as well.

Essentially I landed on a couple utilities to view and manage devices:

camcontrol devlist

‘camcontrol’ shows devices connected to, you guessed it, the CAM (Common Access  Method) subsystem.

In this example, I see my hard drive is labled as “ada0”:


[root@VM_FreeBSD ~]# 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 (cd0,pass1)
usbconfig

usbconfig will show a basic output of your currently connected USB device, basic output, but still useful.


[root@VM_FreeBSD ~]# usbconfig
ugen0.1: <OHCI root HUB Apple> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen0.2: <Mass Storage Device JetFlash> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)

pciconf -v

A handy utility as well, ‘pciconf’ has a nice standardized view for listing your PCI and USB devices:


[root@VM_FreeBSD ~]# pciconf -lv | tail
subclass   = audio
ohci0@pci0:0:6:0:    class=0x0c0310 card=0x00000000 chip=0x003f106b rev=0x00 hdr=0x00
vendor     = 'Apple Computer Inc.'
device     = 'KeyLargo/Intrepid USB'
class      = serial bus
subclass   = USB
none0@pci0:0:7:0:    class=0x068000 card=0x00000000 chip=0x71138086 rev=0x08 hdr=0x00
vendor     = 'Intel Corporation'
device     = '82371AB/EB/MB PIIX4 ACPI'
class      = bridge
gpart show -l

gpart show was a great way to get a near equivalent ‘lsblk’ output of my devices.  On Linux,  ‘lsblk’  gave me an excellent device tree, size, type, and mount location, and I found out adding -l gave me about what I was expecting.


[root@VM_FreeBSD ~]# gpart show -l
=>       34  104857533  ada0  GPT  (50G)
34        128     1  (null)  (64k)
162   98566016     2  (null)  (47G)
98566178    5242880     3  (null)  (2.5G)
103809058    1048509        - free -  (512M)

You’re messing with my chi man…

This is one area where I would need to either accept what PC-BSD would do for me via graphical utilities, or do some more digging.  I wasn’t all too happy with how devices are managed in FreeBSD, but that is just my current personal opinion.  Anyone of course is free to point me in a good direction to convince me other wise.   Maybe I am love drunk with ‘fdiks -l’, ‘lsblk’, and ‘blkid’ that BSD seems to have blind-sided me in this regard.

I did however, become fond of the FreeBSD Quick Start Guide For Linux Users.  There is quite a bit of useful information in there.  Even so, the guide, in my opinion needs a lot of expansion for users that are familiar with more in depth command usage than an average Linux user.  While some basic areas are covered, there is much more I would like to see in this guide for curious Linux minds.  Now, I understand FreeBSD is not PC-BSD, but from what I know, they share the same “base” system, being that PC-BSD is built off of FreeBSD.

If the guide mentioned about were in fact a “one stop shop” for new Linux users coming over to the “cool guys party,” then I would feel much more at home.  None the less, I am thrilled that the handbook is so well written, and at least gets you the right concepts in your mind for Fast and Furious Googling.  There are some other areas I planned to explore tonight, but that will have to be it for now

Cheers,

-mikeyd

Advertisements

About professorkaos64

www.libregeek.org

Posted on 20131217, in Distro Test Drive, Distros and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s