Automatically bind mount NFS/SMB/CIFS share to Proxmox LXC container after reboot with bash script

  Рет қаралды 4,941

Automation Avenue

Automation Avenue

Күн бұрын

Пікірлер: 48
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
We will write a bash script and create a cron job that will automatically mount bind our NAS shares (NFS/SMB/CIFS) running on Proxmox VM to unprivileged LXC containers (also on Proxmox) after reboot. == TIMESTAMPS == 0:00 bind mount that works after reboot 14:00 writing bash script 19:35 creating cron job Commands used in the video: *************************** mount.sh script: #!/usr/bin/env bash qm start 202 until [ "$(qm status 202 | awk '{print $2}')" == "running" ]; do sleep 2 done sleep 20 mount -t cifs -o user=smbuser,password=marekpass //192.168.1.202/MiniPC /mnt/minipc sleep 20 lxc-start -n 203 ************************** crontab -e: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin @reboot /usr/bin/bash /opt/scripts/mount.sh You might also want to watch following videos: Read AND WRITE from unprivileged LXC container to Proxmox SMB / NFS / CIFS / NAS share: kzbin.info/www/bejne/eXfLnZpspseca68 Bind mount NAS (CIFS/SMB/NFS) shares to Unprivileged LXC Proxmox container: kzbin.info/www/bejne/l3bdoJKra7h9qc0 Please let me know if you have any questions. Marek
@robip
@robip 8 күн бұрын
It's great to see technical videos where mistakes happen. 9/10 times we are likely to make the same ones and seeing your troubleshooting methodology helps everyone. Bravo
@Automation-Avenue
@Automation-Avenue 8 күн бұрын
Very true! Thats why I dont cut them out during editing. Thank you for watching :) Marek
@cozmickitty7730
@cozmickitty7730 4 ай бұрын
Most frustrating thing for me(newb) is passing devices/data to containers. This is helpful, thanks
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
I agree, it takes a while to get used to. Thank you for watching! Marek
@bretlinden8248
@bretlinden8248 3 ай бұрын
Thank you for another great video. Explained very well, easy to follow. All I had to do was pay attention, and translate my own information in place of your specific info and I'm good. I subscribed. We need more guys like you.
@Automation-Avenue
@Automation-Avenue 3 ай бұрын
Happy I could help, thank you for watching and commenting :)
@jameso7826
@jameso7826 4 ай бұрын
Very informative, I like the style of your video I would suggest for anyone that comes here and follows your steps to ls the mount from outside the mount directory during testing. That way you avoid blocking the mount from happening by having that directory locked by your terminal. i.e: ls -la /mnt/minipc instead of cd /mnt/minipc ls -la
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
It's a great advise ! Well - what can I say - my video PROVES that YOUR way is the way to run that command :) Thank you for watching and for taking the time to comment ! Marek
@moekachee1168
@moekachee1168 Ай бұрын
Wow, I can't believe it has taken me this long to find your channel. You are amazing! Thank you so much for this information. You have a new Subscriber.
@Automation-Avenue
@Automation-Avenue Ай бұрын
You are so welcome! Thank you for watching and subscribing :) Marek
@codescholar7345
@codescholar7345 4 ай бұрын
Bind to container can be done in the GUI too by adding mount point to resources. Thanks the the previous video, I needed it’s solution yesterday!
@Automation-Avenue
@Automation-Avenue 2 ай бұрын
Hi Please see this new video, I believe you might be interested in this one too, its about setting write permissions for unprivileged LXC container: kzbin.info/www/bejne/eXfLnZpspseca68 Please let me know what you think. Thank you for your comment. Marek
@mobilifone
@mobilifone Ай бұрын
Hi Marek, really good explanation and useful. I had just to introduce a sleep 60 (at least) statement at the beginning of the bash file because in my installation (maybe not very fast) at reboot time the lxc container manager is not ready and the script try to start the container (or vm) too early with the result that the container or vm (never started) still stopped and never became running allowing the rest of the script to flow. That's why I need to delay the execution
@Automation-Avenue
@Automation-Avenue Ай бұрын
Yes mate, whatever works for you. Every single system will respond slightly different way, glad you found out what was the issue and how to fix it. Thank you for watching and commenting :) Marek
@maxcorfield328
@maxcorfield328 2 ай бұрын
What a fantastic guide! I do have a quick question. I have 2 different LCXs that require different SMB mount points that I have working thanks to your last video. The question is do I just create 2 different .sh scripts and add the crontab lines twice ?
@Automation-Avenue
@Automation-Avenue 2 ай бұрын
Hi I dont think there is right or wrong approach to that, you can add more instructions to existing script or you can create separate bash script and run both in cron. Its up to you really. Thank you for watching and commenting!
@safwaniiiiiiz
@safwaniiiiiiz 4 ай бұрын
Thank you so much sir, Really helpful topic
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
I am glad I can help! Thank you for your comment ! Marek
@hongjunha5987
@hongjunha5987 2 ай бұрын
Thank you for the video. It worked well for me.
@Automation-Avenue
@Automation-Avenue 2 ай бұрын
You're welcome! Thank you for watching. Marek
@dermagdermag7642
@dermagdermag7642 4 ай бұрын
Great video and very helpful - thanks! Could you maybe tell / show how to amend the script to mount / unmount an external HDD when starting the PLEX/Jellyfin container? This way you would not need to have an external HDD attached to the Homeserver all the time to watch a movie every now and then.. This would be super helpful - I did not find any tutorials how to do this.. Thanks!
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
Hi! If you need to mount your disk only when you need to use it then I would check` autofs` tool rather than standard mount which is very limited for that specific use case. Please see more here: help.ubuntu.com/community/Autofs Hope that helps ! Thanks for watching - Marek
@MaruPlaysMP
@MaruPlaysMP Ай бұрын
This is an excellent explanation, I really like the style of your videos and how you go through everything step by step. I watched your other video about this issue and I'm glad to have found this one as well. But for me, I run into another issue when I set up everything: I recently had to reboot my proxmox server and before the solution with mounting from my omv worked but now it doesn't anymore, so I went through it again and tried mounting it manually again, but I get the following error: mount error(115): Operation now in progress I googled but found nothing that could help me resolve my problem. Also the man-page didn't help me at all. Do you have any tips or even a solution for this problem? My OMV is up and running just fine, so is the jellyfin container.
@Automation-Avenue
@Automation-Avenue Ай бұрын
Hi - have you seen this video maybe? kzbin.info/www/bejne/fqaUl4xmYqupjKc - its my video for this specific task - mounting after Proxmox reboot. Please have a look. Thank you for your comment ! Marek
@MaruPlaysMP
@MaruPlaysMP Ай бұрын
@@Automation-Avenue That's the video I was watching but the error keeps coming up for me, so the mount doesn't work. Not with the script and also not manually
@Automation-Avenue
@Automation-Avenue 29 күн бұрын
Hmmm, I never came across that, with a bit of googling it looks like usually the issue is missing route or - for some people - leaving the command running for over 10 minutes resulted with mount eventually being created. I guess you tried both solutions already? Is anything happening / some errors etc or is it just hanging?
@MaruPlaysMP
@MaruPlaysMP 19 күн бұрын
@@Automation-Avenue Sorry for getting back so late. I tried all solutions I could find but still the error persists. It's also just this error and as you said it is just hanging. It's a little frustrating by now
@brenth560
@brenth560 Ай бұрын
Should options be set start at boot = no or yes? Thanks so much for sharing love your videos
@Automation-Avenue
@Automation-Avenue Ай бұрын
Hi I left the default option there - so 'No' for both LXCs and VMs. Thank you for watching :) Marek
@brenth560
@brenth560 Ай бұрын
@@Automation-Avenue this is my cron output Oct 09 05:17:01 homelab CRON[3527053]: pam_unix(cron:session): session closed for user root Oct 09 06:17:01 homelab CRON[3549468]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0) Oct 09 06:17:01 homelab CRON[3549468]: pam_unix(cron:session): session closed for user root Oct 09 06:25:01 homelab CRON[3552492]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0) Oct 09 06:25:01 homelab CRON[3552493]: (root) CMD (test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; }) Oct 09 06:25:01 homelab CRON[3552492]: pam_unix(cron:session): session closed for user root Oct 09 07:17:01 homelab CRON[3571792]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0) Oct 09 07:17:01 homelab CRON[3571792]: pam_unix(cron:session): session closed for user root Oct 09 08:17:01 homelab CRON[3594087]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0) Oct 09 08:17:01 homelab CRON[3594087]: pam_unix(cron:session): session closed for user root
@Koko-badu
@Koko-badu 2 ай бұрын
Hi, Tnx for your vid. I'm affraid your mounted folder inside LXC container 203 will be read only. Good for Jellyfin, but not good enough for many other purposes. Owner of the folder inside LXC will be 'nobody'.
@Automation-Avenue
@Automation-Avenue 2 ай бұрын
Hi - yes, many people mentioned that, so I created a video how to change the configuration to be able to read AND WRITE from unprivileged container: kzbin.info/www/bejne/eXfLnZpspseca68 I hope that helps Please let me know if its clear enough or maybe something can be improved. Thank you for your input Marek
@Koko-badu
@Koko-badu 2 ай бұрын
Wow, I'm impressed. Impressed a lot. Not only about the speed that the new video came on line, but first of all about the knowledge. I’m convinced that the vid content is just a bit of your total know how. That earns respect. No, I don’t have any suggestions for improvement since it is through and through good. All the usual yt bells, likes, subscription are pressed 😊 I’ll look at other vids of yours, and perhaps come with some suggestions, but only with the goal to make vids even better. Positive feedback with other words. Thanks a ton!!
@Automation-Avenue
@Automation-Avenue Ай бұрын
Thank you for your feedback, much appreciated :) Marek
@Jungl3B0b
@Jungl3B0b 3 ай бұрын
First of all: Big Thanks to this 2 videos. I have 2 thinks I'm struggeling with. 1) you wrote ...dev/null... in the cronjob but not in your video description. Does this mean you don't need it or is it just missing in the description? and the big second one. For me it does not work because of: -bash: /opt/scripts/mount.sh: No such file or directory but its there..... Someone got a hint for me?
@Automation-Avenue
@Automation-Avenue 3 ай бұрын
Hi Yes sorry, only after publishing the video I realized that you cant use angled brackets in the description, so I had to drop that portion of config but yes - it should not have any influence on the script itself, it was just a simple redirection. You might also be interested in the new video I have just released - Bind mounts vs Volumes - what are they? What's the difference between them? Link below: kzbin.info/www/bejne/oZasf62bjtiSosU Kind regards Marek
@monish05m
@monish05m 4 ай бұрын
Just add mounting options to fstab in host and bind mount that location to lxc container.
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
Can you elaborate? How that would work after reboot when the VM needs to be started first and be fully up and running before you mount anything? I know there are some other possibilities, I am aware you can achieve something similar with autofs, but not sure how you can do that with simple entry in fstab file as I tried and it simply doesnt work so please let me know. Thank you for your comment!
@Mad0ptiX
@Mad0ptiX 2 ай бұрын
@@Automation-Avenue /etc/fstab
@onoitsu2-
@onoitsu2- 21 күн бұрын
@@Automation-Avenue you could change the fstab mount options for this to contain nofail, so proxmox can boot right and then ensure there is enough delay before your Jellyfin container starts, setting a manual autostart delay of something reasonable like 10-20 seconds.
@neilharris
@neilharris 4 ай бұрын
Hi, i have followed the instructions, but when i try to connect to the share it is Read Only. is there anyway to make this writable
@alishernabiev2744
@alishernabiev2744 3 ай бұрын
@neilharris try to change the permission on the folder "chmod +x /your/folder
@Automation-Avenue
@Automation-Avenue 2 ай бұрын
Hi - yes thats the default behaviour, please see my new video which shows how to configure unprivileged container uid and gid to be able to read AND WRITE :) Read AND WRITE from unprivileged LXC container to Proxmox SMB / NFS / CIFS / NAS share: kzbin.info/www/bejne/eXfLnZpspseca68 Hope that helps. Please let me know if you have any further questions. Thank you for watching and commenting Marek
@kristof9497
@kristof9497 4 ай бұрын
Thanks.
@Automation-Avenue
@Automation-Avenue 4 ай бұрын
You're welcome !
NAS Shares On LXC - Unprivileged - Jellyfin Example
13:35
Jim's Garage
Рет қаралды 40 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 18 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 95 МЛН
Real Man relocate to Remote Controlled Car 👨🏻➡️🚙🕹️ #builderc
00:24
When u fight over the armrest
00:41
Adam W
Рет қаралды 32 МЛН
Docker on Proxmox LXC 🚀 Zero Bloat and Pure Performance!
20:53
SmartHomeBeginner
Рет қаралды 62 М.
Proxmox, VM Redundancy Using ZFS Replication
30:21
Tech Tutorials - David McKone
Рет қаралды 4 М.
Running a NAS on Proxmox, Different Methods and What to Know
18:47
ElectronicsWizardry
Рет қаралды 58 М.
You should be using Proxmox Backup Server
10:38
Techno Tim
Рет қаралды 64 М.
Moving My Dockers to Proxmox LXC Containers
13:28
Novaspirit Tech
Рет қаралды 30 М.
I switched to Linux 30 days ago... How did it go?
28:46
Craft Computing
Рет қаралды 281 М.
The intro to Docker I wish I had when I started
18:27
typecraft
Рет қаралды 260 М.
Passing Storage to a Container Getting Started with Proxmox 8
24:38
virtualize everything
Рет қаралды 32 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 18 МЛН