Linux系统磁盘管理详解(7)

[root@cobbler-node1 ~]# dd if=/dev/zero of=/tmp/swap bs=10M count=100 100+0 records in 100+0 records out 1048576000 bytes (1.0 GB) copied, 31.7965 s, 33.0 MB/s [root@cobbler-node1 ~]# ls -ldh /tmp/swap -rw-r--r-- 1 root root 1000M Jun 23 15:05 /tmp/swap [root@cobbler-node1 ~]# mkswap /tmp/swap mkswap: /tmp/swap: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 1023996 KiB no label, UUID=ea3fe1f1-895c-4885-9e42-78cab304efd1 [root@cobbler-node1 ~]# free -m total used free shared buffers cached Mem: 474 457 17 0 2 390 -/+ buffers/cache: 64 410 Swap: 2047 0 2047 [root@cobbler-node1 ~]# swapon /tmp/swap [root@cobbler-node1 ~]# free -m total used free shared buffers cached Mem: 474 458 16 0 2 390 -/+ buffers/cache: 65 409 Swap: 3047 0 3047 [root@cobbler-node1 ~]# echo "/tmp/swap swap swap defaults 0 0" >> /etc/fstab #显示正在使用的虚拟交换空间 [root@cobbler-node1 ~]# swapon -s Filename Type Size Used Priority /dev/sda2 partition 1048568 0 -1 /dev/sdb1 partition 1048568 0 -2 /tmp/swap file 1023992 0 -3 企业案例场景: Swap在工作中,特别是java环境,程序写的有问题,会发生内存泄露,可能会被占用,让开发改程序,临时运维加大swap,重启系统

7 磁盘格式化挂载 7.1 磁盘格式化并挂载的操作步骤

#普通ext4文件系统格式化过程 [root@cobbler-node1 ~]# mkfs -t ext4 -b 4096 -I 256 /dev/sdb3 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 24320 inodes, 24320 blocks 1216 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=25165824 1 block group 32768 blocks per group, 32768 fragments per group 24320 inodes per group Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 24 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. #防止出现上面的告警信息(标黄) [root@cobbler-node1 ~]# tune2fs -c -1 /dev/sdb3 tune2fs 1.41.12 (17-May-2010) Setting maximal mount count to -1 #挂载到相应目录 [root@cobbler-node1 ~]# mount -t ext4 /dev/sdb3 /applog1 #显示挂载的文件系统 [root@cobbler-node1 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 ext4 8.7G 3.3G 5.1G 40% / tmpfs tmpfs 238M 0 238M 0% /dev/shm /dev/sda1 ext4 194M 29M 155M 16% /boot /dev/sr0 iso9660 4.2G 4.2G 0 100% /mnt /dev/sdb3 ext4 90M 4.1M 81M 5% /applog1

7.2 dumpe2fs查看文件系统内部详细信息

# dumpe2fs - dump ext2/ext3/ext4 filesystem information [root@cobbler-node1 ~]# dumpe2fs /dev/sdb3 dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 23d188bf-7b4c-41c1-a33e-dd908926303f Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg
dir_nlink extra_isize Filesystem flags: signed_directory_hash Default
mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 24320 Block count: 24320 Reserved block count: 1216 Free blocks: 21761 Free inodes: 24309 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 5 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 24320 Inode blocks per group: 1520 Flex block group size: 16 Filesystem created: Sun Jun 24 15:01:18 2018 Last mount time: Sun Jun 24 15:05:39 2018 Last write time: Sun Jun 24 15:05:39 2018 Mount count: 1 Maximum mount count: -1 Last checked: Sun Jun 24 15:01:18 2018 Check interval: 15552000 (6 months) Next check after: Fri Dec 21 15:01:18 2018 Lifetime writes: 10 MB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 256 Required extra isize: 28 Desired extra isize: 28 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: 89578f2c-49a6-4023-af1d-bd055875100f Journal backup: inode blocks Journal features: (none) Journal size: 4096k Journal length: 1024 Journal sequence: 0x00000001 Journal start: 0 Group 0: (Blocks 0-24319) [ITABLE_ZEROED] Checksum 0xeec2, unused inodes 24309 Primary superblock at 0, Group descriptors at 1-1 Reserved GDT blocks at 2-6 Block bitmap at 7 (+7), Inode bitmap at 23 (+23) Inode table at 39-1558 (+39) 21761 free blocks, 24309 free inodes, 2 directories, 24309 unused inodes Free blocks: 2559-24319 Free inodes: 12-24320

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12101.html