Linux教科書 LPICレベル2 スピードマスター問題集 Version4.5対応 を参考にLPIC2の勉強をした

  • 投稿者:
  • 投稿カテゴリー:Linux

Linux教科書 LPICレベル2 スピードマスター問題集 Version4.5対応を参考にLPIC2の勉強をした。
知らなかったことや試してみたことをメモしておく。

ファイルシステム

fuserコマンドでファイルやファイルシステムにアクセスしているプロセスを表示する

# fuser -v /mnt/test.txt
                     USER        PID ACCESS COMMAND
/mnt/test.txt:       root      20719 f.... lv

mke2fsコマンドでext3ファイルシステムを作成する

configファイルは/etc/mke2fs.confに存在する

# mke2fs -j disk.img
...
# mke2fs -t ext3 disk.img
...

Btrfs(B-tree filesystem)ファイルシステムでスナップショットを取得してみる

・Btrfsは2009年にリリースされ、2014年8月にstableとなり、同年10月にSUSE Enterprise Linux 12のデフォルトファイルシステムとなった
・Btrfsはsnapshotをsubvolume単位で取得する
https://qiita.com/termoshtt/items/d3b3b6c36a97fea60a14

# dd if=/dev/zero of=disk.img bs=1M count=256
...
# mkfs.btrfs disk.img
btrfs-progs v4.15.1
See http://btrfs.wiki.kernel.org for more information.

Label:              (null)
UUID:               3bbf3295-23d4-44d9-bcd4-759cf3b8c40a
Node size:          16384
Sector size:        4096
Filesystem size:    256.00MiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP              32.00MiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1   256.00MiB  disk.img

# btrfs subvolume create /mnt/sub-data
Create subvolume '/mnt/sub-data'
# btrfs subvolume create /mnt/sub-data2
Create subvolume '/mnt/sub-data2'
# btrfs subvolume list /mnt/
ID 256 gen 7 top level 5 path sub-data
ID 257 gen 8 top level 5 path sub-data2

# btrfs subvolume snapshot /mnt/sub-data /mnt/snapshot
Create a snapshot of '/mnt/sub-data' in '/mnt/snapshot/sub-data'

XFSファイルシステムをバックアップしてみる

・2014年6月にリリースされたRedHat Enterprise linux 7にてデフォルトのファイルシステムになった

# dd if=/dev/zero of=disk.img bs=1M count=256
...
# mkfs -t xfs disk.img
meta-data=disk.img               isize=512    agcount=4, agsize=16384 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0, rmapbt=0, reflink=0
data     =                       bsize=4096   blocks=65536, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

# mount -t xfs disk.img /mnt/
# df | grep mnt
/dev/loop1        258724   13616    245108   6% /mnt

# xfs_info /dev/loop1
meta-data=/dev/loop0             isize=512    agcount=4, agsize=16384 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1 spinodes=0 rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=65536, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

# xfsdump -f /backup/data.dump -L "full backup" -M "data.dump" /dev/loop1
...
xfsdump:   stream 0 /backup/data.dump OK (success)
xfsdump: Dump Status: SUCCESS

# xfsrestore -r -f /backup/data.dump /mnt
...
xfsrestore:   stream 0 /backup/data.dump OK (success)
xfsrestore: Restore Status: SUCCESS

Windowsでも読めるISOファイルを作成する

・-JオプションをつけることでISO9660+Joliet拡張のファイルを作成する

# mkisofs -R -T -J -o lpic2.iso lpic2
I: -input-charset not specified, using utf-8 (detected in locale settings)
Total translation table size: 220
Total rockridge attributes bytes: 330
Total directory bytes: 488
Path table size(bytes): 10
Max brk space used 0
183 extents written (0 MB)

カーネル

diffコマンドで取得した差分をpatchコマンドで適用する

# cat test.txt
this is test
# cat test2.txt
this is test
this is test2
# diff -up test.txt test2.txt > diff.patch
# patch test.txt < diff.patch
patching file test.txt
# cat test.txt
this is test
this is test2
# patch -R test.txt < diff.patch
patching file test.txt
# cat test.txt
this is test

https://qiita.com/astro_super_nova/items/e30dcaf4d106deebc63c

モジュールのファイルの場所を表示する

# modinfo -n xfs
/lib/modules/4.15.0-1043-aws/kernel/fs/xfs/xfs.ko

各モジュールの依存関係を記載したファイル

# cat /lib/modules/4.15.0-1043-aws/modules.dep

現在稼働しているカーネルパラメーター

# cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.15.0-1043-aws root=UUID...

システムの起動

変更された設定ファイルを表示する

# systemd-delta
[OVERRIDDEN] /etc/tmpfiles.d/screen-cleanup.conf → /usr/lib/tmpfiles.d/screen-cleanup.conf

--- /usr/lib/tmpfiles.d/screen-cleanup.conf     2017-07-01 21:07:57.000000000 +0900
+++ /etc/tmpfiles.d/screen-cleanup.conf 2018-09-13 00:58:27.539635430 +0900
@@ -1 +1 @@
-d /run/screen 0777 root utmp
+d /run/screen 1777 root utmp

[EXTENDED]   /lib/systemd/system/rc-local.service → /lib/systemd/system/rc-local.service.d/debian.conf
[EXTENDED]   /lib/systemd/system/user@.service → /lib/systemd/system/user@.service.d/timeout.conf
[MASKED]     /etc/udev/rules.d/60-cdrom_id.rules → /lib/udev/rules.d/60-cdrom_id.rules