In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Manage file system 1. Create EXT4 file system
The mkfs (Make Filesystem) command is used to create a file system (formatted). The basic syntax format of the mkfs command is as follows:
1) examples of mkfs applications
Format the / dev/sdb1 partition as the EXT4 file system.
[root@centos01 ~] # fdisk / dev/sdb Welcome to fdisk (util-linux 2.23.2). The changes remain in memory until you decide to write them to disk. Think twice before using the write command. Command (enter m for help): nPartition type: P primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): P partition number (1-4, default 1): start sector (2048-83886079, default is 2048): the default value 2048Last sector will be used, + sector or + size {KMagne MMagg} (2048-83886079, default is 83886079): + 5G partition 1 has been set to Linux type Set the size to 5 GiB command (enter m for help): P disk / dev/sdb:42.9 GB, 42949672960 bytes 83886080 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte I size (min / best): 512byte / 512byte disk label type: dos disk identifier: 0xd459c569 device Boot Start End Blocks Id System/dev/sdb1 2048 10487807 5242880 83 Linux command (enter m for help): wThe Partition table has been altered calling ioctl () to re-read partition table. Synchronizing disks. [root@centos01 ~] # mkfs-t ext4 / dev/sdb1 [root@centos01 ~] # mkfs.ext4 / dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) File system tag = OS type: Linux Block size = 4096 (log=2) Block size = 4096 (log=2) Stride=0 blocks, Stripe width=0 blocks327680 inodes, 1310720 blocks65536 blocks (5.00%) reserved for the super user first data Block = 0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768,98304,163840,229376,294912,819200 884736Allocating group tables: finish writing inode table: complete Creating journal (32768 blocks): complete Writing superblocks and filesystem accounting information: complete 2, create Swap swap file system
Use the mkswap command to create a swap file system; the basic syntax format is as follows:
1) examples of mkswap applications
Create the / dev/sdb2 partition as a swap partition.
[root@centos01 ~] # mkswap / dev/sdb2 mkswap: / dev/sdb2: warning: wiping old swap signature. Setting swap space version 1, size = 5242876 KiB unlabeled UUID=a86ecd38-3058-4d92-9688-346cb9407915 [root@centos01 ~] # cat / proc/meminfo | grep SwapTotal SwapTotal: 4194300 kB [root@centos01 ~] # swapon / dev/sdb2 [root@centos01 ~] # cat / proc/meminfo | grep SwapTotal SwapTotal: 9437176 kB [root@centos01 ~] # swapoff / dev/sdb2 [root@centos01 ~] # cat / proc/meminfo | grep SwapTotal SwapTotal: 4194300 kB3, mounting and unmounting file system
1) Mount the hard disk partition
The mount command mounts the file system and ISO image. The basic syntax format of mount is as follows:
Application examples:
[root@centos01 ~] # mkdir / sdb1 [root@centos01 ~] # mount / dev/sdb1 / sdb1/ [root@centos01 ~] # mount / dev/sdb1 on / sdb1 type ext4 (rw,relatime Data=ordered) [root@centos01 ~] # df-Th File system Type capacity available available mount point / dev/sda3 xfs 76G 3.6G 73G 5% / devtmpfs devtmpfs 474M 0 474m 0% / devtmpfs tmpfs 489m 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0M 482m 2% / runtmpfs Tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 197m 136M 61m 70% / boottmpfs tmpfs 98M 0% / run/user/0/dev/sdb1 ext4 4.8G 20m 4.6G 1% / sdb12) Unmount the mounted hard disk partition [root@centos01 ~] # umount / sdb1/ [root@centos01 ~] # df -Th file system type capacity available available mount point / dev/sda3 xfs 76G 3.7G 73G 5% / devtmpfs devtmpfs 474M 0474M 0% / devtmpfs tmpfs 489M 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0m 482m 2% / runtmpfs tmpfs 489m 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 197m 136m 61m 70% / boottmpfs tmpfs 98m 098m 0% / run/user/03) Mount ISO image [root@centos01 ~] # lsanaconda-ks.cfg ansible.iso initial-setup-ks.cfg [root@centos01 ~] # mount-o loop ansible.iso / mnt/ mount: / dev/loop0 write protection [root@centos01 ~] # mount will be mounted read-only. / root/ansible.iso on / mnt type iso9660 (ro Relatime) [root@centos01 ~] # df-Th File system Type capacity available available mount point / dev/sda3 xfs 76G 3.7G 73G 5% / devtmpfs devtmpfs 474M 0 474m 0% / devtmpfs tmpfs 489m 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0M 482m 2% / runtmpfs Tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 197m 136M 61m 70% / boottmpfs tmpfs 98M 098m 0% / run/user/0/dev/loop0 iso9660 83M 83M 0100% / mnt4) unmount the mounted ISO image [root@centos01 ~] # umount / mnt/ [root@centos01 ~] # df-Th File system type capacity used available mount point / dev/sda3 xfs 76G 3.7G 73G 5% / devtmpfs devtmpfs 474M 0474M 0% / devtmpfs tmpfs 489M 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0m 482m 2% / runtmpfs tmpfs 489M 0489m 0% / sys/fs/cgroup/dev/sda1 xfs 197m 136m 61m 70% / boottmpfs tmpfs 98m 0 98m 0% / run/user/04, Set up automatic mounting of the file system
The / etc/fstab configuration file contains the file system records that need to be mounted automatically after boot. Examples are as follows:
1) automatically mount the hard disk partition [root@centos01 ~] # mkfs.ext4 / dev/sdb1 [root@centos01 ~] # vim / etc/fstab. / dev/sdb1 / sdb1 ext4 defaults 0 0 [root@centos01 ~] # df-Th File system Type capacity available available mount point / dev/sda3 xfs 76G 3.6G 73G 5% / devtmpfs devtmpfs 474M 0474M 0 / Devtmpfs tmpfs 489M 0 489m 0% / dev/shmtmpfs tmpfs 489M 7.0M 482m 2% / runtmpfs tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sdb1 ext4 4.8G 20m 4.6G 1% / sdb1/dev/sda1 xfs 197m 136m 61m 70% / boottmpfs tmpfs 98M 0 98m 0% / run/user/0 [root@centos01 ~] # cat / proc/meminfo | grep SwapTotal SwapTotal: 4194300 kB [root@centos01 ~] # vim / etc/fstab. / dev/sdb1 / sdb1 ext4 defaults 0 0 / dev/sdb2 swap swap defaults 0 0 [root@centos01 ~] # cat / proc/meminfo | grep SwapTotal SwapTotal: 9437176 kB2) automatically mount the ISO image [root @ centos01 ~] # lsanaconda-ks.cfg ansible.iso initial-setup-ks.cfg [root@centos01 ~] # mount-o loop ansible.iso / mnt/ mount: / dev/loop0 write protection [root@centos01 ~] # mount will be mounted read-only. / root/ansible.iso on / mnt type iso9660 (ro,relatime) [root@centos01 ~] # umount / mnt/ [root@centos01 ~] # vim / etc/fstab. / dev/sdb1 / sdb1 ext4 defaults 0 0/ dev/sdb2 swap swap defaults 0 0/root/ansible.iso / mnt iso9660 defaults 0 0 [root@ Centos01 ~] # df-Th file system type capacity available available mount point / dev/sda3 xfs 76G 3.7G 73G 5% / devtmpfs devtmpfs 474M 0474m 0% / devtmpfs tmpfs 489m 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0M 482m 2% / runtmpfs Tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/loop0 iso9660 83M 83M 0% / mnt/dev/sdb1 ext4 4.8G 20M 4.6G 1% / sdb1/dev/sda1 xfs 197m 136m 61m 70% / boottmpfs tmpfs 98m 098m 0% / run/user/05, View disk usage
The basic syntax format of the df command is as follows:
Examples of applications are as follows:
[root@centos01 ~] # df-Th File system Type capacity available available mount point / dev/sda3 xfs 76G 3.7G 73G 5% / devtmpfs devtmpfs 474M 0474m 0% / devtmpfs tmpfs 489m 0 489m 0% / dev/shmtmpfs tmpfs 489m 7.0M 482m 2% / runtmpfs tmpfs 489m 0489m 0% / sys/fs/cgroup/dev/sda1 xfs 197M 136M 61m 70% / boottmpfs tmpfs 98m 098m 0% / run/user/0 II, Manage LVM logical volumes 1. Overview of LVM
Logical Volume Manager, logical volume management.
1) LVM action
Adjust the disk capacity dynamically to improve the flexibility of disk management. Note: the / boot partition is used to hold boot files and cannot be created based on LVM.
2) the basic concepts of graphical interface management tools system-config-lvm2 and LVM mechanism.
PV (Physical Volume, physical volume): an entire hard disk, or a normal partition created using tools such as fdisk; includes many PE (Physical Extent, basic units) of the default 4MB size.
VG (Volume Group, volume group): a combination of one or more physical volumes.
LV (Logical Volume, logical volume): a piece of space separated from a volume group and used to establish a file system.
3. LVM management commands 1) Common LVM management commands
2) main commands for managing LVM
4. LVM application case 1) add two hard disks by yourself, use the fdisk command to plan two partitions, and set the type to "8e" [root@centos01 ~] # fdisk-l / dev/sdb / dev/sdc | grep "LVM" / dev/sdb1 2048 83886079 41942016 8e Linux LVM/dev/sdc1 2048 83886079 41942016 8e successfully created) create a physical volume pvcreate [root@centos01 ~] # pvcreate / dev/sdb1 / dev/sdc1 Physical volume "/ dev/sdb1" successfully created. Physical volume "/ dev/sdc1" successfully created.3) create volume group vgcreate [root@centos01 ~] # vgcreate mail_store/ dev/sdb1 / dev/sdc1 Volume group "mail_store" successfully created4) create logical volume lvcreate [root@centos01 ~] # lvcreate-L 20G-n mbox mail_store Logical volume "mbox" created. [root@centos01 ~] # mkfs-t ext4 / dev/mail_store/mboxmke2fs 1.42.9 (28-Dec-2013) File system label = OS type: Linux Block large Small = 4096 (log=2) chunk size = 4096 (log=2) Stride=0 blocks Stripe width=0 blocks1310720 inodes, 5242880 blocks262144 blocks (5.00%) reserved for the super user first data block = 0Maximum filesystem blocks=2153775104160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768,98304,163840,229376,294912,819200,884736,1605632,2654208 4096000Allocating group tables: finish writing inode table: complete Creating journal (32768 blocks): complete Writing superblocks and filesystem accounting information: complete 5) expand the logical volume [root@centos01] # lvextend-L + 5G / dev/mail_store/mbox Size of logical volume mail_store/mbox changed from 20.00 GiB (5120 extents) to 25.00 GiB (6400 extents). Logical volume mail_store/mbox successfully resized. [root@centos01] # [root@centos01] # resize2fs / dev/mail_store/mbox resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on / dev/mail_store/mbox to 6553600 (4k) blocks.The filesystem on / dev/mail_store/mbox is now 6553600 blocks long.
-this is the end of this article. Thank you for reading-
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.