Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[bmartino1] Workaround Scripts Updated

Featured Replies

With the release of unraid 7 it's time to clean house, condense and fix some things here and there...

 

While working on the unraid 7 beta for testing and bug reports, I made a workarounds script to work with Mods, Admins, Community devs and with  lime tech and others to fix things.

Some scripts there are all in one from multiple there. As this is a clean house and share for others who may want to do similar...

Edited by bmartino1
Data - Typo

  • Author

Thank you User script Plugin... Why not the go file? 
*Its too early in the boot process. The array needs to be started and some networking settings and file access are need at array start.
Cron: at startup of the Array

Custom Fix Network settings.

fix_networking_settings.sh

 

#!/bin/bash

# Delay before the script starts
sleep 30

# Fix hosts file
fix_hosts_file() {
    echo "Fixing hosts file..."
    sleep 35  # Wait for system initialization
    if [ -f "/boot/config/hosts" ]; then
        rm -f /etc/hosts
        cp /boot/config/hosts /etc/hosts
        chmod 644 /etc/hosts
        echo "Hosts file has been updated."
    else
        echo "Hosts file not found at /boot/config/hosts. Skipping."
    fi
}

# Apply sysctl settings
apply_sysctl_settings() {
    echo "Applying sysctl settings..."
    sysctl -w net.ipv6.conf.all.forwarding=1
    sysctl -w net.ipv6.conf.eth0.accept_ra=2
    sysctl -w net.ipv6.conf.eth0.accept_ra_rt_info_max_plen=64

    echo "Verifying sysctl settings..."
    sysctl net.ipv6.conf.all.forwarding
    sysctl net.ipv6.conf.eth0.accept_ra
    sysctl net.ipv6.conf.eth0.accept_ra_rt_info_max_plen
}

# Configure vhost0 interface
configure_vhost0() {
    echo "Configuring vhost0 interface..."
    sleep 80  # Wait for array and Docker services to start

    echo "Bringing vhost0 down..."
    ifconfig vhost0 down
    ip link set vhost0 down

    echo "Flushing existing IP addresses from vhost0..."
    ip addr flush dev vhost0

    echo "Assigning static IP to vhost0..."
    ip addr add 192.168.2.248/24 dev vhost0

    # Uncomment below for DHCP configuration instead of static IP
    # echo "Configuring vhost0 with DHCP..."
    # ifconfig vhost0 0.0.0.0
    # dhcpcd vhost0

    echo "Bringing vhost0 up..."
    ip link set vhost0 up

    echo "vhost0 interface configured."
}

# Main execution
main() {
    echo "Starting networking settings fix..."
    sleep 60  # Initial delay to ensure system readiness

    fix_hosts_file
    apply_sysctl_settings
    configure_vhost0

    echo "Networking settings fix completed."
}

main


SO, In unraid 7 I run:

a single nic with ipv4 and ipv6. Since I have only 1 Nic I have no use for bridging nor bonding. So I turn them off. My interface eth0 supports macvlan without the need to use a software network br0... (there was a while and time of some nic and hardware not able to support macvlan due to needing to support other nic settings....)
image.thumb.png.df0c18a951b2d2ed9ece04645a365f07.png

 

Docker settings:
*Due to the Macvlan bug, and some Nic Hardware requirments, I can see why the switch to ipvaln...
I still Prefer Macvlan due to the interaction of each docker service I run will have its own Mac address. (And having the ability to assign a mac my self)

*Due to docker evolution contains can no longer set their own mac this is now done at the docker network level...
image.thumb.png.fb5199689429b4a05a38000c32073c12.png

For My network, I Want to Preserve User Defined Networks for other docker networks I create.
I Want Host access to custom Networks Enabled to allow my docker to talk to the subnet and lan network over eth0
With unraid v7 I prefer a xfs img base for stability. With ZFS implementations, this may need to become an overlay 2...

Then With Vms I have it set to use vhost
image.png.d6ce081e1940a181e67ced4ceac17425.png
*vmbr0 would work, but they wouldn't get assigned a lan ip. They would get a vmbr0 ip from unraids hyper-v virtual switch. To avoid issues, I set it to vhost0
This way any VM, Docker I run will have its own unique mac address and a IP from my LAN to communicate to each other over the interface.

