In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
When installing a Unix-like operating system, partitioning is definitely an essential step. This step is simple and simple. Step by step partition-> formatting can be completed according to the prompts. Since there is almost no bottleneck in the purchase of hard drives in current projects, many projects may not use the dynamic expansion function of LVM until the hardware goes offline. So when installing OS, I will not specifically study the concepts of LVM, PV, VG, LV, and so on, because my later project is mainly about storage, so I recently studied several documents to summarize some things about partitioning in unix-like systems.
There are two ways to partition, format and mount the hard disk in linux. The command line is used in the graphical interface of the initial installation of OS and the later expansion of the hard disk. Let's talk about the relatively troublesome latter:
First of all, take a look at the figure above. Enter fdisk-l in linux to see the hard disk information currently installed in the server (lv is not visible). / dev/sda refers to the mounting path of the hard disk sda after installation. Similar discs are mounted on / dev/sr0 and / dev/media, and the latter is a soft link to the former. Start end is the starting position of the sector, blocks is the block size, and the above figure is calculated in terms of kb. ID refers to the code name of the file system: 83 means ext2/3,82 represents swap,5 is an extended partition, lvm is 8eMagne raid is fd.
Sda1~6 represents the current partition of sda, which is divided into six zones, for example, sda1 is mounted in /, sd2 is mounted in / opt, which can be completed during OS installation. Next, we will talk about the process of dividing sda into two new partitions, sda7 and sda8, and configuring it as LVM using the command line.
1) # fdisk / dev/sda, enter the size and hex code [8e], 8e is the code of the LVM type partition, similar to 83 for ext2/3
The latest understanding: in fact, pv does not need to be formatted, in other words, it has nothing to do with formatting, pv is just a further division of the physical disk, refer to this article: file system naked devices
2) # partprobe, let the LVM partition take effect immediately without reboot; at this point, the physical partition is created.
3) # pvcreat / dev/sda7, create the physical volume PV of LVM, create sda8 in the same way, and then view it with pvscan or pvdiaplay.
4) # vgcreat volume group name physical volume
# vgcreat vg1 / dev/sda7 / dev/sda8, use the two PV you created earlier to create the VG of the LVM (you can also create it with a PV), and view it with vgscan or vhdisplay after the creation is completed.
5) # lvcreat-L size volume group name-n logical volume name
# lvcreat-L 5G vg1-n lv1, create a 5G lv with the previously created vg, and then the lvm is created
Only the logical volume can not write data, the command can not be implemented on the logical volume alone, only by establishing the file system on the logical volume, the user can operate on the logical volume through the file system.
6) # mkfs.ext3 / dev/vg1/lv1 plus file system
# mount-t ext3 / dev/vg1/lv1 / mnt format lv and mount it on / mnt, and you can see it under mnt; lost+found is considered a success. Note: lv cannot be seen with fdisk-l, but with lvdisplay talent, refer to the following figure:
If you want to draw another lv2 from the vg1 created above, you can start directly from lvcreat. A hard drive supports 15 partitions, but if you use vg to divide lv. There can be no quantity limit.
Summarize the lvm configuration process: hard disk partition-> create pv- > create vg- > create lv- > format mount.
Here's how to extend lv:
For example, the lv1 divided above is 5G. If you want to add 1G, the steps are as follows:
0) uninstall umount / mnt first
# lvresize-L absolute size object
1) # lvresize-L 6G / dev/vg1/lv1
2) # e2fsck-f / dev/vg1/lv1 check data blocks for damage
3) # resize2fs / dev/vg1/lv1 determines the size and effective data
4) # mount-t ext3 / dev/vg1/lv1 / mnt remount
At this point, the capacity expansion of lv is completed, and the capacity of lv is expanded based on the capacity of vg. If you want to expand the capacity of vg, the method is as follows:
1) # pvcreate / dev/sda9 create a new pv
2) # vgextend volume group name physical volume
# vgextend vg1 / dev/sd9 add sd9 to vg
3) # vgdisplay vg1 View
After the expansion of vg, the methods to delete lv, vg, pv and partitions are as follows. Note the order in which they are deleted:
1) # umount / mnt
2) # lvremove / dev/vg1/lv1 Delete lv
3) # vgremove vg1 Delete vg
4) # pvremove / dev/sda7 Delete pv physical Volume
5) # fdisk,command Select d philosophy number Select 8 to delete the partition
6) # partprobe command does not restart to take effect
So far, everything from the creation of the partition to the creation of the lv is eliminated.
You can also use the command line to create raid. You can add it when you have time. Let's talk about the lvm creation when installing os:
As shown in the above figure, the above image appears after clicking sda in the previous step, and you can create a lvm directly from sda.
As shown in the figure above, create a pv from sda2, and then continue partitioning in the vg above. In fact, partitioning in pv means the same thing as partitioning directly in sdax, but the difference is the extended functionality of lvm.
# fdisk-l can only view physical devices, not lv. If you want to view lv, use lvdisplay, and similar
The mapping relationships under / dev/mapper/VoLGroup00-LogVol00 's df-h dev/VoLGroup00 bind mapper are all mapping relationships, which can be found only when lvm and multipath are done. You can check them under / dev/VoLGroup00.
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.