Computer Science
Algorithm
Data Processing
Digital Life
Distributed System
Distributed System Infrastructure
Machine Learning
Operating System
Android
Linux
Tizen
Windows
iOS
Programming Language
C++
Erlang
Go
Scala
Scheme
Type System
Software Engineering
Storage
Change Root File System from Ext4 to Xfs on Archlinux (2013)
UI
Flutter
Javascript
Virtualization
Life
Life in Guangzhou (2013)
Recent Works (2013)
东京之旅 (2014)
My 2017 Year in Review (2018)
My 2020 in Review (2021)
十三年前被隔离的经历 (2022)
A Travel to Montreal (2022)
My 2022 in Review (2023)
Travel Back to China (2024)
Projects
Bard
Blog
RSS Brain
Scala2grpc
Comment Everywhere (2013)
Fetch Popular Erlang Modules by Coffee Script (2013)
Psychology
耶鲁大学心理学导论 (2012)
Thoughts
Chinese
English

Change Root File System from Ext4 to Xfs on Archlinux

Posted on 10 Jan 2013, tagged ext4xfsinitramfsbackup

Xfs is said a high performance file system. So I changed my root file system from ext4 to xfs today. There are some tricky things. This article is a simple HOWTO.

1. Make a xfs partation

Note: a xfs partation cannot be shrunk. And if you don’t have a splite boot partation, you should make one with ext2 since grub don’t support xfs well.

2. Copy files with tar

Copy files from origin ext4 partation to the new xfs partation with tar. Be careful, never use cp to backup a file system since cp will change the setuid bit and follow hard links. Use tar instead, for example:

tar --exclude=proc/ --exclude=sys/ -cf - / | ( cd <xfs_mount_path> ; tar -xpvf - )

I just exclude two directories for an example. You should exclude all mounted file systems (except root of cause). It is recommended to use a bootable CD or USB disk to boot your system, mount both ext4 and xfs partations, then use tar to copy files. In this way, you need not exclude any directory:

tar  -cf - <ext4_mount_path> | ( cd <xfs_mount_path> ; tar -xpvf - )

3. Config grub and modify fstab

There is nothing special here. Just modify your grub config and fstab in your xfs partation. Remember to make an entry for your old root file system while config the grub. Then you could try to reboot. If the system could not mount xfs partation, you may want to boot with the old ext4 root partation and modify initramfs for xfs support as bellow.

4. Modify initramfs to include xfs support

In the boot process, kernel use initramfs as root first, then mount the real root file system. If your initramfs don’t include support for xfs, you may see these errors during booting:

fsck.xfs: file not found
mount: unknown filesystem type "xfs"

In this case, you need boot into your old ext4 root partation and modify initramfs. In archlinux, you can do it with mkinitcpio.

Just add xfs to kernel modules and fsck.xfs to binary files in /etc/mkinitcpio.conf:

MODULES="xfs"
BINARIES="fsck.xfs"

Remember to copy it to your xfs partation, too.

Then make a initramfs:

mkinitcpio -p linux