Skip to content
  • 0 Votes
    2 Posts
    2k Views
    rickR

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

FreeBSD Notes
  • rickR

    Screen recording can use webm as their format, it can be more simple to use a gif to embed into a website or forum, than adding scripts to host different video format.

    In this case I grabbed a screen record of the progress for writing zeros to a hard drive with dd

    Use ffmpeg to convert webm to gif:

    First create a pallet:

    Move into the directory which the webm is located, or type in the path

    Where ‘dd.webm’ is the screen recording

    ffmpeg -y -i dd.webm -vf palettegen palette.png

    Output:

    dd-ffmpeg.png

    Then convert the webm to gif:

    ffmpeg -y -i dd.webm -i palette.png -filter_complex paletteuse -r 10 dd.gif

    dd-webm-2.png

    This is what I ended up with, looks like any image of any alien on the interwebz, as if shot through a potato, some tweaking of the command is in my future. None the less.

    dd.gif

    read more

  • rickR

    Write zeros to all sectors

    Use the command ‘lsblk’ to find the drive you wish to erase

    I’m using ‘dd’ to erase things

    In this case I’m torching sdb

    Only use status=progress if you care it’s not necessary

    dd if=/dev/zero of=/dev/sdb bs=12M status=progress

    dd.gif

    read more

  • rickR

    Remove old kernel images that are cluttering the system

    zstd-no-space-error.png

    Most of these errors are due to low or not enough space left in the root partition.

    If you are using a Debian flavor:

    sudo apt-get autoremove --purge

    zstd-error.png

    Inform grub whenever an old kernel is removed:

    update grub

    update-grub.png

    Remove the un-used kernel config files:

    These will be the files pre cursed as ‘rc’ where installed kernels use ‘ii’

    … As well as files no longer used or required due to dependencies

    This command will detect, print, and remove left over cruft from previously installed packages or scripts, that have been removed or updated.

    sudo dpkg --purge $(dpkg -l | awk '/^rc/{print $2}')

    purge.png

    You can re-run the following to view the installed kernel(s):

    dpkg --list | grep linux-image

    installed-kernels.png

    read more

  • rickR

    New script due to dependency changes:

    #! /bin/sh set -e

    if [ “$1” = “install” ] || [ “$1” = “upgrade” ]; then

    ACTION=$1

    elif [ “$1” = “” ]; then ACTION=install else echo “usage: $(basename $0) action [source]” echo “action is either install (default) or upgrade” echo “source is either tar (default) or git” exit 1 fi

    if [ “$2” = “git” ] || [ “$2” = “tar” ]; then SOURCE=$2 elif [ “$2” = “” ]; then SOURCE=tar else echo “Unknown source $2!” exit 1 fi

    if [ “$BPC_UID” ] && [ $(getent passwd “$BPC_UID” | cut -d ‘:’ -f 1) != “backuppc” ]; then echo “The uid = $BPC_UID is already in use!” exit 1 fi

    #Install dependencies

    apt-get -q update export DEBIAN_FRONTEND=noninteractive apt-get install -q -y apache2 apache2-utils libapache2-mod-perl2 par2 perl smbclient rsync tar gcc zlib1g zlib1g-dev rrdtool git make perl-doc libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl libacl1-dev wget iputils-ping pwgen

    #Set up backuppc user and directory

    if ! id backuppc >/dev/null 2>&1; then if [ “$BPC_UID” ]; then adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/false --uid=“$BPC_UID” backuppc else adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/false backuppc fi fi mkdir -p /var/lib/backuppc/.ssh chmod 700 /var/lib/backuppc/.ssh echo -e “BatchMode yes\nStrictHostKeyChecking no” > /var/lib/backuppc/.ssh/config if [ ! -e /var/lib/backuppc/.ssh/id_rsa ]; then ssh-keygen -q -t rsa -b 4096 -N ‘’ -C “BackupPC key” -f /var/lib/backuppc/.ssh/id_rsa fi chmod 600 /var/lib/backuppc/.ssh/id_rsa chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub chown -R backuppc:backuppc /var/lib/backuppc/.ssh

    #Set password or read password file

    if [ “$BPC_PASS” ]; then PASSWORD=“$BPC_PASS” elif [ -e /root/password ]; then PASSWORD=$(cat /root/password) chmod 600 /root/password else PASSWORD=$(pwgen -s -1 32) echo “$PASSWORD” > /root/password chmod 600 /root/password fi echo “backuppc:$PASSWORD” | chpasswd backuppc

    #Get BackupPC release versions

    get_latest_release() { wget -q -O - “https://api.github.com/repos/$1/releases/latest” | grep ‘“tag_name”:’ | sed -E ‘s/.“([^”]+)"./\1/’
    } bpcver=$(get_latest_release “backuppc/backuppc”) bpcxsver=$(get_latest_release “backuppc/backuppc-xs”) rsyncbpcver=$(get_latest_release “backuppc/rsync-bpc”)

    mkdir -p /tmp/bpc cd /tmp/bpc

    if [ $SOURCE = “tar” ]; then

    ##Fetch and install latest stable releases

    wget https://github.com/backuppc/backuppc-xs/releases/download/$bpcxsver/BackupPC-XS-$bpcxsver.tar.gz wget https://github.com/backuppc/rsync-bpc/releases/download/$rsyncbpcver/rsync-bpc-$rsyncbpcver.tar.gz wget https://github.com/backuppc/backuppc/releases/download/$bpcver/BackupPC-$bpcver.tar.gz tar -zxf BackupPC-XS-$bpcxsver.tar.gz tar -zxf rsync-bpc-$rsyncbpcver.tar.gz tar -zxf BackupPC-$bpcver.tar.gz cd BackupPC-XS-$bpcxsver perl Makefile.PL make make test make install cd …/rsync-bpc-$rsyncbpcver ./configure make make install cd …/BackupPC-$bpcver fi

    if [ $SOURCE = “git” ]; then

    #Fetch and install the latest development code instead

    git clone https://github.com/backuppc/backuppc.git git clone https://github.com/backuppc/backuppc-xs.git git clone https://github.com/backuppc/rsync-bpc.git cd backuppc-xs perl Makefile.PL make make test make install cd …/rsync-bpc ./configure make make install cd …/backuppc ./makeDist --nosyntaxCheck --releasedate “date -u "+%d %b %Y"” --version ${bpcver}git tar -zxf dist/BackupPC-${bpcver}git.tar.gz cd BackupPC-${bpcver}git fi

    if [ $ACTION = “install” ]; then ./configure.pl --batch --cgi-dir /var/www/cgi-bin/BackupPC --data-dir /var/lib/backuppc --hostname backuppc --html-dir /var/www/html/BackupPC --html-dir-url /BackupPC --install-dir /usr/local/BackupPC fi

    if [ $ACTION = “upgrade” ]; then ./configure.pl --batch --config-path /etc/BackupPC/config.pl fi

    #Set up web server #Note that changing the apache user and group (/etc/apache2/envvars) could cause other services #provided by apache to fail. There are alternatives if you don’t want to change the apache #user: use SCGI or a setuid BackupPC_Admin script - see the docs. cp httpd/BackupPC.conf /etc/apache2/conf-available/backuppc.conf sed -i “/Require local/d” /etc/apache2/conf-available/backuppc.conf sed -i “s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=backuppc/” /etc/apache2/envvars sed -i “s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=backuppc/” /etc/apache2/envvars echo ‘’ > /var/www/html/index.html a2enconf backuppc a2enmod cgid service apache2 restart

    #Set up backuppc service

    cp systemd/init.d/debian-backuppc /etc/init.d/backuppc

    chmod 755 /etc/init.d/backuppc

    update-rc.d backuppc defaults

    chmod u-s /var/www/cgi-bin/BackupPC/BackupPC_Admin

    touch /etc/BackupPC/BackupPC.users

    sed -i “s/$Conf{CgiAdminUserGroup}.*/$Conf{CgiAdminUserGroup} = ‘backuppc’;/” /etc/BackupPC/config.pl

    sed -i “s/$Conf{CgiAdminUsers}.*/$Conf{CgiAdminUsers} = ‘backuppc’;/” /etc/BackupPC/config.pl

    chown -R backuppc:backuppc /etc/BackupPC

    echo $PASSWORD | htpasswd -i /etc/BackupPC/BackupPC.users backuppc

    service backuppc start

    #Clean up

    cd rm -rf /tmp/bpc echo “All done!” exit 0

    read more

  • rickR

    To list all files in current directory including dot files (hidden files or directories), as well as print permissions :

    ls -la
    read more