[Solved] Connect network share at boot
[Solved] Connect network share at boot
Hi,
I'm new to Porteus and installed 4.0 on a 9 year old Igel thinclient, runs like a charm :-)
Now I want to connect a network share (Windows domain, on a Synology NAS) at boot up. Therefore I edited
/etc/rc.d/rc.local with this onliner:
mount.cifs \\IP-Address/share /mnt/share -o /root/.smbcredentials
.smbcredentials looks like this:
user=windows-user
password=password
domain=windows-domain
If I'm starting /etc/rc.d/rc.local with guest account, mount.cifs isn't found. If I do this as root, everything works as it should.
Rebooting the system, the network share isn't connected. I copied /etc/rc.d/rc.local to rootcopy-dir with no luck.
Any ideas? I would be really happy to get this running.
I'm new to Porteus and installed 4.0 on a 9 year old Igel thinclient, runs like a charm :-)
Now I want to connect a network share (Windows domain, on a Synology NAS) at boot up. Therefore I edited
/etc/rc.d/rc.local with this onliner:
mount.cifs \\IP-Address/share /mnt/share -o /root/.smbcredentials
.smbcredentials looks like this:
user=windows-user
password=password
domain=windows-domain
If I'm starting /etc/rc.d/rc.local with guest account, mount.cifs isn't found. If I do this as root, everything works as it should.
Rebooting the system, the network share isn't connected. I copied /etc/rc.d/rc.local to rootcopy-dir with no luck.
Any ideas? I would be really happy to get this running.
- Ed_P
- Contributor
- Posts: 8341
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Connect network share at boot
mount.cifs is not a guest command.
Would a sudo command help? Maybe a script with the sudo command that the /etc/rc.d/rc.local file would reference.
mynetshr.sh
Code: Select all
guest@porteus:~$ mount.cifs
bash: mount.cifs: command not found
guest@porteus:~$ su
Password:
root@porteus:/home/guest# mount.cifs
Usage: mount.cifs <remotetarget> <dir> -o <options>
mynetshr.sh
Code: Select all
#!/bin/sh
echo guest | sudo -S mount.cifs \\IP-Address/share /mnt/share -o /root/.smbcredentials > /dev/null 2>&1 &
Ed
- Blaze
- DEV Team
- Posts: 3869
- Joined: 28 Dec 2010, 11:31
- Distribution: ⟰ Porteus current ☯ all DEs ☯
- Location: ☭ Russian Federation, Lipetsk region, Dankov
- Contact:
Connect network share at boot
Hi JeWe.
Welcome on the board!
How about setuid?
Open terminal and run these commands:
Welcome on the board!
How about setuid?
Open terminal and run these commands:
Code: Select all
su
toor
chmod u+s /sbin/mount.cifs
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
Connect network share at boot
Thanks for your answers!
@Ed
Not sure, if I get this right. I made the little shell script and saved it in /home/guest. Then I edited /etc/rc.d/rc.local
sh /home/guest/mynetshr.sh
After a reboot, network share isn't mounted. With user guest, I can start rc.local or the script mynetshr.sh. No effect.
@Blaze
mount.cifs already got enough permission (755). As @Ed stated, I can't execute this command, so I simply copied it to /bin.
Execute my command, it says
Permission denied: No match for Mountpoint found in /etc/fstab
Quite clear, guest doesn't have access to /root
Executing mount.cifs without any option works.
@Ed
Not sure, if I get this right. I made the little shell script and saved it in /home/guest. Then I edited /etc/rc.d/rc.local
sh /home/guest/mynetshr.sh
After a reboot, network share isn't mounted. With user guest, I can start rc.local or the script mynetshr.sh. No effect.
@Blaze
mount.cifs already got enough permission (755). As @Ed stated, I can't execute this command, so I simply copied it to /bin.
Execute my command, it says
Permission denied: No match for Mountpoint found in /etc/fstab
Quite clear, guest doesn't have access to /root
Executing mount.cifs without any option works.
- Ed_P
- Contributor
- Posts: 8341
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Connect network share at boot
JeWe did you make the script executable.
Test it by executing it in a terminal window.
If it doesn't work remove the redirect at the end so any error msgs will be visible.
The copy you have in /bin should be removed so it executes the correct version.
Code: Select all
chmod +x mynetshr.sh
Code: Select all
./mynetshr.sh
The copy you have in /bin should be removed so it executes the correct version.
Ed
Connect network share at boot
JeWe, rc.local is executed as root at the end of bootup, so it is probably not a permission issue.
However, during boot up, the PATH is not set (since root user has not yet logged in). Hence you need to call the mount.cifs command using the full path, that is: /sbin/mount.cifs
Some other things:
1. In your command, you start with \\IP-Address. The mount.cifs example I saw in the manual has forward slashes //.
2. Also, from the manual it does not say if the -o options can come from a file. Try passing it directly.
3. You are trying to mount at /mnt/share. By default Porteus does not have this directory. Is this directory already present in your system during bootup? If not, you need to also create this directory in your rc.local before you mount it.
Maybe one of the above also could have made the command to fail at bootup. It would also be helpful if you redirect stdout and stderr of the command to a file, so that if the command still fails, you can read out the file to see what error it says.
So, put this in you rc.local (after you create /mnt/share if that does not exist) and copy it to rootcopy:
However, during boot up, the PATH is not set (since root user has not yet logged in). Hence you need to call the mount.cifs command using the full path, that is: /sbin/mount.cifs
Some other things:
1. In your command, you start with \\IP-Address. The mount.cifs example I saw in the manual has forward slashes //.
2. Also, from the manual it does not say if the -o options can come from a file. Try passing it directly.
3. You are trying to mount at /mnt/share. By default Porteus does not have this directory. Is this directory already present in your system during bootup? If not, you need to also create this directory in your rc.local before you mount it.
Code: Select all
/bin/mkdir /mnt/share
So, put this in you rc.local (after you create /mnt/share if that does not exist) and copy it to rootcopy:
Code: Select all
/sbin/mount.cifs //IP-Address/share /mnt/share -o user=windows-user,password=password,domain=windows-domain &> /root/mount_log.txt
- Blaze
- DEV Team
- Posts: 3869
- Joined: 28 Dec 2010, 11:31
- Distribution: ⟰ Porteus current ☯ all DEs ☯
- Location: ☭ Russian Federation, Lipetsk region, Dankov
- Contact:
Connect network share at boot
JeWe, open terminal and run these commands:
Use /media path for mount your Windows partitions, because you will see your mounted partition at the left sidebar of your file manager.
With this permission you not able to mount partitions as guest user
Cheers
Code: Select all
su
toor
mkdir /media/share
echo -e username=windows-user\\npassword=password\\ndomain=windows-domain > /home/guest/.smblocal1
chmod 400 /home/guest/.smblocal1
echo 'echo -e \\n# Local partitions:\\n//IP-Address/share /media/share cifs credentials=/home/guest/.smblocal1,dir_mode=0777,file_mode=0777,users 0 0 >> /etc/fstab' >> /etc/rc.d/rc.local
chmod u+s /sbin/mount.cifs
cat /dev/null > ~/.bash_history && history -c
reboot
Code: Select all
-rwxr-xr-x 1 root root 39560 сен 27 2017 /sbin/mount.cifs*
but if you apply setuid via chmod 4755 /sbin/mount.cifs you will able to do this.This program is not installed setuid root - "user" CIFS mounts not supported.
... do not do this.
Cheers
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
Connect network share at boot
Really big thanks to everyone for your kind help!
@jssouza
Logging the output of the mount leads to the solution:
mount error (101): Network is unreachable
So I followed this one:
https://superuser.com/questions/1180988 ... -of-system
Created a script and started it from /etc/rc.d/rc.local, works!
Case closed, surely I'll be back with other dumb questions :-)
@jssouza
Logging the output of the mount leads to the solution:
mount error (101): Network is unreachable
So I followed this one:
https://superuser.com/questions/1180988 ... -of-system
Created a script and started it from /etc/rc.d/rc.local, works!
Case closed, surely I'll be back with other dumb questions :-)