![Ubuntu 和 NTFS 上罕见目录和文件名出现错误的“设备上没有剩余空间”](https://linux22.com/image/1537808/Ubuntu%20%E5%92%8C%20NTFS%20%E4%B8%8A%E7%BD%95%E8%A7%81%E7%9B%AE%E5%BD%95%E5%92%8C%E6%96%87%E4%BB%B6%E5%90%8D%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF%E7%9A%84%E2%80%9C%E8%AE%BE%E5%A4%87%E4%B8%8A%E6%B2%A1%E6%9C%89%E5%89%A9%E4%BD%99%E7%A9%BA%E9%97%B4%E2%80%9D.png)
我在一台 Ubuntu 机器(相当老的 Ubuntu 10.04.1 LTS,由于某些原因我还没准备好升级)和一个 NTFS 格式的外部 USB 驱动器上遇到了最奇怪的问题。请注意,这台机器已经作为文件和 Web 服务器运行多年,除了下面讨论的缺陷外,尽管使用频率很高,但没有明显的缺陷。由于我花了几个小时试图理解问题却没有成功,我希望有人能给出一些提示,说明可能发生的情况(除了建议迁移到较新版本的 Ubuntu——无论如何我都会这样做,但现在我不能这样做)。
下面是一个不起作用的例子(当然,“/media/paolo\'s\ #3” 是所讨论的 USB 安装设备):
rm -rf /media/paolo\'s\ #3/audio
id3v2 --list "/media/paolo's #3/01 -- Psalm 108 vs. 2 - Psalm 100.mp3"
id3v2 tag info for /media/paolo's #3/01 -- Psalm 108 vs. 2 - Psalm 100.mp3:
TALB (Album/Movie/Show title): Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965)
TCOM (Composer): Bernstein, Leonard (1918-1990)
[...]
mkdir -p "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop"
cp "/media/paolo's #3/01 -- Psalm 108 vs. 2 - Psalm 100.mp3" "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop"
cp: cannot create regular file `/media/paolo\'s #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop/01 -- Psalm 108 vs. 2 - Psalm 100.mp3': No space left on device
也就是说,我只是想递归地创建一个深路径,并从设备的根目录复制一个有效文件。当然,问题是磁盘上有足够的可用空间(100 GB)。
现在,需要指出的是,我无法简化路径,因为实际上任何其他名称都可以正常工作。更具体地说,我在运行一个复制几 GB 数据的 Perl 脚本时发现了这个问题,在数千个与上述目录类似的目录中,只有十几个存在问题(此处显示为转义,就好像它们要在 shell 中使用单引号一样):
/media/paolo's #3/audio/mp3/Classical/Bach, Carl Philipp Emanuel (1714-1788)/5. Opera/Oratorio '\''Die Auferstehung und Himmelfahrt Jesu'\'' for 3 Soli, SATB Chorus, and Orchestra, Wq240 (1777-1778) -- Schlick, Prégardien, Varcoe, Rheinische Kantorei, Das Kleine Konzert, Max
/media/paolo's #3/audio/mp3/Classical/Bach, Johann Sebastian (1685-1750)/4. Vocal/Cantata no. 211 '\''Schweigt stille, plaudert nicht'\'' for Soprano, Tenor, Bass, Choir, and Orchestra, BWV211 (1734-1735) -- Hansmann, Equiluz, van Egmond, Concentus Musicus Wien, Harnoncourt
/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop
/media/paolo's #3/audio/mp3/Classical/Bruhns, Nicolaus (1665-1697)/4. Vocal/Cantate '\''Muss nicht der Mensch'\'', for Soprano, Alto, Tenor, Bass, 2 Trumpets, Bassoon, 2 Violins, 2 Gambas, Cello, and Continuo -- De Reyghere, Bowman, De Mey, van Egmond, Ricercar Consort
/media/paolo's #3/audio/mp3/Classical/Caresana, Cristofaro (c1640-1709)/4. Vocal/Cantata '\''L'\''adoratione de'\'' Maggi'\'' for 6 Voices and Instruments '\''Per la nascita di nostro Signore'\'' (1676) -- Schiavo, Varriale, Mineccia, De Vittorio, Totaro, Naviglio, I Turchini, Florio
/media/paolo's #3/audio/mp3/Classical/Fux, Johann (1660-1741)/1. Orchestral/Serenada à 8 for 2 Trumpets, 2 Oboes, Bassoon, 2 Violins, Viola, and Continuo in C major from '\''Concentus musico-instrumentalis'\'', op. 1, K.352 (1701) -- Concentus Musicus Wien, Harnoncourt
/media/paolo's #3/audio/mp3/Classical/Handel, George Frideric (1685-1759)/4. Vocal/Motet '\''Saeviat tellus inter rigoris'\'' for Soprano, 2 Oboes, Strings, and Continuo in D major, HWV240 (1707) -- Massis, Choeur des Musiciens du Louvre, Les Musiciens du Louvre, Minkowski
/media/paolo's #3/audio/mp3/Classical/Schumann, Robert (1810-1856)/4. Vocal/Requiem for Mignon from Goethe'\''s '\''Wilhelm Meister'\'', op. 98b (1849) -- Bonney, Poschner, Schaechter, Hintermeier, Pita, Schmidt, Wiener Staatsopernchor, Chamber Orchestra of Europe, Abbado
/media/paolo's #3/audio/mp3/Classical/Telemann, Georg Philipp (1681-1767)/4. Vocal/Cantata '\''Ein Mensch ist in seinem Leben wie Gras'\'' for Soli ATB, Choir SATB, and Orchestra, TWV4:18 -- Wessel, Jochens, Schreckenberger, Rheinische Kantorei, Das Kleine Konzert, Max
/media/paolo's #3/audio/mp3/Classical/Telemann, Georg Philipp (1681-1767)/5. Opera/Oratorio '\''Betrachtung der 9. Stunde an dem Todestage Jesu'\'' for Soli ATBB, Choir SATB, and Orchestra, TWV5:5 -- Chordier, Jochens, Wimmer, van der Kamp, Rheinische Kantorei, Das Kleine Konzert, Max
/media/paolo's #3/audio/mp3/Classical/Verdi, Giuseppe (1813-1901)/4. Vocal/Messa da Requiem for 4 Solo Voices, Chorus, and Orchestra (1874) -- Tomowa-Sintow, Baltsa, Carreras, van Dam, Konzertvereinigung Wiener Staatsopernchor, Wiener Philharmoniker, von Karajan
/media/paolo's #3/audio/mp3/Classical/Waxman, Franz (1906-1967)/5. Opera/Joshua, Dramatic Oratorio for Soloists, Narrator, Mixed Chorus, and Orchestra (1959) -- Schnell, Gilfry, Hallenberg, Buchi, Poole, Prague Philharmonic Choir, Prague Philharmonia, Sedares
/media/paolo's #3/audio/mp3/Classical/Zelenka, Jan Dismas (1679-1745)/4. Vocal/Missa Divi Xaverii, for Soloists SATB, Choir SATB, 2 Flutes, 2 Oboes, 4 Trumpets, Timpani, Strings, and Continuo in D major, ZWV12 (1729) -- Collegium Vocale 1704, Collegium 1704, Luks
关于我认为可能导致失败的原因,我认为不是,我有几个评论:(1) 这两个路径,甚至包括要复制到其中的文件的名称,都不是我复制的最长的路径——有更长的路径可以完美地工作。(2) 虽然其中许多包含 UTF-8 非 ASCII 字符和轻微特殊字符(如单引号),但大多数其他成功创建的目录和文件具有完全相同的特征。(3) 目录名称的微小更改可能会导致该过程成功;在上面列表的第一个案例中,我注意到删除“Schlick”前面的两个空格中的一个会成功,但添加第三个空格仍然会失败。再次,请注意,数千个看似非常相似的目录根本没有任何问题。(4) 在第一次复制失败(由于“设备上没有剩余空间”)后,进一步的复制尝试(相同或其他文件)实际上会因“输入/输出错误”而失败。我不确定这是否重要,但 dmesg 似乎没有显示与此相关的任何内容。 (5) 该行为非常确定,我在相同目录中观察了它超过一周,并且在多次卸载和重新安装 USB 磁盘后仍然有效。
为了说明上面的观点(2),这里有一个实际的例子:
rm -rf /media/paolo\'s\ #3/audio
mkdir -p "/media/paolo's #3/audio/mp3/Classical/Bach, Johann Sebastian (1685-1750)/4. Vocal/Cantata no. 17 'Wer Dank opfert, der preiset mich' for Soprano, Alto, Tenor, Bass, Choir, and Orchestra, BWV17 (1726) -- Soloist of the Wiener Sängerknaben, Esswood, Equiluz, van Egmond, Wiener Sängerknaben, Concentus Musicus Wien, Harnoncourt"
cp "./mp3/Classical/Bach, Johann Sebastian (1685-1750)/4. Vocal/Cantata no. 17 'Wer Dank opfert, der preiset mich' for Soprano, Alto, Tenor, Bass, Choir, and Orchestra, BWV17 (1726) -- Soloist of the Wiener Sängerknaben, Esswood, Equiluz, van Egmond, Wiener Sängerknaben, Concentus Musicus Wien, Harnoncourt/01 -- Coro; Wer Dank opfert, der preiset mich.mp3" "/media/paolo's #3/audio/mp3/Classical/Bach, Johann Sebastian (1685-1750)/4. Vocal/Cantata no. 17 'Wer Dank opfert, der preiset mich' for Soprano, Alto, Tenor, Bass, Choir, and Orchestra, BWV17 (1726) -- Soloist of the Wiener Sängerknaben, Esswood, Equiluz, van Egmond, Wiener Sängerknaben, Concentus Musicus Wien, Harnoncourt"
可以注意到,这里有重音字母、双倍空格,并且其中复制的第一个文件的整体路径名比其中一个失败目录的路径名要长:
echo "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop/01 -- Psalm 108 vs. 2 - Psalm 100.mp3" | wc -c
303
echo "/media/paolo's #3/audio/mp3/Classical/Bach, Johann Sebastian (1685-1750)/4. Vocal/Cantata no. 17 'Wer Dank opfert, der preiset mich' for Soprano, Alto, Tenor, Bass, Choir, and Orchestra, BWV17 (1726) -- Soloist of the Wiener Sängerknaben, Esswood, Equiluz, van Egmond, Wiener Sängerknaben, Concentus Musicus Wien, Harnoncourt/01 -- Coro; Wer Dank opfert, der preiset mich.mp3" | wc -c
379
下面是另一个奇怪的例子。实际上,它运行正常:
rm -rf /media/paolo\'s\ #3/audio
mkdir -p "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop"
touch "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop/TEST"
cp "/media/paolo's #3/01 -- Psalm 108 vs. 2 - Psalm 100.mp3" "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop"
id3v2 --list "/media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop/01 -- Psalm 108 vs. 2 - Psalm 100.mp3"
id3v2 tag info for /media/paolo's #3/audio/mp3/Classical/Bernstein, Leonard (1918-1990)/4. Vocal/Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965) -- Kelly, Franklin-Kitchen, Nayeler, Budd, Charrier, Bournemouth Symphony Chorus and Orchestra, Alsop/01 -- Psalm 108 vs. 2 - Psalm 100.mp3:
TALB (Album/Movie/Show title): Chichester Psalms, for Boy Soprano, Mixed Chorus, Organ, Harp, and Percussion (1965)
TCOM (Composer): Bernstein, Leonard (1918-1990)
[...]
与第一个示例的唯一区别是,在进行复制之前,我触摸了目录中的随机文件。然后,复制成功,并且(上例中未显示)我可以删除被触摸的文件,而所有内容仍保持正常。但如果我在触摸文件 TEST 后立即将其删除,则后续复制将失败。请注意,我试图使用此技术在我的脚本中快速解决问题:虽然它在简单的测试用例上运行良好,但它在所有情况下都无法正常工作——唉,目前我没有更多信息。
我不知道发生了什么,也不知道我能做什么(再次强调,除了更换 Ubuntu 版本)来解决这个问题。