Linux lessons 20 (проверка файловой системы)

df -h

mkdir /mnt/hard
mount /dev/sdb /mnn/hard

[root@cent1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 9.0M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos_cent1-root 30G 2.7G 28G 9% /
/dev/sda1 1014M 193M 822M 19% /boot
/dev/mapper/centos_cent1-home 1.9G 110M 1.8G 6% /home
tmpfs 378M 0 378M 0% /run/user/0
/dev/sdb 9.8G 37M 9.2G 1% /mnt

df -i поакжет мвободные ноды

[root@cent1 hard]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 479761 378 479383 1% /dev
tmpfs 482676 1 482675 1% /dev/shm
tmpfs 482676 595 482081 1% /run
tmpfs 482676 16 482660 1% /sys/fs/cgroup
/dev/mapper/centos_cent1-root 15558656 63957 15494699 1% /
/dev/sda1 524288 334 523954 1% /boot
/dev/mapper/centos_cent1-home 976896 44 976852 1% /home
tmpfs 482676 1 482675 1% /run/user/0
/dev/sdb 655360 12 655348 1% /mnt/hard

du -h покажет сколько занимют папки и подпапки
du -h /home/andrey/*

44K /home/andrey/ajakava
39M /home/andrey/arhiv.cpio
4.0K /home/andrey/Dockerfile
0 /home/andrey/extract
0 /home/andrey/folder1
0 /home/andrey/folder2/folder1
0 /home/andrey/folder2
39M /home/andrey/kubectl
56K /home/andrey/test

du -h —summarize /home/andrey/ покажет сколько занимет папка
77M /home/andrey/

ls -ls
ls -i

—————проверака файловой системы——————

fsck /dev/sdb1
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/sdb1 is mounted.
e2fsck: Cannot continue, aborting. диск надо отмонтировать

umount /dev/sdb1

fsck /dev/sdb1
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/sdb1: clean, 11/655360 files, 83137/2621184 blocks

или точнее, с указанием типа файловой системы

fsck -t ext4 /dev/sdb1
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/sdb1: clean, 11/655360 files, 83137/2621184 blocks

mkfs -t xfs -f /dev/sdb1 переформатируем
fsck /dev/sdb1
fsck from util-linux 2.23.2
If you wish to check the consistency of an XFS filesystem or
repair a damaged filesystem, see xfs_repair(8).

xfs_check /dev/sdb1

mount /dev/sdb1/ /mnt/hard

debugfs -w /dev/sdb1

[root@cent1 hard]# debugfs -w /dev/sdb1
debugfs 1.42.9 (28-Dec-2013)
debugfs: ls
2 (12) . 2 (12) .. 11 (20) lost+found 12 (4052) test.txt
debugfs: rm test.txt

debugfs: ls
2 (12) . 2 (12) .. 11 (4072) lost+found

debugfs: lsdel
Inode Owner Mode Size Blocks Time deleted
0 deleted inodes found.

debugfs: ls
2 (12) . 2 (12) .. 11 (4072) lost+found
debugfs: lsdel
Inode Owner Mode Size Blocks Time deleted
0 deleted inodes found.
debugfs: undel <12> test.txt
debugfs: ls
2 (12) . 2 (12) .. 11 (20) lost+found 12 (4052) test.txt возратит удаленный файл

dumpe2fs /dev/sdb1 > out.txt
less out.txt

tune2fs настраивает файловую систему

tune2fs -O has_journal /dev/sdb1 добавили опцию журналирования
tune2fs 1.42.9 (28-Dec-2013)
[root@cent1 hard]# dumpe2fs /dev/sdb1 | grep features
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Journal features: journal_64bit