Your Network may Vary...
Due to a Unifi Network implementation and due to having a Mix Network of Apple Devices, Android, Linux, Windows... I often have to run a few unique network instance to make every device happy and running smooth on the network, hence the use of this script.

Mainly due to host file dns inconsistency brought on and notified via the FCP and due to multiple device wanting different things to ensure compatibility and device connections. I run the above script.

 

My Example Host File as my unraid host name is BMM-Unraid

root@BMM-Unraid:~# cat /boot/config/hosts 
#IPV4:
127.0.0.1       ip4-loopback localhost
#IPV6:
::1             ip6-localhost ip6-loopback localhost
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
ff02::3         ip6-allhosts
#fe80::1%lo0    localhost

#Unraid needed:
127.0.0.1      BMM-Unraid BMM-Unriad.home.arpa BMM-Unraid.local BMM-Unraid.localdomain
#54.149.176.35     keys.lime-technology.com

#Other Needed and  Docker Services
192.168.2.254 BMM-Unraid BMM-Unraid.home.arpa BMM-Unraid.localdomain BMM-Unriad.local
192.168.2.248 vhost-bmm-unraid.home.arpa

As Such to assist unraid running a few Networks related task I have to assist with the standard with my search domain set to RFC Standards ".home.arpa", to use .local for apple and mdns and .localdomain for some netbios windows ntml for some older systems...

Since Unraid has fixed the host file form stable v6 to 7 And to fix some unifi and other service I run at unraids level to maintain a network.

Due to a unifi bug (as it was fine in earlier version of unfi network) and due to potential security issue like a rouge DHCP server and IGMP snooping. Due to how unraids vhost@tap default configuration work... I often get spam false positive notification due to how Unraid vhost tap stealing the set static IP address and then both interfaces begin to use the same Ip address... When unraids vhost tap that is then networking bridge tunneled to supply a network service for my unriad VM and Dockers. I thought it best to then, like my VM and Dockers that have Static IP to Have Unraid Claim that Tap Interface as a Static Service IP.

This way Unifi and other IP Conflicts don't happen, and this fixes some port forwarding and travel packet things later on how it traverses into unraid.

Finally, Due to ipv6 enabled on my network Unraid seems to have taken a big stance of while allowing an ipv6 set it may not use ipv6 for dockers, vm, etc... Form home assistant to dns docker liek adguard and pihole I've found that i need to add these ipv6 setting to assist with vlan and other ipv6 communication.

Thus, this script of Fix Unraid Network as it need only be ran once at first array boot and set up the unraid instance in a configured way to reduce network packets while maintaining service for a mixed network...

By default Unraid appears to be using the ".localdomain"
image.png.5f0981b463544d1da1b6221cb40dfb7f.png

Edited by bmartino1
Data - Typo

  • Author

Lets take a look at samba more at zfs and snapshots:

Re Testing with Unraid 7 WIP...

As this has been accomplished on unraid before
https://forum.level1techs.com/t/zfs-on-unraid-lets-do-it-bonus-shadowcopy-setup-guide-project/148764
Using

https://github.com/zfsonlinux/zfs-auto-snapshot

 

This can be a fairly advanced setup. From ZFS options to other plugins to zfs commands and snapshots.... 

I assume you have a zfs pool and I assume you have the ZFS Master Plugin installed.
I assume you have some snapshots already.
Otherwise, You may need some apps installed from the CA:

 

with ZFS Master Plugin and Snap shots plugin we can double-check:
Additional ZFS Master Plugin Settings:
image.thumb.png.4a92224c369278730713550b607aaae0.png

*As the level1 Guide used https://github.com/zfsonlinux/zfs-auto-snapshot/wiki/Samba for making zfs snapshots... I'm accomplishing this via a different script and differnet file name.

Using the ZFS Mast Plugin you can add a Snapshot Prefix and still follow along Level 1 guid to a point...

The guide does install FIO:
which can be installed via plugin:
https://github.com/ich777/un-get
 

un-get install fio

May Have been a nerd pack application. Not seeing it as a pre binary...
If you want to 3rd party install that instructions can be found here...


Zfs snapshot script... Manual supply the pool/dataset:

#!/bin/bash

