In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "the method of Linux exchange partition SWAP and lvm management tutorial". In the daily operation, I believe many people have doubts about the method of Linux exchange partition SWAP and lvm management tutorial. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "Linux exchange partition SWAP method and lvm management tutorial". Next, please follow the editor to study!
Catalogue
1. Swap partition SWAP
1.1 create swapfile
1.2 format swap Partition
1.3 detect the current swap partition
1.4 Open the newly created SWAP partition
1.5 close the newly created swap partition
1.6 add a switching partition swap to the new area
2. Lvm management
Step lvm
1. Prepare physical disk (add disk to refer to previous blog)
3. Volume group management
Expand the volume group to add new disks to the volume group
4. Logical volume management
The extended capacity of a logical volume cannot exceed the capacity of a volume group
Logical volume clipping capacity for ext4 file system
First of all, we create a 1G logical volume as the cropped object.
1. If it has been mounted, it must be uninstalled first.
2. For tailoring capacity, the file system must be tested first.
3. Cut the logical volume capacity after the adjustment
4. It is strongly recommended that the file system be checked again after cropping.
5. Mounting test
1. Swap partition SWAP
Swap partitions generally specify that the size of virtual memory is 1 to 1.5 times the actual memory. If the actual memory exceeds the 8GB, you can directly allocate the 16GB to the virtual memory. If the virtual memory is insufficient, you need to add a virtual disk. Since the original disk cannot be re-partitioned, you can choose to create a new one.
1.1 create swapfile [root@clq0917 ~] # dd if=/dev/zero of=/opt/www bs=1M count=1024 record 10240read record 1024000 write out 1073741824 bytes (1.1GB) replicated, 10.7409 seconds, 100MB/ seconds [root@clq0917 ~] # 1.2 format swap partition [root@clq0917 ~] # mkswap-f / opt/www is setting swap space version 1, size = 1048572 KiB untagged UUID=9928fe54-9639-4dd9-90ef-82d3f69e94fe [root@clq0917 ~] # 1.3 detect the current swap partition [root@clq0917] # free-m total used free shared buffers cachedMem: 1840 1304 535 8 1 1115 Mozilla + buffers/cache: 188 1652Swap: 2047 0 2047 [root@clq0917 ~] # 1.4 enable the newly created SWAP partition [root@clq0917 ~] # swapon / opt/wwwswapon: / opt/www: unsafe permission 0644 0600 is recommended. / / use permission command [root@clq0917 ~] # chown 600 / opt/www [root@clq0917 ~] # free-m total used free shared buffers cachedMem: 1840 1305 535 8 1 1115 Muhammad + buffers/cache: 188 1651Swap: 3071 0 3071//swap multiple partitions Come out 1G1.5 and close the newly created swap partition [root@clq0917 ~] # swapoff / opt/www [root@clq0917 ~] # free-m total used free shared buffers cachedMem: 1840 1304 535 8 1 1115 Muhampac + buffers/cache: 188 1652Swap: 2047 02047 1652Swap / Restore to do not add virtual disk 1.6 add a swap partition swap1 to the new area. [root@clq0917 ~] # fdisk-l / dev/sdb disk / dev/sdb:21.5 GB 21474836480 bytes 41943040 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: 0x1f8fccca device Boot Start End Blocks Id System/dev/sdb1 2048 393215 195584 83 Linux/dev/sdb2 393216 41943039 20774912 5 Extended/dev/sdb5 395264 589823 97280 82 Linux swap ~ prepare this area for exchange partition 2. Change the partition type to 82 command (enter m for help): l 0 empty 24 NEC DOS 81 Minix / old Linu bf Solaris 1 FAT12 27 hidden NTFS Win 82 Linux exchange / So C1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C C6 DRDOS/sec (FAT- 4 FAT16 xfs_growfs / dev/hongmao/lv1ext--- > resize2fs / dev/hongmao/lv1) the logical volume clipping capacity of the ext4 file system first create a 1G logical volume as the clipping object
Lvcreate-n uplooking-L 1G finance
Mkfs.ext4 / dev/finance/uplooking
# mkdir-p / finance/uplooking
# mount / dev/finance/uplooking / finance/uplooking/
# cp / etc/host* / finance/uplooking/
1. If it has been mounted, it must be uninstalled first.
Umount / dev/finance/uplooking
2. For tailoring capacity, the file system must be tested first.
E2fsck-f / dev/finance/uplooking
Resize2fs / dev/finance/uplooking 512M
3. Cut the logical volume capacity after the adjustment
Lvreduce-L 512m / dev/finance/uplooking
WARNING: Reducing active logical volume to 512.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce uplooking? [y/n]: y
4. It is strongly recommended that the file system be checked again after cropping.
E2fsck-f / dev/finance/uplooking
5. Mounting test
If it can be mounted, it generally means that the file system is not corrupted if it is successfully cut.
Mount / dev/finance/uplooking / mnt
...
/ dev/mapper/finance-uplooking 472m 1.6m 435m 1% / mnt and the file system capacity is refreshed
Considerations for reducing logical volumes:
Can not be reduced online, you have to uninstall it first.
Ensure that the reduced space size can still store all the original data.
Files should be forcibly checked before shrinking to ensure that the file system is in a consistent state.
Use the command
E2fsck-f / PATH/TO/LV
At this point, the study on the "Linux exchange partition SWAP method and lvm management tutorial" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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: 241
*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.