List block devices FreeBSD



  • List hard drives USB optical media

    camcontrol devlist
    

    For more detail:

    gpart list
    

    Here is the mess I get on this machine currently from the latter:

    Geom name: ada0
    modified: false
    state: OK
    fwheads: 16
    fwsectors: 63
    last: 976773167
    first: 63
    entries: 4
    scheme: MBR
    Providers:
    1. Name: ada0s1
       Mediasize: 500107825152 (466G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 32768
       Mode: r3w3e5
       attrib: active
       rawtype: 165
       length: 500107825152
       offset: 32768
       type: freebsd
       index: 1
       end: 976773159
       start: 64
    Consumers:
    1. Name: ada0
       Mediasize: 500107862016 (466G)
       Sectorsize: 512
       Mode: r3w3e8
    
    Geom name: ada0s1
    modified: false
    state: OK
    fwheads: 16
    fwsectors: 63
    last: 976773095
    first: 0
    entries: 8
    scheme: BSD
    Providers:
    1. Name: ada0s1a
       Mediasize: 2147483648 (2.0G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 32768
       Mode: r1w1e1
       rawtype: 27
       length: 2147483648
       offset: 0
       type: freebsd-zfs
       index: 1
       end: 4194303
       start: 0
    2. Name: ada0s1b
       Mediasize: 2147483648 (2.0G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 2147516416
       Mode: r1w1e0
       rawtype: 1
       length: 2147483648
       offset: 2147483648
       type: freebsd-swap
       index: 2
       end: 8388607
       start: 4194304
    3. Name: ada0s1d
       Mediasize: 495812853760 (462G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 32768
       Mode: r1w1e1
       rawtype: 27
       length: 495812853760
       offset: 4294967296
       type: freebsd-zfs
       index: 4
       end: 976773087
       start: 8388608
    Consumers:
    1. Name: ada0s1
       Mediasize: 500107825152 (466G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 32768
       Mode: r3w3e5
    
    Geom name: ada1
    modified: false
    state: OK
    fwheads: 16
    fwsectors: 63
    last: 976773167
    first: 63
    entries: 4
    scheme: MBR
    Providers:
    1. Name: ada1s1
       Mediasize: 500107825152 (466G)
       Sectorsize: 512
       Stripesize: 4096
       Stripeoffset: 0
       Mode: r3w3e5
       attrib: active
       rawtype: 165
       length: 500107825152
       offset: 32768
       type: freebsd
       index: 1
       end: 976773159
       start: 64
    Consumers:
    1. Name: ada1
       Mediasize: 500107862016 (466G)
       Sectorsize: 512
       Stripesize: 4096
       Stripeoffset: 0
       Mode: r3w3e8
    
    Geom name: ada1s1
    modified: false
    state: OK
    fwheads: 16
    fwsectors: 63
    last: 976773095
    first: 0
    entries: 8
    scheme: BSD
    Providers:
    1. Name: ada1s1a
       Mediasize: 2147483648 (2.0G)
       Sectorsize: 512
       Stripesize: 4096
       Stripeoffset: 0
       Mode: r1w1e1
       rawtype: 27
       length: 2147483648
       offset: 0
       type: freebsd-zfs
       index: 1
       end: 4194303
       start: 0
    2. Name: ada1s1b
       Mediasize: 2147483648 (2.0G)
       Sectorsize: 512
       Stripesize: 4096
       Stripeoffset: 0
       Mode: r1w1e0
       rawtype: 1
       length: 2147483648
       offset: 2147483648
       type: freebsd-swap
       index: 2
       end: 8388607
       start: 4194304
    3. Name: ada1s1d
       Mediasize: 495812853760 (462G)
       Sectorsize: 512
       Stripesize: 4096
       Stripeoffset: 0
       Mode: r1w1e1
       rawtype: 27
       length: 495812853760
       offset: 4294967296
       type: freebsd-zfs
       index: 4
       end: 976773087
       start: 8388608
    Consumers:
    1. Name: ada1s1
       Mediasize: 500107825152 (466G)
       Sectorsize: 512
       Stripesize: 4096
       Stripeoffset: 0
       Mode: r3w3e5
    
    Geom name: da0
    modified: false
    state: CORRUPT
    fwheads: 255
    fwsectors: 63
    last: 30310359
    first: 40
    entries: 152
    scheme: GPT
    Providers:
    1. Name: da0p1
       Mediasize: 2147483648 (2.0G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 65536
       Mode: r0w0e0
       rawuuid: 107c86ad-1192-11e8-a477-001966e9f863
       rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
       label: (null)
       length: 2147483648
       offset: 65536
       type: freebsd-swap
       index: 1
       end: 4194431
       start: 128
    2. Name: da0p2
       Mediasize: 13371351040 (12G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 2147549184
       Mode: r0w0e0
       rawuuid: 1092e574-1192-11e8-a477-001966e9f863
       rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
       label: (null)
       length: 13371351040
       offset: 2147549184
       type: freebsd-zfs
       index: 2
       end: 30310351
       start: 4194432
    Consumers:
    1. Name: da0
       Mediasize: 15518924800 (14G)
       Sectorsize: 512
       Mode: r0w0e0
    
    Geom name: iso9660/ESXI-6.5.0-20170104001-STANDARD
    modified: false
    state: CORRUPT
    fwheads: 255
    fwsectors: 63
    last: 30310359
    first: 40
    entries: 152
    scheme: GPT
    Providers:
    1. Name: iso9660/ESXI-6.5.0-20170104001-STANDARDp1
       Mediasize: 2147483648 (2.0G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 65536
       Mode: r0w0e0
       rawuuid: 107c86ad-1192-11e8-a477-001966e9f863
       rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
       label: (null)
       length: 2147483648
       offset: 65536
       type: freebsd-swap
       index: 1
       end: 4194431
       start: 128
    2. Name: iso9660/ESXI-6.5.0-20170104001-STANDARDp2
       Mediasize: 13371351040 (12G)
       Sectorsize: 512
       Stripesize: 0
       Stripeoffset: 2147549184
       Mode: r0w0e0
       rawuuid: 1092e574-1192-11e8-a477-001966e9f863
       rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
       label: (null)
       length: 13371351040
       offset: 2147549184
       type: freebsd-zfs
       index: 2
       end: 30310351
       start: 4194432
    Consumers:
    1. Name: iso9660/ESXI-6.5.0-20170104001-STANDARD
       Mediasize: 15518924800 (14G)
       Sectorsize: 512
       Mode: r0w0e0
    




Tmux Commands

screen and tmux

A comparison of the features (or more-so just a table of notes for accessing some of those features) for GNU screen and BSD-licensed tmux.

The formatting here is simple enough to understand (I would hope). ^ means ctrl+, so ^x is ctrl+x. M- means meta (generally left-alt or escape)+, so M-x is left-alt+x

It should be noted that this is no where near a full feature-set of either group. This - being a cheat-sheet - is just to point out the most very basic features to get you on the road.

Trust the developers and manpage writers more than me. This document is originally from 2009 when tmux was still new - since then both of these programs have had many updates and features added (not all of which have been dutifully noted here).

Action tmux screen
start a new session tmux OR
tmux new OR
tmux new-session
screen
re-attach a detached session tmux attach OR
tmux attach-session
screen-r
re-attach an attached session (detaching it from elsewhere) tmux attach -d OR
tmux attach-session -d
screen -dr
re-attach an attached session (keeping it attached elsewhere) tmux attach OR
tmux attach-session
screen -x
detach from currently attached session ^b d OR
^b :detach
^a ^d OR
^a :detach
rename-window to newname ^b , <newname> OR
^b :rename-window <newn>
^a A <newname>
list windows ^b w ^a w
list windows in chooseable menu ^a "
go to window # ^b # ^a #
go to last-active window ^b l ^a ^a
go to next window ^b n ^a n
go to previous window ^b p ^a p
see keybindings ^b ? ^a ?
list sessions ^b s OR
tmux ls OR
tmux list-sessions
screen -ls
toggle visual bell ^a ^g
create another window ^b c ^a c
exit current shell/window ^d ^d
split window/pane horizontally ^b " ^a S
split window/pane vertically ^b % ^a |
switch to other pane ^b o ^a <tab>
kill the current pane ^b x OR (logout/^D)
collapse the current pane/split (but leave processes running) ^a X
cycle location of panes ^b ^o
swap current pane with previous ^b {
swap current pane with next ^b }
show time ^b t
show numeric values of panes ^b q
toggle zoom-state of current pane (maximize/return current pane) ^b z
break the current pane out of its window (to form new window) ^b !
re-arrange current panels within same window (different layouts) ^b [space]
Kill the current window (and all panes within) ^b killw [target-window]
  • Locate devices:

    camcontrol devlist

    Output; in this case only:

    <ST3500418AS CC35> at scbus3 target 0 lun 0 (pass0,ada0) <ST500DM002-1BD142 KC45> at scbus5 target 0 lun 0 (pass1,ada1) <AHCI SGPIO Enclosure 1.00 0001> at scbus9 target 0 lun 0 (ses0,pass2) <Generic STORAGE DEVICE 1532> at scbus10 target 0 lun 0 (da0,pass3) <Generic STORAGE DEVICE 1532> at scbus10 target 0 lun 1 (da1,pass4)

    Where ada0 and ada1 are mechanical drives, da0 is a miniSD card in a USB enclosure da1

    Or to print all partitions:

    gpart show

    Output (after formatting USB device):

    => 63 976773105 ada0 MBR (466G) 63 1 - free - (512B) 64 976773096 1 freebsd [active] (466G) 976773160 8 - free - (4.0K) => 0 976773096 ada0s1 BSD (466G) 0 4194304 1 freebsd-zfs (2.0G) 4194304 4194304 2 freebsd-swap (2.0G) 8388608 968384480 4 freebsd-zfs (462G) 976773088 8 - free - (4.0K) => 63 976773105 ada1 MBR (466G) 63 1 - free - (512B) 64 976773096 1 freebsd [active] (466G) 976773160 8 - free - (4.0K) => 0 976773096 ada1s1 BSD (466G) 0 4194304 1 freebsd-zfs (2.0G) 4194304 4194304 2 freebsd-swap (2.0G) 8388608 968384480 4 freebsd-zfs (462G) 976773088 8 - free - (4.0K) => 32 2012128 da0 MBR (983M) 32 2012128 1 fat32 (982M)

    List partitions on dev da0:

    gpart show da0

    Delete existing partitions:

    gpart delete -i da0

    Destroy label:

    gpart destroy da0

    Create new mbr spanning entire disk:

    gpart create -s mbr da0

    Create new fat32 partition spanning entire disk:

    gpart add -t fat32 da0

    Initialize fat32 file system:

    newfs_msdos -F32 /dev/da0s1

    Lets break something!

    Don’t do any of this unless you are prepared to break it all, or better yet, you read the man pages and find out what they actually do, very useful tools however.

    I’m just making notes from other notes, various resources on the net.

    gpart destroy -F da0

    Zero out the drive === !!!Don’t do this jazz regularly on any USB!!! The type of memory has a finite read/write number===

    dd if=/dev/zero of=/dev/da0 bs=2m count=1

    Format the drive

    newfs_msdos -F32 /dev/da0s1

    read more
  • Alternatively or in addition to the above to install bhyve:

    pkg install vm-bhyve bhyve-firmware bhyve-rc-3 grub2-bhyve

    Output:

    To ensure binaries built with this toolchain find appropriate versions of the necessary run-time libraries, you may want to link using

    -Wl,-rpath=/usr/local/lib/gcc48

    For ports leveraging USE_GCC, USES=compiler, or USES=fortran this happens transparently.

    ===> NOTICE:

    This port is deprecated; you may wish to reconsider installing it:

    Unsupported by upstream. Use GCC 6 or newer instead… Message from vm-bhyve-1.1.8_1:

    To enable vm-bhyve, please add the following lines to /etc/rc.conf, depending on whether you are using ZFS storage or not. Please note that the directory or dataset specified should already exist.

    vm_enable="YES" vm_dir="zfs:pool/dataset"

    OR

    vm_enable="YES" vm_dir="/directory/path"

    Then run :

    vm init

    If upgrading from 1.0 or earlier, please note that the ‘guest’ configuration option is no longer used.

    Guests that are not using UEFI boot will need either loader=“grub” or loader=“bhyveload” in their configuration in order to make sure the correct loader is used.

    Message from bhyve-rc-3:

    Configuration is done completely though rc.conf. The rc script won’t touch any devices for you (neither disk, nor tap) so you need to make sure all of those have been initialized properly.

    General setup:

    kldload vmm net.link.tap.up_on_open=1

    Make it persistent:

    echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf cat >> /boot/loader.conf << EOF vmm_load="YES" EOF

    Minimal example:

    cat >> /etc/rc.conf << EOF cloned_interfaces="tap0 bridge0" bhyve_enable="YES" bhyve_diskdev="/dev/zvol/anything/bhyve/virt" EOF ifconfig tap0 create ifconfig bridge0 create service bhyve start tmux list-sessions tmux attach -t bhyve service bhyve status service bhyve stop

    Multi profile configuration example:

    cat >> /etc/rc.conf << EOF cloned_interfaces="tap0 tap1 bridge0" bhyve_enable="YES" bhyve_profiles="virt1 virt2" bhyve_virt1_diskdev="/dev/zvol/anything/bhyve/virt1" bhyve_virt2_tapdev="tap1" bhyve_virt2_diskdev="/dev/zvol/anything/bhyve/virt2" bhyve_virt2_memsize="8192" bhyve_virt2_ncpu="4" EOF ifconfig tap0 create ifconfig tap1 create ifconfig bridge0 create service bhyve start # start all service bhyve start virt2 # start individual tmux attach -t bhyve_virt1 tmux attach -t bhyve_virt1 service bhyve stop virt2 # stop individual service bhyve stop # stop all

    (by default ctrl-b d detaches from tmux).

    read more
});