ファイルシステムをXFSからext4に変換してみた。

CentosのデフォルトのファイルシステムはXFSだがext4に変換してみた。

現状は

# df -T | grep -i xfs
ファイルシス タイプ 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/centos-root xfs 34909540 12561500 22348040 36% /
/dev/sda1 xfs 508588 169916 338672 34% /boot
/dev/mapper/centos-home xfs 17041408 3049104 13992304 18% /home

このような感じ

fstransformというパッケージをつかうと出来るらしい

普通にYUMではいるのか?

# yum install fstransform
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 6.9 kB 00:00:00
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi-safe: ftp.riken.jp
* updates: ftp.iij.ad.jp
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
remi-safe | 3.0 kB 00:00:00
updates | 3.4 kB 00:00:00
epel/x86_64/primary_db FAILED
http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/dfe399fd78675260e7888081dd162479b2ecd1e9afe7e15f74c9c0fd5571dbf4-primary.sqlite.bz2: [Errno 14] HTTP Error 404 – Not Found
他のミラーを試します。
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn’t help to resolve this issue please use https://bugs.centos.org/.

(1/3): epel/x86_64/updateinfo | 954 kB 00:00:00
(2/3): remi-safe/primary_db | 1.4 MB 00:00:00
(3/3): epel/x86_64/primary_db | 6.6 MB 00:00:00
依存性の解決をしています
–> トランザクションの確認を実行しています。
—> パッケージ fstransform.x86_64 0:0.9.3-1.el7 を インストール
–> 依存性解決を終了しました。

依存性を解決しました

=====================================================================================================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
=====================================================================================================================================================================
インストール中:
fstransform x86_64 0.9.3-1.el7 epel 130 k

トランザクションの要約
=====================================================================================================================================================================
インストール 1 パッケージ

総ダウンロード容量: 130 k
インストール容量: 362 k
Is this ok [y/d/N]: y
Downloading packages:
fstransform-0.9.3-1.el7.x86_64.rpm | 130 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : fstransform-0.9.3-1.el7.x86_64 1/1
検証中 : fstransform-0.9.3-1.el7.x86_64 1/1

インストール:
fstransform.x86_64 0:0.9.3-1.el7

完了しました!

インストールできました。

使い方はこんな感じ

fstransform {device} {target-file-system-type}

実際にやってみる。
対象は/homeの/dev/mapper/centos-homeを指定

# fstransform /dev/mapper/centos-home ext4
fstransform: starting version 0.9.3, checking environment
fstransform: checking for which… ‘/usr/bin/which’
fstransform: checking for expr… ‘/usr/bin/expr’
fstransform: checking for id… ‘/usr/bin/id’
fstransform: parsing command line arguments
fstransform: checking for stat… ‘/usr/bin/stat’
fstransform: checking for mkfifo… ‘/usr/bin/mkfifo’
fstransform: checking for blockdev… ‘/usr/sbin/blockdev’
fstransform: checking for losetup… ‘/usr/sbin/losetup’
fstransform: checking for fsck… ‘/usr/sbin/fsck’
fstransform: checking for mkfs… ‘/usr/sbin/mkfs’
fstransform: checking for mount… ‘/usr/bin/mount’
fstransform: checking for umount… ‘/usr/bin/umount’
fstransform: checking for mkdir… ‘/usr/bin/mkdir’
fstransform: checking for rmdir… ‘/usr/bin/rmdir’
fstransform: checking for rm… ‘/usr/bin/rm’
fstransform: checking for dd… ‘/usr/bin/dd’
fstransform: checking for sync… ‘/usr/bin/sync’
fstransform: checking for fsmove… ‘/usr/sbin/fsmove’
fstransform: checking for fsremap… ‘/usr/sbin/fsremap’
fstransform: checking for fsck(source file-system)… ‘/usr/sbin/fsck’
fstransform: checking for fsck(target file-system)… ‘/usr/sbin/fsck’
fstransform: looking for optional commands
fstransform: checking for sleep… ‘/usr/bin/sleep’
fstransform: checking for date… ‘/usr/bin/date’
14:27:38 fstransform: environment check passed.
14:27:38 fstransform: saving output of this execution into /var/tmp/fstransform/fstransform.log.101625
14:27:38 fstransform: preparing to transform device ‘/dev/mapper/centos-home’ to file-system type ‘ext4’
14:27:38 fstransform: device is mounted at ‘/home’ with file-system type ‘xfs’
14:27:38 fstransform: device raw size = 17460887552 bytes
14:27:38 fstransform: creating sparse loop file ‘/home/.fstransform.loop.101625’ inside device ‘/dev/mapper/centos-home’…
14:27:38 dd: 1+0 レコード入力
14:27:38 dd: 1+0 レコード出力
14:27:38 dd: 1 バイト (1 B) コピーされました、 0.000236563 秒、 4.2 kB/秒
14:27:38 fstransform: device file-system block size = 4096 bytes
14:27:38 fstransform: device usable size = 17460887552 bytes
14:27:38 dd: 1+0 レコード入力
14:27:38 dd: 1+0 レコード出力
14:27:38 dd: 1 バイト (1 B) コピーされました、 0.000208061 秒、 4.8 kB/秒
14:27:39 fstransform: connected loop device ‘/dev/loop0’ to file ‘/home/.fstransform.loop.101625’
14:27:39 fstransform: formatting loop device ‘/dev/loop0’ with file-system type ‘ext4’…
14:27:40 fstransform: mounting loop device ‘/dev/loop0’ on ‘/tmp/fstransform.loop.101625’ …
14:27:41 fstransform: loop device ‘/dev/loop0’ mounted successfully.
14:27:41 fstransform: preliminary steps completed, now comes the delicate part:
14:27:41 fstransform: fstransform will move ‘/dev/mapper/centos-home’ contents into the loop file.

