Cannot add data to Azure /dev/sdb1 - linux

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/

Related

Unable to change directory or file permission [chmod question]

I am trying to change the permission of a file to 444 (read-only).
This directory resides in a NTFS drive. All files in this drive seem to be owned by root.
This is the present permissions for the directory.
drwxrwxrwx 1 root root 0 Jul 23 11:41 xxx_directory
I've tried sudo bash and then execute chmod 444 xxx_directory to no avail.
The expected outcome was dr--r--r-- for xxx_directory.
Thoughts? Thank you.
The directories need at least R-X
First, create a mount point in a terminal using 'mkdir'. Then, type the following line to mount the partition with options 'permissions':
sudo mount /dev/sdXN -t ntfs-3g -o permissions [Mount point]
Example:
sudo mount /dev/sdb1 -t ntfs-3g -o permissions /media/Data/
Then, you will be able to edit the permissions of the files on the NTFS partition with 'chmod' and 'chown' !
Check thia reference LINUX - MOUNT NTFS PARTITION WITH PERMISSIONS
You should at least require the x permission for directories otherwise you won't be able to cd into it.
You can specify the permissions (via fmask and dmask) while mounting the partition ( or in fstab if an entry is there).
An example of an fstab entry :
#mounting by UUID
UUID=<partition UUID> /mount/point ntfs-3g user,uid=1000,gid=1000,dmask=0022,fmask=0033
This would give all directories in that partition drwxr-xr-x parmissions. Any file created will get .rw-r--r-- permissions. And the ownership would be by the user with uid 1000 so he can change permissions (without sudo)

Ubuntu: create a new partition on /dev/sdb1 (which still has 1.5tb of free space) and mount it on /tmp/

As you can see /dev/sda is mounted to /. Thats where /tmp/ is located as shown image. Since It is running out of space on my / partition,I can't install caffe, and there is error: No space left on device.
Now I want to create a new partition on /dev/sdb1 (which still has 1.5tb of free space) and mount it on /tmp/.
Could you guys tell me how to create a new partition for solving this issue by linux command.
thanks
Just give the following command
To unmont the existing volume give the following
sudo umount /dev/sdb1
Note:- Make sure no process is using the particular directory
Then again mount it to /tmp
sudo mount /dev/sdb1 /tmp
or
cd /dev/ && sudo mount sdb1 /tmp

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

Mount another virtual hard disk always belongs root owner, why?

Environment is in virtual box,ubuntu 12.04. It has 2 disks, /dev/sda1 and /dev/sdb1 are both ext4 type filesystem.
Since /dev/sdb1 is add after system installed, so I want to mount it manually. I'd try this command:
sudo mount -o user,defaults /dev/sdb1 ~/project
No errors report. Then I get mount info by mount:
/dev/sdb1 on /home/igsrd/project rw,noexec,nosuid,nodev
But when I ls -l to see /home/igsrd I found its permission is still belongs root, so I can't touch anything in it. Why it still belongs root?
I have another machine running ubuntu 12.04,too. I mount another partition with same option will be fine, correct permission(ownership). Are any differences between them?
*nix permissions on a filesystem that supports them natively, e.g. ext4, will be maintained regardless of how it is mounted when using a proper filesystem driver, e.g. the native ext4 driver built into Linux.
Why don't you just (while still root) do this:
chown -R <your-user-name> ~<your-user-name>/project
?

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

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

Resources