没有权限raid10阵列linux ubuntu

没有权限raid10阵列linux ubuntu

我刚刚使用 mdadm 从 3 个 1TB hhd 创建了一个 Raid10 阵列,名为 md0。我遵循了以下说明:https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-16-04

我没有md0的权限。

该数组可以在以下位置找到:

/media/joe/f7790191-84f3-4d9b-81b8-43de132244a2

echo hello > hello.txt
bash: hello.txt: Permission denied

实际上,我甚至无法使用 sudo 来做到这一点......

sudo echo hello > hello.txt
bash: hello.txt: Permission denied

权限应按以下方式显示:

joe@joeslinux:/media/joe$ ls -al
total 12
drwxr-x---+ 3 root root 4096 Mar 30 22:42 .
drwxr-xr-x  3 root root 4096 Mar 28 17:26 ..
drwxr-xr-x  3 root root 4096 Mar 29 22:30 f7790191-84f3-4d9b-81b8-43de132244a2

哦,/mnt 是这样的:

joe@joeslinux:/$ ls -al /mnt/
total 12
drwxr-xr-x  3 root root 4096 Mar 29 17:22 .
drwxr-xr-x 24 root root 4096 Mar 28 20:54 ..
drwxr-xr-x  2 root root 4096 Mar 29 17:22 md0

/etc/fstab是:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p1 during installation
UUID=20b839d8-08f1-441e-99e3-f87f6dda9c66 /               ext4    errors=remount-ro 0       1
# swap was on /dev/nvme0n1p5 during installation
UUID=2403be72-9dca-43b6-a596-044cfd813801 none            swap    sw              0       0

sudo blkid是:

/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/nvme0n1: PTUUID="3acfb4f5" PTTYPE="dos"
/dev/nvme0n1p1: UUID="20b839d8-08f1-441e-99e3-f87f6dda9c66" TYPE="ext4" PARTUUID="3acfb4f5-01"
/dev/nvme0n1p5: UUID="2403be72-9dca-43b6-a596-044cfd813801" TYPE="swap" PARTUUID="3acfb4f5-05"
/dev/sda: UUID="43468a60-e0d2-6202-4e0c-320120beeee1" UUID_SUB="11eb3ea8-74da-18c2-cd0a-bb2454c0cb46" LABEL="joeslinux:0" TYPE="linux_raid_member"
/dev/sdb: UUID="43468a60-e0d2-6202-4e0c-320120beeee1" UUID_SUB="a49f1c1a-3450-39bc-8efb-67da1ebeacdf" LABEL="joeslinux:0" TYPE="linux_raid_member"
/dev/md0: UUID="f7790191-84f3-4d9b-81b8-43de132244a2" TYPE="ext4"
/dev/sdc: UUID="43468a60-e0d2-6202-4e0c-320120beeee1" UUID_SUB="27ae3d15-ef03-2937-7454-ed89da25e857" LABEL="joeslinux:0" TYPE="linux_raid_member"

sudo fdisk-l 是:

Disk /dev/nvme0n1: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3acfb4f5

Device         Boot     Start       End   Sectors   Size Id Type
/dev/nvme0n1p1 *         2048 366155775 366153728 174.6G 83 Linux
/dev/nvme0n1p2      366157822 500117503 133959682  63.9G  5 Extended
/dev/nvme0n1p5      366157824 500117503 133959680  63.9G 82 Linux swap / Solaris

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x000680a0

Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x76221e63

Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xee260f95

Disk /dev/md0: 1.4 TiB, 1500105408512 bytes, 2929893376 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1572864 bytes

(省略 loop0,1,2,3 条目)

我面临的问题是 root:root 所有者吗?或者也许 fstab 不包含与 md0 绑定的 UUID?抱歉,我对此还不太熟悉。

答案1

如果 RAID 阵列的底层文件系统是ext4,则问题在于权限。/etc/fstab默认情况下,安装在 中的项目不会获得所有者或组 ID,如果它是 Linux 格式的文件系统,那么您必须chown通过等获取权限。

您必须将整个 RAID 阵列的完整所有权更改为您的用户,或者用于sudo在 RAID 阵列上创建目录,然后重新分配文件夹本身的所有权。

这两个选项都相当容易实现。

在阵列上创建一个目录,并将该目录设置为您所有

sudo mkdir /media/joe/f7790191-84f3-4d9b-81b8-43de132244a2/{FOLDER NAME}
sudo chown joe:joe /media/joe/f7790191-84f3-4d9b-81b8-43de132244a2/{FOLDER NAME}

...只需确保将其替换{FOLDER NAME}为您创建的目录的名称。

要将阵列上的整个权限集更改为您的权限:

sudo chown joe:joe /media/joe/f7790191-84f3-4d9b-81b8-43de132244a2/

这会将整个磁盘阵列更改为您拥有,进而允许您在阵列上创建文件,这可能就是您想要做的。

请注意,这将禁止其他用户root写入数组,以防您想将其用于除个人存储以外的其他用途。

相关内容