0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NILFS2でも Lifetime writesを知りたいよね?

Last updated at Posted at 2021-02-20

ext4は tune2fs(8)で lifetime writesを教えてくれるが、、、


$ sudo tune2fs -l /dev/sda1 | grep ^Lifetime
Lifetime writes:          184 MB

残念ながら nilfs-tune(8)はそのものズバリの出力をしてくれない。

nilfs-tuneの出力をいじってみよう。

Last sequence#がセグメント単位での最新の書き込み番号らしい。


$ sudo nilfs-tune -l /dev/dm-0 | grep '^Last sequence #:' | awk '{print $4}'
4927
$ sudo nilfs-tune -l /dev/dm-0 | grep '^Block size:' | awk '{print $3}'
4096
$ sudo nilfs-tune -l /dev/dm-0 | grep '^# of blocks per segment:' | awk '{print $6}'
2048

492740962048 (bytes) = 38.4 (GB)、ってことだ。

コマンド一発で出るようにしてみましょうか。


$ ./nilfs_lifetimewrites.sh /dev/dm-0
38.4 GB written.

スクリプトはこちら。


#!/bin/sh
TMPDIR=/tmp
TMPFILE=$TMPDIR/tmp-nilfstune.txt

if [ $# -lt 1 ]; then
  echo usage: $0 device-name
  exit 255
fi

sudo nilfs-tune -l $1 >$TMPFILE
if [ $? -ne 0 ]; then
  echo nilfs-tune exited by $?, exiting
  exit -1
fi

LASTSEQ=`grep '^Last sequence #:'         < $TMPFILE | awk '{print $4}'`
BLKSIZE=`grep '^Block size:'              < $TMPFILE | awk '{print $3}'`
BLKASEG=`grep '^# of blocks per segment:' < $TMPFILE | awk '{print $6}'`

TOTALWRITESGB=`echo "scale=1; $LASTSEQ * $BLKSIZE * $BLKASEG /1024 /1024 /1024" | bc`
echo $TOTALWRITESGB GB written.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?