2011年2月26日星期六

RHEL 5.6 真的「完全」支援 ext4 文件系統格式嗎?!

2008 年 12月 發佈正式的 ext4 文件系統格式及後其支援的 kernel 2.6.28, 到今天都差不多兩年多了, 除了主流的 Linux 系統 distro 個別開發嘗鮮版本外, 企業版的 Linux 系統(RHEL, SUSE 等等)基於穩定安全下一直都是以 technical preview 的方式讓用戶體驗, 並沒有完全地提供原整支援, Redhat 公司釋出的 RHEL 6 及 RHEL 5.6 終於都支援了正式 ext4, 雖然 Redhat 官方在 RHEL 5.6 版本發行說明文件中表示了 「The fourth extended filesystem (ext4) is now a fully supported feature in Red Hat Enterprise Linux 5.6」, 不過在 RHEL 5.6 的其他軟體套件卻仍然存在相容性問題, 其中 RHEL 5.6 提供的軟體 gnome-vfs 並沒有更新支援 ext4, 一但 / 根目錄或 home 目錄架建在 ext4 格式下的話, 在 gnome 桌面應用時會有功能缺失的問題, 最常見的狀態是 gnome 桌面的 Trash「回收筒」不會顯示任何已刪除的文件, 而且 nautilus 也不能正常偵測到 ext4 應用分割區。

RHEL6 的 ext4 分割區在 gnome 桌面刪除文件後 Trash 的內容存在已刪除文件
RHEL5.6 的 ext4 分割區在 gnome 桌面刪除文件後 Trash 的內容空白
RHEL 5.6 發行說明文件
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html-single/5.6_Release_Notes/index.html

Fourth Extended Filesystem (ext4) Support
The fourth extended filesystem (ext4) is now a fully supported feature in Red Hat Enterprise Linux 5.6. ext4 is based on the third extended filesystem (ext3) and features a number of improvements, including: support for larger file size and offset, faster and more efficient allocation of disk space, no limit on the number of subdirectories within a directory, faster file system checking, and more robust journaling.
To complement the addition of ext4 as a fully supported filesystem in Red Hat Enterprise Linux 5.6, the e4fsprogs package has been updated to the latest upstream version. e4fsprogs contains utilities to create, modify, verify, and correct the ext4 filesystem.

RHEL 5.6 kernel 是 2.6.18-238
RHEL 5.6 內的 gnome-vfs2 版本仍然是 5.5 時的 2.16.2-6.el5_5.1 而 RHEL 6 內的版本已更新是 2.24.2-3.el6, 舊的版本仍然沒有支援 ext4 及 ext4dev, Debian bug#539322 2009/7 收納了此問題, 而 Redhat bug#594836 2010/5 亦收納了此問題, 不過 Redhat 官方並沒有對此支援修正感到趣味性, 這造成 RHEL 5.6 的 ext4 其實只是 kernel 的改造支援而已, 其他的軟體在相容性下變成的像殘障病患一樣, 其實 RHEL 5.6 連自身的 anaconda 系統安裝程式也沒有更新到支援格化 ext4 文件系統格式, 在腦惱的失望下唯有自己解決 gnome-vfs 的缺陷(加 patch)【適用於 CentOS 5】。

參考了 Bug#594836 內的附件 "Minimal patch to add ext4 support", 可以自行新增 ext4 patch 到 gnome-vfs2-2.16.2-6.el5_5.1 的源碼內手動編譯及安裝。

將下列修正源碼補丁 "Minimal patch to add ext4 support" 儲存為 gnome-vfs-2.16.2-ext4.patch 文件
--- gnomevfs-2.16.2/libgnomevfs/gnome-vfs-filesystem-type.c 2010-11-10 20:35:39.000000000 +0000
+++ gnomevfs-2.16.2/libgnomevfs/gnome-vfs-filesystem-type.c 2010-11-10 20:39:22.000000000 +0000
@@ -47,6 +47,8 @@
{ "ext2" , N_("Ext2 Linux Volume"), 1 },
{ "ext2fs" , N_("Ext2 Linux Volume"), 1 },
{ "ext3" , N_("Ext3 Linux Volume"), 1 },
+ { "ext4" , N_("Ext4 Linux Volume"), 1 },
+ { "ext4dev" , N_("Ext4 Linux Volume"), 1 },
{ "fat" , N_("MSDOS Volume"), 1 },
{ "ffs" , N_("BSD Volume"), 1 },
{ "hfs" , N_("MacOS Volume"), 1 },

下載源碼套件 gnome-vfs2-2.16.2-6.el5_5.1.src.rpm

安裝源碼套件
# rpm -ivh gnome-vfs2-2.16.2-6.el5_5.1.src.rpm

gnome-vfs-2.16.2-ext4.patch 文件新增到源碼目錄 /usr/src/redhat/SOURCE

修改 rpm build spec 編譯程序文件加入 ext4 patch 程序
將下列 patch 源碼儲存為 spec.patch/usr/src/redhat/SPEC 目錄
--- gnome-vfs2.spec 2011-02-25 18:26:49.550202195 +0800
+++ gnome-vfs2.spec 2011-02-25 18:28:10.237202195 +0800
@@ -12,7 +12,7 @@
Summary: The GNOME virtual file-system libraries
Name: gnome-vfs2
Version: 2.16.2
-Release: 6%{?dist}.1
+Release: 6%{?dist}.1.1
License: LGPL
Group: System Environment/Libraries
Source0: gnome-vfs-%{version}.tar.bz2
@@ -94,6 +94,8 @@
# CVE-2009-2473 neon, gnome-vfs2 embedded neon: billion laughs DoS attack
# Patch25: CVE-2009-2473-neon-billion-laughs.patch

+# ext4 support as of RHEL6
+Patch99: gnome-vfs-2.16.2-ext4.patch

%description
GNOME VFS is the GNOME virtual file system. It is the foundation of
@@ -158,6 +160,8 @@
%patch23 -p1 -b .copy-follow-symlink
%patch24 -p1 -b .dav-escape

+%patch99 -p1 -b .ext4
+
# -- disabled, no QE capacity
# %patch25 -p1 -b .neon-CVE-2009-2473

執行 spec.patch 補丁修改 gnome-vfs2.spec
# cd /usr/src/redhat/SPEC
# patch -b gnome-vfs2.spec spec.patch


手動編譯
# cd /usr/src/redhat/SPEC
# rpmbuild -ba gnome-vfs2.spec --define 'dist .el5_5'

**所有編譯開發套件要求需要手動執行 yum 安裝, 包括 yum groupinstall 'Development Tools'

編譯完成後手動升級安裝
# cd /usr/src/redhat/RPMS/i386
# rpm -Uvh gnome-vfs2-2.16.2-6.el5_5.1.1.i386.rpm gnome-vfs2-smb-2.16.2-6.el5_5.1.1.i386.rpm


安裝了 gnome-vfs 支援 ext4 的修正補丁後, gnome 的 Trash「回收筒」功能回復【CentOS 5.5】
備註:
  • 如果系統是 x86_64 的話, 則可以使用 mock 別權環境打包源碼後編譯 i386 及 x86_64。
  • 由於 blogger 對 code 碼的左方空白字去掉, 留意源碼位置已被自動改動。

更新補充:

沒有留言:

發佈留言