警告文がでて/dev/mapper/centos-home /dev/loop0がいっぱいになるとデーターを失うと言ってる感じ
ですが容量には余裕が有るのでENTERで続行

14:27:41 fstransform: WARNING: THIS IS IMPORTANT! if either the original device ‘/dev/mapper/centos-home’
or the loop device ‘/dev/loop0’ become FULL,

YOU WILL LOSE YOUR DATA !

fstransform checks for enough available space,
in any case it is recommended to open another terminal, type
watch df /dev/mapper/centos-home /dev/loop0
and check that both the original device ‘/dev/mapper/centos-home’
and the loop device ‘/dev/loop0’ are NOT becoming full.
if one of them is becoming full (or both),
you MUST stop fstransform with CTRL+C or equivalent.

this is your chance to quit.
press ENTER to continue, or CTRL+C to quit:
14:28:05 fstransform: moving ‘/dev/mapper/centos-home’ contents into the loop file.
14:28:05 fstransform: this may take a long time, please be patient…
14:28:09 fsmove: progress: 5.0% done, 2.8 gigabytes still to move
14:28:18 fsmove: progress: 10.0% done, 2.7 gigabytes still to move, estimated 2 minutes left
14:28:21 fsmove: progress: 15.0% done, 2.5 gigabytes still to move, estimated 1 minute and 50 seconds left
14:28:24 fsmove: progress: 20.0% done, 2.4 gigabytes still to move, estimated 1 minute and 40 seconds left
14:28:28 fsmove: progress: 25.0% done, 2.2 gigabytes still to move, estimated 1 minute and 25 seconds left
14:28:35 fsmove: progress: 30.0% done, 2.1 gigabytes still to move, estimated 1 minute and 20 seconds left
14:28:49 fsmove: progress: 35.0% done, 1.9 gigabytes still to move, estimated 1 minute and 25 seconds left
14:28:52 fsmove: progress: 40.0% done, 1.8 gigabytes still to move, estimated 1 minute and 20 seconds left
14:28:59 fsmove: progress: 45.0% done, 1.6 gigabytes still to move, estimated 1 minute and 10 seconds left
14:29:01 fsmove: progress: 50.0% done, 1.5 gigabytes still to move, estimated 1 minute and 5 seconds left
14:29:04 fsmove: progress: 55.0% done, 1.3 gigabytes still to move, estimated 60 seconds left
14:29:04 fsmove: move() skipped `/home/.fstransform.loop.101625′, matches exclude list
14:29:04 fsmove: job completed.
14:29:04 fstransform: unmounting and running ‘/usr/sbin/fsck’ (disk check) on loop file ‘/home/.fstransform.loop.101625’
14:29:06 fsck: fsck from util-linux 2.23.2
14:29:07 fsck: /dev/loop0: 5960/1066864 files (1.9% non-contiguous), 547472/4262912 blocks
14:29:07 fstransform: disconnected loop device ‘/dev/loop0’ from file ‘/home/.fstransform.loop.101625’
14:29:07 fstransform: unmounting device ‘/dev/mapper/centos-home’ before disk check
14:29:07 fstransform: running ‘/usr/sbin/fsck’ (disk check) on device ‘/dev/mapper/centos-home’
14:29:07 fsck: fsck from util-linux 2.23.2
14:29:07 fsck: /sbin/fsck.xfs: XFS file system.
14:29:07 fstransform: mounting again device ‘/dev/mapper/centos-home’ read-only
14:29:07 fstransform: launching ‘/usr/sbin/fsremap’ in simulated mode
14:29:07 fsremap: starting job 1, persistence data and logs are in ‘/var/tmp/fstransform/fsremap.job.1’
14:29:07 fsremap: if this job is interrupted, for example by a power failure,
14:29:07 fsremap: you CAN RESUME it with: /usr/sbin/fsremap -n -q –resume-job=1 — /dev/mapper/centos-home
14:29:07 fsremap: analysis completed: 1.80 gigabytes must be relocated
14:29:07 fsremap: allocated 823.62 megabytes RAM as memory buffer
14:29:07 fsremap: primary-storage is 230.00 megabytes, initialized and mmapped() to contiguous RAM
14:29:07 fsremap: (simulated) starting in-place remapping. this may take a LONG time …
14:29:07 fsremap: (simulated) progress: 6.3% done, 1.8 gigabytes still to relocate
14:29:07 fsremap: (simulated) progress: 38.3% done, 1.2 gigabytes still to relocate
14:29:07 fsremap: (simulated) progress: 61.8% done, 816.8 megabytes still to relocate
14:29:07 fsremap: (simulated) progress: 79.6% done, 489.4 megabytes still to relocate
14:29:07 fsremap: (simulated) progress: 94.1% done, 217.2 megabytes still to relocate
14:29:07 fsremap: (simulated) clearing 14.47 gigabytes free-space from device …
14:29:07 fsremap: (simulated) job completed.
14:29:07 fstransform: launching ‘/usr/sbin/fsremap’ in REAL mode to perform in-place remapping.
14:29:07 fsremap: starting job 2, persistence data and logs are in ‘/var/tmp/fstransform/fsremap.job.2’
14:29:07 fsremap: if this job is interrupted, for example by a power failure,
14:29:07 fsremap: you CAN RESUME it with: /usr/sbin/fsremap -q –resume-job=2 — /dev/mapper/centos-home
14:29:07 fsremap: analysis completed: 1.80 gigabytes must be relocated
14:29:08 fsremap: allocated 823.57 megabytes RAM as memory buffer
14:29:08 fsremap: primary-storage is 230.00 megabytes, initialized and mmapped() to contiguous RAM
14:29:08 fsremap: successfully unmounted device ‘/dev/mapper/centos-home’
14:29:08 fsremap: everything ready for in-place remapping, this is your LAST chance to quit.
14:29:08 fsremap: WARN: press ENTER to proceed, or CTRL+C to quit

14:29:15 fsremap: starting in-place remapping. this may take a LONG time …
14:29:22 fsremap: progress: 6.3% done, 1.8 gigabytes still to relocate
14:29:48 fsremap: progress: 38.3% done, 1.2 gigabytes still to relocate, estimated 50 seconds left
14:30:06 fsremap: progress: 61.8% done, 816.8 megabytes still to relocate, estimated 30 seconds left
14:30:23 fsremap: progress: 79.6% done, 489.4 megabytes still to relocate, estimated 15 seconds left
14:30:37 fsremap: progress: 94.1% done, 217.2 megabytes still to relocate, estimated 5 seconds left
14:30:42 fsremap: clearing 14.47 gigabytes free-space from device …

14:35:57 fsremap: job completed.
14:35:58 fstransform: running again ‘/usr/sbin/fsck’ (disk check) on device ‘/dev/mapper/centos-home’
14:35:58 fsck: fsck from util-linux 2.23.2
14:35:58 fsck: /sbin/fsck.xfs: XFS file system.
14:35:58 fstransform: mounting transformed device ‘/dev/mapper/centos-home’
14:35:58 fstransform: completed successfully. your new ‘ext4’ file-system is mounted at ‘/home’

なんか出来たっぽいのでreboot実行

/homeがマウントできないの・・・

fstransform

fstransform


パスワードを打ってメンテナンスモードで見てみる。

fstabがxfsのまま・・

fstransform

fstransform

このままでは当然無理なのでxfsに書き換えて再度rebootすると

# df -T | grep ext4
/dev/mapper/centos-home ext4 16652636 1790876 13992796 12% /home

無事に変換されました。
見た所データの消失も無いようです。

/homeを別パーティションに分けてる場合は簡単に済みましたが/bootや/だけの場合は
起動させるのにちょっと手を加える必要がありそうです。

タグ , . ブックマークする パーマリンク.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です