Skip to content

Blank and Burn ISO Freebsd

FreeBSD Notes
  • Locate the drive:

    camcontrol devlist
    

    Output:

    <ST3500418AS CC35>                 at scbus3 target 0 lun 0 (pass0,ada0)
    <ATAPI iHAS324   A BL1A>           at scbus4 target 0 lun 0 (pass3,cd0)
    <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)
    

    Where “ at scbus4 target 0 lun 0 (pass3,cd0)” = our DVD drive


    Blank the DVD+RW medium:

    growisofs -Z /dev/cd0=/dev/zero
    

    Output: Notice this disk contains a previously written .ISO

    WARNING: /dev/cd0 already carries isofs!
    About to execute 'builtin_dd if=/dev/zero of=/dev/pass3 obs=32k seek=0'
    /dev/pass3: restarting DVD+RW format...
    /dev/pass3: "Current Write Speed" is 4.1x1352KBps.
    3964928/4700372992 ( 0.1%) @0.9x, remaining 59:13 RBU  99.9% UBU   3.8%
    22544384/4700372992 ( 0.5%) @4.0x, remaining 24:12 RBU 100.0% UBU  99.8%
    [................]
    3048865792/4700372992 (64.9%) @4.0x, remaining 5:04 RBU  99.9% UBU  99.8%
    3067445248/4700372992 (65.3%) @4.0x, remaining 5:01 RBU 100.0% UBU  99.8%
    [................]
    3784048640/4700372992 (80.5%) @4.0x, remaining 2:48 RBU  99.9% UBU  99.8%
    3802726400/4700372992 (80.9%) @4.0x, remaining 2:45 RBU 100.0% UBU  99.8%
    [................]
    4370333696/4700372992 (93.0%) @4.0x, remaining 1:00 RBU  99.9% UBU  99.8%
    4388945920/4700372992 (93.4%) @4.0x, remaining 0:57 RBU  99.9% UBU  99.8%
    [................]
    
    

    Write the ISO:

    growisofs -Z /dev/cd0 -J -R /home/rick/Downloads/ISO/FreeBSD/FreeBSD-11.1-RELEASE-amd64-dvd1.iso
    

    Output

    Executing 'mkisofs -J -R /home/rick/Downloads/ISO/FreeBSD/FreeBSD-11.1-RELEASE-amd64-dvd1.iso | builtin_dd of=/dev/pass3 obs=32k seek=0'
      0.31% done, estimate finish Sun Feb 18 10:46:09 2018
      0.61% done, estimate finish Sun Feb 18 10:46:09 2018
    /dev/pass3: "Current Write Speed" is 4.1x1352KBps.
      1.23% done, estimate finish Sun Feb 18 10:48:52 2018
      1.53% done, estimate finish Sun Feb 18 10:50:30 2018
    [.............]
     37.92% done, estimate finish Sun Feb 18 10:56:15 2018
     38.22% done, estimate finish Sun Feb 18 10:56:15 2018
    [.............]
     53.51% done, estimate finish Sun Feb 18 10:56:16 2018
     53.82% done, estimate finish Sun Feb 18 10:56:16 2018
    [.............]
     74.61% done, estimate finish Sun Feb 18 10:56:17 2018
     74.92% done, estimate finish Sun Feb 18 10:56:17 2018
    [.............]
     89.59% done, estimate finish Sun Feb 18 10:56:18 2018
     89.90% done, estimate finish Sun Feb 18 10:56:18 2018
    [.............]
    99.99% done, estimate finish Sun Feb 18 10:56:19 2018
    Total translation table size: 0
    Total rockridge attributes bytes: 300
    Total directory bytes: 0
    Path table size(bytes): 10
    Max brk space used 0
    1635174 extents written (3193 MB)
    builtin_dd: 1635184*2KB out @ average 3.9x1352KBps
    /dev/pass3: flushing cache
    /dev/pass3: stopping de-icing
    /dev/pass3: writing lead-out
    
    

    Fin!

FreeBSD Notes
  • Print command name running on port

    sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | while read port process pid; do echo "Port $port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n
    read more

  • 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

  • If attempting to install FreeBSD on a disk which previously belongs to a ZFS, and you get this error: Before installing, select the option ‘shell’

    Once in the shell, remove geom protections by running:

    sysctl kern.geom.debugflags=0x10

    When your finished, type exit and return to the install / configure screen.

    read more

  • Which means geom is protecting the disk.

    Running the following clears the protection:

    sysctl kern.geom.debugflags=0x10

    Output:

    kern.geom.debugflags: 0 -> 16

    Clearing MBR and partitions:

    dd if=/dev/zero of=/dev/ada0 bs=512 count=1 conv=notrunc
    read more