!! IMPORTANT !! As of Home Assistant 2023.6, there is build in option to mount NAS storage, tested for few month, working perfectly. I am removing the image from google drive on 1.1.2025.
Mount NAS share directly to HASS OS It is based on debian live iso image
- Have Proxmox guest VM with Home Assistant
- Have NAS as LXC or VM on the host
- Create Host only network between HA and NAS (This will prevent loosing network connection, if you reboot router or other situations and speed will be superfast.
- Proxmox host with Home Assistant guest / RPI Home Assistant OS
- 2GB of RAM (its for unsquashing images)
- Everytime you update/upgrade Home Assistant check the sensor if the share is mounted, if not then you need to use this repository.
- MAKE A BACKUP OF Home Assistant VM !!!
- Create or take my template of fstab and upload it to new folder
custom_components/hanasmount. - Create monitoring variable for mounted volume (i am sure my solution is not the best,but it works fine):
- Create file in the network share named
thisisnasand put1inside and save. - Setup a switch in Home Assistant to monitor mounted volume
nas_available_sw:
command_on: "echo -e '1' > /media/thisisnas"
command_off: "echo -e '1' > /media/thisisnas"
command_state: "grep -c '1' /media/thisisnas"
value_template: "{{ value == '1' }}"- Download my 1.1GB image https://drive.google.com/file/d/18PlE-wAlc_snZpq1v-BJUUFiKxyUXlO-/view?usp=share_link
- Mount it to the HA VM, boot VM from image,press enter on grub menu.
- Wait 1-2minutes until it will write FINISHED on the screen and it will shutdown after few seconds.
- There will be a message to press enter to finish shutdown process.
- Remove the ISO from VM and run the Home Assistant VM without the iso
If you want the machine not to shutdown after the process is finish for debuging, write this command on boot
touch /tmp/stopIf by any reason there would be a problem, go look for logs located in /tmp/ folder or in home assistant custom_components/hanasmount
Just to be 100% sure any accounts can be hacked and somebody can put malicious code inside my repository
Here is a tutorial how to make your own bootable image for Home Assistant NAS mount. Or just fork the repository so you will keep the md5 checksum
hanasmountdebian-live-11.6.0-amd64-standard.md5 and link for the file.
Reuploaded file's google link can't be the same link if somebody/me change the file in the future.
Boot to any debian host/vm
Read: https://dev.to/otomato_io/how-to-create-custom-debian-based-iso-4g37 or https://web.archive.org/web/20220425175043/https://dev.to/otomato_io/how-to-create-custom-debian-based-iso-4g37
run command:
sudo apt-get update && sudo apt-get install -y xorrisoGoto Downloads folder run command:
wget "https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-11.6.0-amd64-standard.iso"run commands:
sudo apt-get install squashfs-tools
sudo apt-get install -y fakeroot
sudo apt-get install isolinux
xorriso -osirrox on -indev "debian-live-11.6.0-amd64-standard.iso" -extract / iso && chmod -R +w isoCreate new folder unsquash in Downloads folder
mkdir unsquashcopy iso/live/filesystem.squashfs to new folder with command
cp iso/live/filesystem.squashfs unsquash/
cd unsquashrun commands inside unsquash folder:
sudo unsquashfs filesystem.squashfs
sudo chroot squashfs-root/Now you will be inside unsquashed root and you will see user changed to root run commands:
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
sudo apt-get update
sudo apt-get install squashfs-toolsdownload execute.sh script from my repository to /root/
wget "https://raw.githubusercontent.com/ukrolelo/hassos_nas_mount/main/execute.sh"((Check it on malicious code))
chmod 700 /root/execute.sh
chmod +x /root/execute.shnano /var/spool/cron/crontabs/rootinsert below text:
@reboot root sleep 30 ; /root/execute.sh > /tmp/stdout.txt 2> /tmp/stderr.txt &Then ending the image preparation with commands:
echo ' ' > /etc/resolv.conf
apt-get clean
history -c
exitNow we left squashfs environment To create new squashfs from the folder that we made changes
sudo mksquashfs squashfs-root/ filesystem.squashfs -comp xz -b 1M -noappendcopy new created filesystem.squashfs file to the iso/live location with command
cp filesystem.squashfs ../iso/live/Go to downloads directory and run this command:
sudo xorriso -as mkisofs -r -V "Home assistant NAS mount" -o hanasmountdebian-live-11.6.0-amd64-standard.iso -J -l -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img \
-no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin iso/boot isoTake new created ISO and mount&boot on Home Assistant VM
My notes for future refference:
echo $(date -u) "Some message or other"Mount NAS share directly to HASS OS It is based on GPARTED iso image
Important!!! After HAOS 8.5 or 9.0 There are changes to sda3 and sda5. Temp workaround is script from dev branch https://raw.githubusercontent.com/ukrolelo/hassos_nas_mount/dev/execute.sh
Instructions:
Download image
https://drive.google.com/file/d/1rUSd2u5P51MLITZ1rCESJgEF90mY9O9V/view?usp=sharing
BOOT GPARTED image
press enter on grub screen
then
hit 3x enter
check what letters are the disks should be sda
open terminal and execute the script with
/home/execute.sh
This is the image that i made myself:
if you need, network settings on desktop and press dhcp enter
network should work rightaway
If you want to do your own image you need to insert this comands and then recompile the image
sudo apt update
sudo apt-get install squashfs-tools
https://gparted.org/add-packages-in-gparted-live.php
gparted-live.md5
Contains md5 checksum
d8f187a8a8804cf0f71951d4b48cc77e
*gparted-live.iso