How to rename a MOUNT (mounted shared folder from Windows named mnt) - linux

How to rename a MOUNT (mounted shared folder from Windows named mnt)?
How to rename mnt?
This is the command I used on linux command tool to mount my Shared folder from windows pc to a linux controller.
# mount -t cifs -o username=myusername,password=mypassword //10.80.50.50/Share /mnt
So my mounted Shared folder is now name mnt... How to rename it?
Thanks...

Follow these steps:
Unmount:
umount /mnt
Create another folder:
mkdir /my_new_mount
Mount again:
mount -t cifs -o username=myusername,password=mypassword //10.80.50.50/Share /my_new_mount
Update in /etc/fstab

Related

Cannot add data to Azure /dev/sdb1

I access my Azure VM on linux. Using df -kh, I can see my /dev/sdb1 temporary disk
(https://i.stack.imgur.com/zKXmQ.png)
$ sudo -i blkid
...
/dev/sdb1: PARTUUID="7ec06285-01"
...
I want to use it to store data however, despite, googling and reading the Azure documentation, I did not find any way to add data to it.
cp test /dev/sdb1
cp: cannot create regular file '/dev/sdb1': Permission denied
sudo cp test /dev/sdb1
sudo: unable to resolve host HubertProduction: Temporary failure in name resolution
mkdir /dev/sdb1/TEST
mkdir: cannot create directory ‘/dev/sdb1/TEST’: Not a directory
How can I use /dev/sdb1 to store data and access to them?
It is mounted so do I need to format it? if so how?
All the post I found are about the fact this is a temp storage with no backup: I understand it and this is not the issue here.
I created one Linux Ubuntu VM and created one directory and mounted it on sdb1 temporary disk like below
Without sudo :-
mkdir /data2
mkdir: cannot create directory ‘/data2’: Permission denied
With sudo, It worked:-
sudo mkdir /data2
Mounted dir data2 on sdb1
sudo mount /dev/sdb1 /data2
cd /data2
Accessed data2
siliconuser#siliconvm:/data2$ lsblk
Now you can directly create files in /data2 and those files will be stored in the temporary disk sdb1
Refer below :-
You do not need to format the disk as it is already mounted on Azure Linux VM. But you can change its mounted directory from mnt to dir.
You can create the file by moving to /mnt directory where temporary disk sdb1 is mounted by default after vm creation without a need to mount sdb1 to another directory :-
Refer below :-
Its also showing DATALOSS_WARNING readme file which states that the files created under this directory will be deleted as this is a temporary disk.
Reference :-
https://amalgjose.com/2021/09/01/how-to-add-a-new-disk-to-a-linux-server-without-downtime-or-reboot/

Blob Storage Permament mounting in redhat linux

I have a linux server where i had mounted blog storage but it is temporary mount everytime i restart the machine i have to run this below command manually
sudo blobfuse /sfp/publicstorage134/blobstorage123 --tmp-path=/mnt/rec/mountpath --config-file=/user1/connection_sf.cfg -o attr_timeout=180 -o entry_timeout=120 -o negative_timeout=180 -o allow_other
How can i make this stoarge mount permanently instead of mounting with this command after every restart. Is it possible to put this in /etc/fstab?
The recommendation is to create a script, such as mount.sh or you can also add blobfuse directly to /etc/fstab
Add the following line to use mount.sh:
/<path_to_blobfuse>/mount.sh </path/to/desired/mountpoint> fuse _netdev
OR
Add the following line to run without mount.sh:
blobfuse /home/azureuser/mntblobfuse fuse delay_connect,defaults,_netdev,--tmp-path=/home/azureuser/tmppath,--config-file=/home/azureuser/connection.cfg,--log-level=LOG_DEBUG,allow_other 0 0

How to mount azure file share to existing directory on linux vm

I have an existing directory on an Ubuntu 16.04 LTS virtual machine at /etc/elasticsearch. I also have created a file share in azure. I am able to mount file share to the VM successfully when the mount point is a new directory. However, when I attempt to mount the file share to /etc/elasticsearch, an existing directory that contains data, the existing directory's data gets overwritten completely by the contents of the file share. This causes me to lose the data that previously existed in /etc/elasticsearch, which I obviously do not want. I want the file share to be added in addition to the existing data in /etc/elasticsearch.
Here is what I tried:
if [ ! -d "/etc/smbcredentials" ]; then
sudo mkdir /etc/smbcredentials
fi
if [ ! -f "/etc/smbcredentials/credentials.cred" ]; then
sudo bash -c 'echo "username=username" >> /etc/smbcredentials/credentials.cred'
sudo bash -c 'echo "password=password" >> /etc/smbcredentials/credentials.cred'
fi
sudo chmod 600 /etc/smbcredentials/credentials.cred
sudo bash -c 'echo "//pathtofileshare/analysis /etc/elasticsearch cifs nofail,vers=3.0,credentials=/etc/smbcredentials/credentials.cred,dir_mode=0777,file_mode=0777,serverino" >> /etc/fstab'
sudo mount -t cifs //pathtofileshare/analysis /etc/elasticsearch -o vers=3.0,credentials=/etc/smbcredentials/credentials.cred,dir_mode=0777,file_mode=0777,serverino
Link to file share documentation
Many thanks in advance for any help
I don't believe this is an issue, it just how Linux mount works
http://man7.org/linux/man-pages/man8/mount.8.html
The previous contents (if any) and owner and mode of dir become invisible, and as long as this filesystem remains mounted, the pathname dir refers to the root of the filesystem on device.

How do I use a Samba server location for GOPATH?

I am trying to set my GOPATH to a shared network folder. When I enter
export GOPATH=smb://path/to/shared/folder
I get:
go: GOPATH entry is relative; must be absolute path: "smb".
Run 'go help gopath' for usage.
I've also tried to prefix the path w/ "/" but then it tries to make a folder in root.
thx!
there is only one solution for this:
Map ( mount) a Samba server file path as a Local Disk Drive ( local path),
then set GOPATH to this local path:
Mounting SMB share on local folder by using smbmount command (smbmount is deprecated):
smbmount //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname
Example :
smbmount //192.168.0.1/share1 /mnt –o username=steev,workgroup=test
Mounting SMB share by using mount command
mount –t smbfs ipadd:/sharename /mountpoint –o username=userid,workgroup=workgroupname
Or
mount –t smbfs //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname
Example :
mount –t smbfs 192.168.0.1:/share1 /mnt –o username=surendra,workgroup=test
ref:
http://www.linuxnix.com/8-ways-to-mount-smbfs-samba-file-system-in-linux/
https://askubuntu.com/questions/232998/how-do-i-install-smbmount
http://www.howtogeek.com/116309/use-ubuntus-public-folder-to-easily-share-files-between-computers/
and for Windows: https://serverfault.com/questions/6079/how-can-i-mount-an-ftp-to-a-drive-letter-in-windows
You need to mount the Samba share to a folder on your machine:
$ mkdir /mnt/samba
$ smbmount smb://path/to/share /mnt/samba
Of course you may need to use switches on the smbmount command to provide username, password, workgroup, etc., depending on the configuration of the Samba share you're trying to access. Once you've mounted the share you can then do
$ export GOPATH=/mnt/samba
And as far as Go is concerned the files in the Samba share will be located on your local machine.

Locked out of cifs mounted storage

I've been using this line in /etc/fstab for mounting a storage device to my host:
//url.to-my-storage.com/mystorage /mnt/backup cifs
iocharset=utf8,rw,credentials=/etc/backup-credentials.txt,uid=1000,gid=1000,file_mode=0660,dir_mode=0770
0 0
I was mounting it to another host, and I ran this to protect the files from change through the new host:
chmod -R 444 /mnt/backup
(I tried to protect the storage from writing from this host, which turned out to change the mode of all the storage files)
I assume the missing executable permissions what causing me this:
$ sudo mount -a
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I tried unmounting and mounting again, that didn't help, got the same permission error when using the mount command.
ls the dir shows this:
$ ls -la /mnt/backup
?????????? ? ? ? ? ? backup
HELP !
Dismounting a "Locked Out" Network Drive
To dismount a "locked out" network drive, you can try to force the unmount:
umount -f -t cifs /mnt/backup
If you are having trouble dismounting a drive, make sure that you don't have a console open somewhere where the current working directory (CWD) on the drive which you are trying to dismount, or have a file open in an editor or player somewhere or such.
Properly Mounting a Network Drive
You should add your permissions in your mount options rather than trying to apply them afterwards. You would want to replace these mount options:
rw,file_mode=0660,dir_mode=0770
with
ro
Currently you are mounting your CIFS drive as read-write (rw), giving files read-write permission (file_mode=0660) and directories read-write-execute (dir_mode=0770). Simply mounting the drive as read-only (ro) should suffice. (If you do need to fine tune the file and dir modes, rather use umask.)
I would also advise you to double check whether you are using uid and gid correctly: if the user ID or group ID used gets deleted, that could also lead to problems.
References
https://linux.die.net/man/8/mount
https://en.wikipedia.org/wiki/File_system_permissions
https://oracletechdba.blogspot.com/2017/06/umount-lsof-warning-cant-stat-cifs-file.html
https://stackoverflow.com/a/40527234/171993

Resources