# v0.7 - Fixed duplicate snapshot creation
######################## simple-snapshot-zfs #######################
###################### User Defined Options ######################

# Number of snapshots to keep
SNAPSHOT_QTY=12

###### Don't change below unless you know what you're doing ######
##################################################################

timestamp=$(date "+%Y-%m-%d-%H%M%S")  # Match Samba snapshot pattern
echo "Starting Snapshot ${timestamp}"
echo "_____________________________________________________________"

# Get only top-level datasets to avoid duplication
DATASETS=($(zfs list -H -o name | awk -F'/' '!seen[$1]++'))

# Function to create snapshots unconditionally
create_snapshot() {
  local DATASET="$1"
  local TIMESTAMP="${timestamp}"

  # Check if snapshot already exists before creating
  if zfs list -t snapshot | grep -q "${DATASET}@${TIMESTAMP}"; then
    echo "Snapshot already exists for ${DATASET}@${TIMESTAMP}, skipping..."
  else
    zfs snapshot -r "${DATASET}@${TIMESTAMP}"
    echo "Snapshot created: ${DATASET}@${TIMESTAMP}"
  fi
}

# Function to prune old snapshots
prune_snapshots() {
  local DATASET="$1"
  local KEEP="${SNAPSHOT_QTY}"
  
  local SNAPSHOTS=( $(zfs list -t snapshot -o name -s creation -r "${DATASET}" | grep "^${DATASET}@") )
  local SNAPSHOTS_COUNT=${#SNAPSHOTS[@]}

  echo "Total snapshots for ${DATASET}: ${SNAPSHOTS_COUNT}"

  local SNAPSHOTS_SPACE
  SNAPSHOTS_SPACE=$(zfs get -H -o value usedbysnapshots "${DATASET}")
  echo "Space used by snapshots for ${DATASET}: ${SNAPSHOTS_SPACE}"

  if [[ ${SNAPSHOTS_COUNT} -gt ${KEEP} ]]; then
    local TO_DELETE=$((SNAPSHOTS_COUNT - KEEP))
    for i in "${SNAPSHOTS[@]:0:${TO_DELETE}}"; do
      zfs destroy "${i}"
      echo "Deleted snapshot: ${i}"
      echo "_____________________________________________________________"
    done
  else
   echo "_____________________________________________________________"
  fi
}

# Iterate over top-level datasets only
for dataset in "${DATASETS[@]}"; do
  create_snapshot "${dataset}"
  prune_snapshots "${dataset}"
done

echo "----------------------------Done!----------------------------"

You can cron Automation ZFS Snapshot 5PM every month: 0 17 1 */1 *
image.thumb.png.ec143be330eb3ac01217287b90915f5d.png

And run manual to make a snapshot to record changes...


So Now that we have some snapshots:
we can double-check with the snapshot plugin or terminal:

image.png.88cd238956d1a96f98d53b272bcb793d.png
 root@BMM-Unraid:~# ls /mnt/user/Cloud/.zfs/snapshot
2024-12-23-1840/  2024-12-28-1735/  2024-12-29-0206/  2025-01-05-0408/  2025-01-19-1637/  2025-01-19-1754/

 

lets run and make sure the snapshots are visible.

zfs set com.sun:auto-snapshot=true vm-zfs/Cloud
zfs set snapdir=visible vm-zfs/Cloud


With ZFS Implementations and snapshots ready we are now set to edit Samba...

For Personal Reason and for Advance configurations. I Decided to Forgo Unraid SMB conf.
I use a script to stop samba, remove smb.conf and replace unraids smb.conf with my own...

Script:
 

#!/bin/bash
sleep 60

#Samba - nbbd
/etc/rc.d/rc.samba stop
rm /etc/samba/smb.conf
cp /boot/config/smb-override.conf /etc/samba/smb.conf
/etc/rc.d/rc.samba start


smb override:
 

root@BMM-Unraid:~# cat /boot/config/smb
smb-extra.conf     smb-override.conf  smb.conf           smbpasswd          
root@BMM-Unraid:~# cat /boot/config/smb


 

root@BMM-Unraid:~# cat /boot/config/smb-override.conf 
[global]
# Configurable identification disabled as we need to make other edits.
# include = /etc/samba/smb-names.conf

# Generated names
netbios name = BMM-Unraid
server string = Unraid NAS Server
workgroup = WORKGROUP
security = USER
map to guest = Bad User
guest account = nobody
null passwords = Yes

# Network settings
wins support = yes
name resolve order = lmhosts wins bcast host
multicast dns register = Yes
disable netbios = No
bind interfaces only = yes
interfaces = 192.168.2.254/24 127.0.0.1

# Master browser settings
server role = standalone server
local master = yes
domain master = yes
preferred master = yes
os level = 200
nmbd bind explicit broadcast = no

# Logging
logging = syslog@0
# log level = 3

# File and directory permissions
create mask = 0777
directory mask = 0777
acl allow execute always = Yes

# Printer settings
show add printer wizard = No
disable spoolss = Yes
load printers = No
printing = bsd
printcap name = /dev/null

# Performance settings
aio read size = 0
aio write size = 0
use sendfile = Yes
server multi channel support = yes
max open files = 40960

# Miscellaneous settings
invalid users = root
fruit:encoding = native
fruit:zero_file_id = false
fruit:nfs_aces = No
rpc_server:mdssvc = disabled
rpc_daemon:mdssd = disabled
fruit:time machine max size = 0 # Unlimited
fruit:time machine = True
fruit:resource = stream
fruit:metadata = stream
vfs objects = catia fruit streams_xattr
dns proxy = no
winbind request timeout = 5
#server signing = mandatory
server signing = auto
strict locking = no
ntlm auth = mschapv2-and-ntlmv2-only

# Control Client and Access
# client min protocol = SMB2
# client max protocol = SMB3

# Other File Settings
follow symlinks = yes
unix extensions = No
wide links = Yes
case sensitive = True
default case = lower
preserve case = yes
short preserve case = yes
guest ok = Yes
map hidden = Yes
map system = Yes
smbd max xattr size = 2097152
read raw = yes
write raw = yes

# Other add-ins from plugins and shares via WebUI
# Hook for unassigned devices shares
include = /etc/samba/smb-unassigned.conf

# Unraid WebUI Auto-configured shares
include = /etc/samba/smb-shares.conf

# Hook for user-defined Samba Config
include = /boot/config/smb-extra.conf
#Using to custom define samba...


Due to Samba Shares Settings need updated I use terminal command to get my current samba shares and remvoed Unraid WebUI from messing them.
Note I still have atleast 1 share that doesn't have zfs backups...
image.thumb.png.a35c4fbb2385ac43b7f07d24b19287bf.png
image.thumb.png.23e8a8f1bc024bb9a2364528f291b5de.png

 

Since I needed to reboot I edited the config instead of stopping the array to add my shares to Samba Extra...

Example Share:
 

root@BMM-Unraid:~# cat /boot/config/smb-extra.conf 
#SMB OVeride in affect as well
#add ZFS Backups


[Cloud]
        case sensitive = Auto
        comment = Samba Share Other Data
        force group = users
        force user = nobody
        path = /mnt/user/Cloud
        read only = No
        vfs objects = catia fruit streams_xattr shadow_copy2
        fruit:encoding = native
        shadow: localtime = yes
        shadow: format = %Y-%m-%d-%H%M
        shadow: sort = desc
        shadow: snapdir = .zfs/snapshot


Note the Format, This needs to match your ZFS Master Plugin and Prefix and teh way your zfs snapshots are made for its file name! I don't have a prefix. and using the format per my snapshots
Reboot to apply...

Thats it. With samba now working by going to my Unriad IP for testing:
image.png.c454902eb1435b49a4808a0a0e54ea37.png

 

With that I Now have zfs snapshots working as shadow copies.

As its easier to see with documents when documents are edited and changed and a snapshot of its revios is different:
RMC>Properties Previous Version:
image.png.09960607aa345a6b352b132e494cf81b.png

You will see a earlier revision via Shadow Copies.

Edited by bmartino1
Fix zfs Snapshot Script

  • bmartino1 changed the title to [bmartino1] Workaround Scripts Updated
  • Author

it would be nice if the Devs would give us a custom advance option to add thing to the smb-share in /etc/samba/smb-share.conf to not have to do some side weird workarounds... Truenase, 45drives, OMV... all have this its not that hard to add or fix...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.