Raspberry Pi – XFS file system and the reflink feature is now production ready and enabled by default on new installations

  xfsprogs and the reflink option is an extremely interesting feature – it is an implementation of „Copy on Write“ for files in the file system. You create a reflink using the command cp –reflink=always and the two files act as if they’re linked together (no extra disk space consumed) but as soon as you edit one they become two files. With reflinks one could easily set up a clone of a directory structure to edit something in the clone without modifying the original files so XFS file system is one of the file systems which supports reflinks so it is worthwhile to know how to format a drive with the XFS file system and with the reflinks feature enabled

root@rpi-iot-jsho-xfs-01:~# apt-get update -y
root@rpi-iot-jsho-xfs-01:~# apt-get full-upgrade -y
root@rpi-iot-jsho-xfs-01:~# apt-get install xfsprogs
root@rpi-iot-jsho-xfs-01:~# apt-get install xfsprogs
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen…. Fertig
xfsprogs ist schon die neueste Version (4.20.0-1).
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.
root@rpi-iot-jsho-xfs-01:~# mkfs.xfs -m reflink=1 -f /dev/sda
meta-data=/dev/sda isize=512 agcount=4, agsize=499200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1996800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =Internes Protokoll bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =keine extsz=4096 blocks=0, rtextents=0
root@rpi-iot-jsho-xfs-01:~# mount /dev/sda /XFS
root@rpi-iot-jsho-xfs-01:~# vi /etc/fstab
/dev/sda /XFS xfs defaults 1 2
root@rpi-iot-jsho-xfs-01:~# mkdir -vp /XFS/data_01
mkdir: Verzeichnis ‚/XFS/data_01‘ angelegt
root@rpi-iot-jsho-xfs-01:~# for i in {1..2}; do echo „Writing $i …“; dd if=/dev/urandom of=/XFS/data_01/$i bs=1M count=1024; done
Writing 1 …
1024+0 Datensätze ein
1024+0 Datensätze aus
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 135,721 s, 7,9 MB/s
Writing 2 …
1024+0 Datensätze ein
1024+0 Datensätze aus
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 130,535 s, 8,2 MB/s
root@rpi-iot-jsho-xfs-01:/XFS/data_01# df -h /XFS
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
/dev/sda 7,7G 2,1G 5,6G 28% /XFS
root@rpi-iot-jsho-xfs-01:~# time cp -v /XFS/data_01/{,copy_}1
‚/XFS/data_01/1‘ -> ‚/XFS/data_01/copy_1‘
real 4m34,603s
user 0m0,120s
sys 0m21,923s
root@rpi-iot-jsho-xfs-01:~# df -h /XFS
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
/dev/sda 7,7G 3,1G 4,6G 41% /XFS
root@rpi-iot-jsho-xfs-01:~# time cp -v –reflink=always /XFS/data_01/{,copy_}2
‚/XFS/data_01/2‘ -> ‚/XFS/data_01/copy_2‘
real 0m0,042s
user 0m0,000s
sys 0m0,026s
root@rpi-iot-jsho-xfs-01:~# df -h /XFS
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
/dev/sda 7,7G 3,1G 4,6G 41% /XFS
root@rpi-iot-jsho-xfs-01:~# filefrag -v /XFS/data_01/{,copy_}1
Filesystem type is: 58465342
File size of /XFS/data_01/1 is 1073741824 (262144 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 262143: 24.. 262167: 262144: last,eof
/XFS/data_01/1: 1 extent found
File size of /XFS/data_01/copy_1 is 1073741824 (262144 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 65519: 393224.. 458743: 65520:
1: 65520.. 262143: 630298.. 826921: 196624: 458744: last,eof
/XFS/data_01/copy_1: 2 extents found
root@rpi-iot-jsho-xfs-01:~# filefrag -v /XFS/data_01/{,copy_}2
Filesystem type is: 58465342
File size of /XFS/data_01/2 is 1073741824 (262144 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 131055: 262168.. 393223: 131056: shared
1: 131056.. 262143: 499210.. 630297: 131088: 393224: last,shared,eof
/XFS/data_01/2: 2 extents found
File size of /XFS/data_01/copy_2 is 1073741824 (262144 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 131055: 262168.. 393223: 131056: shared
1: 131056.. 262143: 499210.. 630297: 131088: 393224: last,shared,eof
/XFS/data_01/copy_2: 2 extents found

Leave a Reply

You must be logged in to post a comment.