/mnt/で 'mkdir'を実行できず、 'chmod'を実行できません。

/mnt/で 'mkdir'を実行できず、 'chmod'を実行できません。

私はフォローアップをしています。このガイド私のUbuntu AzureホスティングVMでは/mnt/。実行すると、次のエラーメッセージが表示され続けますsudo mkdir /mnt/test/

mkdir: cannot create directory ‘/mnt/test/’: Operation not permitted

これを試みると、わずかに異なるエラーメッセージが表示されましたcd /mnt/

-bash: cd: /mnt/: Permission denied

次のステップはディレクトリの権限を確認することでしたので、実行して次のようにsudo stat /mnt/しました。

File: /mnt/
Size: 4096          Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d  Inode: 2           Links: 6
Access: (0444/dr--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-02-17 14:19:48.658231668 +0000
Modify: 2021-02-08 12:34:19.906967600 +0000
Change: 2021-02-09 09:40:12.287101300 +0000
Birth: -

書き込み権限がないことを知って実行しましたが、次のsudo chmod 664 /mnt/エラーメッセージが表示されました。

chmod: changing permissions of '/mnt/': Operation not permitted

私はUnixに初めて触れたので、どうすればいいのかわかりません。追加のトラブルシューティング手順や解決策を教えてください。ありがとうございます。

コメントへの回答:

df /mnt出力:

Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sda1       32894736 49192  31151544   1% /mnt

grep | '/mnt'いくつかの編集情報を含む出力:

/dev/sda1 on /mnt type ext4 (rw,relatime,x-systemd.requires=cloud-init.service)
/dev/sda1 on /mnt/sdc1 type ext4 (rw,relatime)
/dev/sdc on /mnt/sdc type ext4 (rw,relatime)
//<azure storage account name>.file.core.windows.net/sih-workspace on /mnt/sih-workspace type cifs (rw,relatime,vers=3.0,cache=strict,username=**********,uid=0,noforceuid,gid=0,noforcegid,addr=<azure data centre IP>,file_mode=0777,dir_mode=0777,soft,persistenthandles,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,bsize=1048576,echo_interval=60,actimeo=1)

ベストアンサー1

ephemeral-disk-warning.dllを介してファイルを生成する愚かなシステムデバイスを使用してください。/mnt/DATALOSS_WARNING_README.txtsystemctl disable ephemeral-disk-warning.service

理由:

@chris-daviesのおかげで同じ状況に直面しました。コメント:

/mnt自体の他のマウントによって隠された/mntのサブディレクトリに複数のマウントがあるようです。あなたが望むものと期待していないことを決定する必要があります。私の提案は、最初のタスクは/ mntをアンマウントして他のタスクに再公開することです。しかし、私はあなたが使用しているAzureファイルシステムユーティリティについてよく知らないので、これは完全な答えではありません。

$ cat /etc/rc.local
mkdir /mnt/tmp
mount --bind /mnt/tmp /tmp
chmod 1777 /tmp
# shortly after booted
$ l /mnt
total 37K
drwxr-xr-x  5 root  root  4.0K Jan 14 08:46 .
drwxr-xr-x 19 root  root    26 Jan 14 01:22 ..
drwx------  2 root  root   16K Jan 14 08:46 lost+found
drwxrwxrwt  5 root  root  4.0K Jan 14 08:46 tmp
# just after systemd unit `ephemeral-disk-warning.service` started and failed
$ l /mnt
ls: cannot access '/mnt/.': Permission denied
ls: cannot access '/mnt/..': Permission denied
ls: cannot access '/mnt/lost+found': Permission denied
ls: cannot access '/mnt/tmp': Permission denied
total 0
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
d????????? ? ? ? ?            ? lost+found
d????????? ? ? ? ?            ? tmp

調査:

$ journalctl --no-pager --boot -g ephemeral
Jan 14 08:46:48 azure systemd[1]: Starting Write warning to Azure ephemeral disk...
Jan 14 08:46:48 azure ephemeral-disk-warning[3758]: /usr/sbin/ephemeral-disk-warning: 7: cannot create /mnt
Jan 14 08:46:48 azure audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=unconfined msg='unit=ephemeral-disk-warning comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Jan 14 08:46:48 azure root[3763]: Added ephemeral disk warning to /mnt
                                  /tmp/DATALOSS_WARNING_README.txt
Jan 14 08:46:48 azure systemd[1]: Finished Write warning to Azure ephemeral disk.
$ journalctl --no-pager --boot -u ephemeral-disk-warning
Jan 14 08:46:48 azure systemd[1]: Starting Write warning to Azure ephemeral disk...
Jan 14 08:46:48 azure ephemeral-disk-warning[3758]: /usr/sbin/ephemeral-disk-warning: 7: cannot create /mnt
Jan 14 08:46:48 azure ephemeral-disk-warning[3758]: /tmp/DATALOSS_WARNING_README.txt: Directory nonexistent
Jan 14 08:46:48 azure systemd[1]: Finished Write warning to Azure ephemeral disk.
Jan 14 08:46:48 azure ephemeral-disk-warning[3761]: chmod: cannot access '/tmp/DATALOSS_WARNING_README.txt': No such file or directory
Jan 14 08:46:48 azure ephemeral-disk-warning[3762]: chattr: No such file or directory while trying to stat /tmp/DATALOSS_WARNING_README.txt
$ systemctl cat ephemeral-disk-warning.service
[Unit]
Description=Write warning to Azure ephemeral disk
After=cloud-config.service
ConditionVirtualization=microsoft
ConditionPathIsMountPoint=/mnt
ConditionPathExists=/dev/disk/azure/resource-part1

[Service]
Type=oneshot
ExecStart=/usr/sbin/ephemeral-disk-warning
RemainAfterExit=yes
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target
$ cat /usr/sbin/ephemeral-disk-warning
#!/bin/sh
dev_resource=$(readlink -f /dev/disk/azure/resource-part1)
dev_resource_mp=$(awk '$1==R {print$2}' "R=${dev_resource}" /proc/mounts)
warn_file="${dev_resource_mp}/DATALOSS_WARNING_README.txt"

if [ ! -f "${warn_file}" ]; then
    cat > ${warn_file} <<EOM
WARNING: THIS IS A TEMPORARY DISK.

Any data stored on this drive is SUBJECT TO LOSS and THERE IS NO WAY TO
RECOVER IT.

Please do not use this disk for storing any personal or application data.

For additional details to please refer to the MSDN documentation at:
http://msdn.microsoft.com/en-us/library/windowsazure/jj672979.aspx

To remove this warning run:
    sudo chattr -i $warn_file
    sudo rm $warn_file

This warning is written each boot; to disable it:
    echo "manual" | sudo tee /etc/init/ephemeral-disk-warning.override
    sudo systemctl disable ephemeral-disk-warning.service

EOM

    chmod 0444 ${warn_file}
    chattr +i ${warn_file}
    logger "Added ephemeral disk warning to ${warn_file}"
fi
$ source <(head -n 4 /usr/sbin/ephemeral-disk-warning)
$ echo $warn_file
/mnt
/tmp/DATALOSS_WARNING_README.txt
$ echo chattr +i ${warn_file}
chattr +i /mnt
/tmp/DATALOSS_WARNING_README.txt

だからこれは別のものです。改行トラップその結果、全体が次/mntのように表示されます。不変最後に、古い/etc/rc.localスタイルの自動実行スクリプトを次のように変換しました。システム装置:

# https://unix.stackexchange.com/questions/471824/what-is-the-correct-substitute-for-rc-local-in-systemd-instead-of-re-creating-rc
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/path/to/the/script.sh
StandardOutput=journal+console
StandardOutput=journal+console

[Unit]
# https://unix.stackexchange.com/questions/635165/unable-to-mkdir-in-mnt-and-cannot-chmod/766859#766859
After=ephemeral-disk-warning.service

After=mnt.mount
Requires=mnt.mount
RequiredBy=anything-requiring-mnt.service
Before=anything-requiring-mnt.service

[Install]
WantedBy=multi-user.target

おすすめ記事