如何在/etc/fstab中指定带有空格的标签/路径?

时间:2022-01-31 00:08:50

I am having trouble trying to get theh permissions for some of my external drives set up.

我在尝试为我的一些外部驱动器设置theh权限时遇到了麻烦。

I believe the probem is due to how I am dealing with spaces in the text such that the commands can be interpreted by the terminal. I have found this, which seems to indicate that I need to configure my etc/fstab file to show the following:

我认为问题在于我如何处理文本中的空格,以便终端可以解释命令。我发现了这个,这似乎表明我需要配置我的etc/fstab文件来显示以下内容:

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/host/ubuntu/disks/swap.disk    none    swap    sw  0   0
LABEL='Expansion Drive'  /media/'Expansion Drive'  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
LABEL='Expansion Drive_'  /media/'Expansion Drive_'  ntfs-3g  defaults,umask=0022,fmask=0133  0  0

However, This is showing an error that the drive Drive_' is not ready. I realize that this is due to using ""s or ''s, but I am not sure how else to do this properly. My 2 drives are called Expansion Drive and Expansion Drive_ . Anyone know how to solve this problem?

然而,这显示了一个错误,驱动器驱动器'没有准备好。我意识到这是由于使用了“s”或“s”,但我不确定还有什么其他方法可以正确地做到这一点。我的两个驱动器叫做膨胀驱动器和膨胀驱动器。有人知道怎么解决这个问题吗?

EDIT: Here is what I can see in the media folder:

编辑:这是我在媒体文件夹中看到的:

chasebrown@ubuntu:/media$ ls -al
total 32
drwxr-xr-x  6 root       root        1024 Mar  9 16:32 .
drwxr-xr-x 24 root       root        1024 Feb 23 23:14 ..
drwx------  1 chasebrown chasebrown  4096 Mar  8 04:21 Expansion Drive
drwx------  1 chasebrown chasebrown  4096 Mar  8 04:21 Expansion Drive_
dr-x------  1 chasebrown chasebrown  2048 May 20  2009 GDRV-25922+VR2
drwx------  1 chasebrown chasebrown 20480 Mar  8 04:21 WD EXTERNAL

Also sudo lsblk -f:

还sudo lsblk - f:

chasebrown@ubuntu:/dev/disk/by-uuid$ sudo lsblk -f
[sudo] password for chasebrown: 
NAME   FSTYPE  LABEL           MOUNTPOINT
sda                            
├─sda1 ntfs    System Reserved 
└─sda2 ntfs                    
sdb                            
└─sdb1 ntfs                    /host
sdc                            
└─sdc1 ntfs    Expansion Drive /media/Expansion Drive_
sdd                            
└─sdd1 ntfs    Expansion Drive /media/Expansion Drive
sde                            
└─sde1 ntfs    WD EXTERNAL     /media/WD EXTERNAL
sr0    iso9660 GDRV-25922+VR2  /media/GDRV-25922+VR2
loop0  ext3                    /

And sudo blkid:

sudo blkid:

chasebrown@ubuntu:/dev/disk/by-uuid$ sudo blkid
/dev/loop0: UUID="87a15942-982f-4edd-bf44-439dc286fd7c" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sr0: LABEL="GDRV-25922+VR2" TYPE="iso9660" 
/dev/sda1: LABEL="System Reserved" UUID="64CEEA61CEEA2B4E" TYPE="ntfs" 
/dev/sda2: UUID="4CA4EBC0A4EBAAA2" TYPE="ntfs" 
/dev/sdb1: UUID="00064EEE064EE46E" TYPE="ntfs" 
/dev/sdc1: LABEL="Expansion Drive" UUID="C682A8EE82A8E3E1" TYPE="ntfs" 
/dev/sdd1: LABEL="Expansion Drive" UUID="D006D78406D769CC" TYPE="ntfs" 
/dev/sde1: LABEL="WD EXTERNAL" UUID="D65AFC375AFC15C9" TYPE="ntfs" 

Therefore my new fstab file is:

因此,我的新fstab文件是:

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/host/ubuntu/disks/swap.disk    none    swap    sw  0   0
LABEL=Expansion\040Drive  /media/Expansion\040Drive  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
LABEL=Expansion\040Drive_  /media/Expansion\040Drive_  ntfs-3g  defaults,umask=0022,fmask=0133  0  0

SOLUTION: I ended up changing the LABEL to UUID and it worked for some reason.

解决方案:我最终将标签更改为UUID,但由于某种原因,它起作用了。

Here is the resulting /etc/fstab file was :

这里是结果/etc/fstab文件:

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/host/ubuntu/disks/swap.disk    none    swap    sw  0   0
UUID=C682A8EE82A8E3E1  /media/Expansion\040Drive  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
UUID=D006D78406D769CC  /media/Expansion\040Drive_  ntfs-3g  defaults,umask=0022,fmask=0133  0  0

1 个解决方案

#1


79  

You can use the escape sequence \040 to escape spaces:

你可以使用escape序列\040来转义空格:

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/host/ubuntu/disks/swap.disk    none    swap    sw  0   0
LABEL=Expansion\040Drive  /media/Expansion\040Drive  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
LABEL=Expansion\040Drive_  /media/Expansion\040Drive_  ntfs-3g  defaults,umask=0022,fmask=0133  0  0

BTW, you cannot quote part of the string like you mentioned in the question. If you're quoting, you need to quote the entire string.

顺便说一句,你不能像你在问题中提到的那样引用字符串的一部分。如果你要引用,你需要引用整个字符串。

Another thing I happen to notice from the output of blkid is that there are 2 partitions (on 2 separate drives sdc1 and sdd1) both having the same LABEL Expansion Drive. To workaround this, you can use UUID instead.

我碰巧从blkid的输出中注意到的另一件事是,有两个分区(在两个单独的驱动器sdc1和sdd1上)都具有相同的标签扩展驱动器。为了解决这个问题,您可以使用UUID。

UUID=C682A8EE82A8E3E1  /media/Expansion\040Drive  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
UUID=D006D78406D769CC  /media/Expansion\040Drive_  ntfs-3g  defaults,umask=0022,fmask=0133  0  0

#1


79  

You can use the escape sequence \040 to escape spaces:

你可以使用escape序列\040来转义空格:

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/host/ubuntu/disks/swap.disk    none    swap    sw  0   0
LABEL=Expansion\040Drive  /media/Expansion\040Drive  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
LABEL=Expansion\040Drive_  /media/Expansion\040Drive_  ntfs-3g  defaults,umask=0022,fmask=0133  0  0

BTW, you cannot quote part of the string like you mentioned in the question. If you're quoting, you need to quote the entire string.

顺便说一句,你不能像你在问题中提到的那样引用字符串的一部分。如果你要引用,你需要引用整个字符串。

Another thing I happen to notice from the output of blkid is that there are 2 partitions (on 2 separate drives sdc1 and sdd1) both having the same LABEL Expansion Drive. To workaround this, you can use UUID instead.

我碰巧从blkid的输出中注意到的另一件事是,有两个分区(在两个单独的驱动器sdc1和sdd1上)都具有相同的标签扩展驱动器。为了解决这个问题,您可以使用UUID。

UUID=C682A8EE82A8E3E1  /media/Expansion\040Drive  ntfs-3g  defaults,umask=0022,fmask=0133  0  0
UUID=D006D78406D769CC  /media/Expansion\040Drive_  ntfs-3g  defaults,umask=0022,fmask=0133  0  0