First, the self-built warehouse yum, respectively, the network source and local sources
Local yum repository is set up the following three steps:
- Create a repository directory structure
- Upload the package to the appropriate directory, or directly mount the CD also, if mount the CD, the third step can be omitted, because the disc there repodata default directory, which is the repository and metadata information put.
- Creating a warehouse metadata information (to put the directory path packet stored createrepo later)
Build a network source warehouse is on the local warehouse built multi-step process to install a http, and then the corresponding directory is mounted to the working directory http on it, please refer to my blog realization https: //www.cnblogs .com / qiuhom-1874 / p / 11487456.html
Build a good warehouse can create the appropriate configuration files, its client configuration file format is as follows (/etc/yum.repo.d/xxx.repo)
[my_base] name=this is test repo baseurl=file:///rpm/centos/$releasever/os/$basearch gpgcheck=0
Description: The first line in brackets any content can fill the equivalent of the name of the warehouse, name explanatory information warehouse, baseurl is the path to the warehouse, the above is a local repository of address, if it is web-based http warehouse , it is necessary to write http: // depot server address / parent directory repodata folder, gpgcheck = 0 means no open gpg verification.
After a good repo client configuration file, you can view the information we built warehouse
yum clean all ## clear the cache yum repolist ## listed warehouse information
Second, compile and install http2.4, implementation can be a normal visit, and the compilation step and submit the results.
Compile installation, first install the build environment package, such as: "development tools", then download a good source package unzip, then enter the directory to unpack, and then view the README or INSTALL documentation, and then run in the unpacked directory ./ configure --help see the compiler option specification, compiler options and then customize according to their needs, generate makefile, then make && make install to compile and install http2.4 steps as follows:
1, yum install "development tools" packet group
[root@localhost ~]# yum groupinstall "development tools" -y
2, create a system user to start the httpd
[root@localhost ~]useradd -r -u 80 -d /data/www/ -s /sbin/nologin httpd [root@localhost ~]# getent passwd httpd httpd:x:80:80::/data/www/:/sbin/nologin
3. Download Source Package
[root@localhost ~]# wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.41.tar.gz --2019-11-05 20:11:40-- http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.41.tar.gz Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 9267917 (8.8M) [application/octet-stream] Saving to: ‘httpd-2.4.41.tar.gz’ 100%[======================================>] 9,267,917 2.82MB/s in 3.1s 2019-11-05 20:11:43 (2.82 MB/s) - ‘httpd-2.4.41.tar.gz’ saved [9267917/9267917] [root@localhost ~]# ll total 9052 -rw-r--r--. 1 root root 9267917 Aug 13 07:37 httpd-2.4.41.tar.gz
4, extract the source packet
[root@localhost ~]# tar xf httpd-2.4.41.tar.gz [root@localhost ~]# ls httpd-2.4.41 httpd-2.4.41.tar.gz
5, after entering to extract the directory
[root@localhost ~]# cd httpd-2.4.41/
6, see the README file
Installation ------------ Please see the file called INSTALL. Platform specific notes can be found in README.platforms.
Description: It says it will look at the INSTALL file to install
7, see the INSTALL file
Quick Start - Unix ------------------ For complete installation documentation, see [ht]docs/manual/install.html or http://httpd.apache.org/docs/2.4/install.html $ ./configure --prefix=PREFIX $ make $ make install $ PREFIX/bin/apachectl start
Description: INSTALL file says quick installation to use the above command you can run fast service, fast installation of course, we want to specify the location to install the software, many options are default values.
For a short impression of what possibilities you have, here is a typical example which configures Apache for the installation tree /sw/pkg/apache with a particular compiler and flags plus the two additional modules mod_rewrite and mod_speling for later loading through the DSO mechanism: $ CC="pgcc" CFLAGS="-O2" \ ./configure --prefix=/sw/pkg/apache \ --enable-rewrite=shared \ --enable-speling=shared The easiest way to find all of the configuration flags for Apache 2.4 is to run ./configure --help.
Description: INSTALL also told us that if we need to compile and install additional modules, we use it like this with the option to specify to our example. To see more information about course options, we can run ./configure --help to see
8, see ./configure Options Help
[root@localhost httpd-2.4.41]# ./configure --help `configure' configures this package to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local/apache2] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/apache2/bin', `/usr/local/apache2/lib' etc. You can specify an installation prefix other than `/usr/local/apache2' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] Documentation DVI the DIR = --dvidir [docdir] --pdfdir the DIR = PDF Documentation [docdir] --psdir the DIR = PS Documentation [docdir] ... display section is omitted
Description: We can see that there are many .configure compiler options, each option represents a different function and meaning.
9, specify the options they need to run ./configure + options check the system has a designated function, said dependent libraries and packages.
[root@localhost httpd-2.4.41]# ./configure --prefix=/application/httpd_2.4 --sysconfdir=/etc/httpd24 --enable-ssl --disable-status checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... no configure: error: APR not found. Please read the documentation. [root@localhost httpd-2.4.41]#
Description: We specify httpd installed /application/httpd_2.4 directory, system configuration files are stored in / etc / httpd24 directory, open ssl function, turn off the process / thread monitoring. configure Baocuo, can not find the APR, please read the documentation
10, the installation dependencies
yum install apr-devel apr-util-devel pcre-devel openssl-devel
Description: Installation can rely on it to do the first step. In the case we are familiar with the software say it can be installed in advance dependent packages.
11. After installing dependencies, our compliance function to compile options with ./configure options we specify + to check our current system in
config.status: creating build/config_vars.sh config.status: creating include/ap_config_auto.h config.status: executing default commands configure: summary of build options: Server Version: 2.4.41 Install prefix: /application/httpd_2.4 C compiler: gcc -std=gnu99 CFLAGS: -pthread CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE LDFLAGS: LIBS: C preprocessor: gcc -E [root@localhost httpd-2.4.41]#
Note: After installation depends, again we run ./configure + we specify compiler options, have not found the word ERROR, that we specify compiler options in the current system environment can be compiled
12, compiled
usr / lib64 / apr-1 / build / libtool --silent --mode = link gcc -std = gnu99 -pthread -o mod_rewrite.la -rpath /application/httpd_2.4/modules -module -avoid-version mod_rewrite.lo make [4]: leaving directory "/root/httpd-2.4.41/modules/mappers" the make [. 3]: leaving directory "/root/httpd-2.4.41/modules/mappers" the make [2]: leave directory " /root/httpd-2.4.41/modules " the make [2]: enter the directory" /root/httpd-2.4.41/support " the make [2]: leave directory" /root/httpd-2.4.41/support " the make [1]: leave directory "/root/httpd-2.4.41" [root @ localhost httpd-2.4.41] #
Description: After we execute the make command to compile a large information display will appear, if there is no final ERROR appears, indicating that there is no question we compile-time
13, installation
Installing configuration files mkdir /etc/httpd24 mkdir /etc/httpd24/extra mkdir /etc/httpd24/original mkdir /etc/httpd24/original/extra Installing HTML documents mkdir /application/httpd_2.4/htdocs Installing error documents mkdir /application/httpd_2.4/error Installing icons mkdir /application/httpd_2.4/icons mkdir /application/httpd_2.4/logs Installing CGIs mkdir /application/httpd_2.4/cgi-bin Installing header files mkdir /application/httpd_2.4/include Installing build system files mkdir /application/httpd_2.4/build Installing man pages and online manual mkdir /application/httpd_2.4/man /application/httpd_2.4/man/man1 mkdir mkdir /application/httpd_2.4/man/man8 mkdir /application/httpd_2.4/manual the make [1]: leave directory "/root/httpd-2.4.41" [root @localhost httpd-2.4.41] #
Description: We can understand that by executing make install, the installation is to copy our compiled libraries and binaries to the appropriate directory of the process
14, add the PATH environment variable, and load the environment variables
[root@localhost httpd-2.4.41]# ll /application/httpd_2.4/bin/ 总用量 1176 -rwxr-xr-x 1 root root 73808 11月 6 05:20 ab -rwxr-xr-x 1 root 40 3449 11月 6 05:13 apachectl -rwxr-xr-x 1 root 40 23519 11月 6 05:13 apxs -rwxr-xr-x 1 root root 8736 11月 6 05:20 checkgid -rwxr-xr-x 1 root 40 8925 11月 6 05:13 dbmmanage -rw-r--r-- 1 root 40 1081 11月 6 05:13 envvars -rw-r--r-- 1 root 40 1081 11月 6 05:13 envvars-std -rwxr-xr-x 1 root root 13848 11月 6 05:20 fcgistarter -rwxr-xr-x 1 root root 40984 11月 6 05:20 htcacheclean -rwxr-xr-x 1 root root 28096 11月 6 05:20 htdbm -rwxr-xr-x 1 root root 18208 11月 6 05:20 htdigest -rwxr-xr-x 1 root root 23456 11月 6 05:20 htpasswd -rwxr-xr-x 1 root root 867296 11月 6 05:20 httpd -rwxr-xr-x 1 root root 13800 11月 6 05:20 httxt2dbm -rwxr-xr-x 1 root root 14440 11月 6 05:20 logresolve -rwxr-xr-x 1 root root 27432 11月 6 05:20 rotatelogs [root@localhost httpd-2.4.41]# echo 'export PATH=/application/httpd_2.4/bin/:$PATH' >/etc/profile.d/http24.sh [root@localhost httpd-2.4.41]# . /etc/profile.d/http24.sh [root@localhost httpd-2.4.41]# echo $PATH /application/httpd_2.4/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost httpd-2.4.41]#
15, start the service (before starting the service, the /etc/httpd24/httpd.conf in the User change the user httpd created for us before)
[root@localhost httpd-2.4.41]# apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message [root@localhost httpd-2.4.41]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::80 :::* LISTEN 0 32 :::21 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* [root@localhost httpd-2.4.41]# ps axu |grep httpd root 41401 0.0 0.1 72852 2956 ? Ss 05:28 0:00 /application/httpd_2.4/bin/httpd -k start httpd 41583 0.0 0.3 427352 6256 ? Sl 05:39 0:00 /application/httpd_2.4/bin/httpd -k start httpd 41584 0.0 0.3 361816 6264 ? Sl 05:39 0:00 /application/httpd_2.4/bin/httpd -k start httpd 41585 0.0 0.3 361816 6264 ? Sl 05:39 0:00 /application/httpd_2.4/bin/httpd -k start root 41668 0.0 0.0 112724 984 pts/0 R+ 05:40 0:00 grep --color=auto httpd
Note: You can see 80 port is already in a listening state, httpd process accordingly up, besides our designated system is run by the user.
16, visit our server with a browser
Third, 2G to create a file system block size of 2048 bytes, reserved 1% of the available space, file system ext4, the volume label Test, required to automatically mount the partition / test directory boot, and acl mount options have default
1, partition
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 3G 0 part [SWAP] └─sda3 8:3 0 16.8G 0 part / sdb 8:16 0 40G 0 disk sr0 11:0 1 1024M 0 rom [root@localhost ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x7a888819. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): Value out of range. Partition number (1-4): 1 First cylinder (1-5221, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221): +2G Command (m for help): p Disk /dev/sdb: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7a888819 Device Boot Start End Blocks Id System /dev/sdb1 1 262 2104483+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
2, create a file system
[root@localhost ~]# mkfs.ext4 -b 2048 -m 1 -L "test" /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label=test OS type: Linux Block size=2048 (log=1) Fragment size=2048 (log=1) Stride=0 blocks, Stripe width=0 blocks 131560 inodes, 1052240 blocks 10522 blocks (1.00%) reserved for the super user First data block=0 Maximum filesystem blocks=538968064 65 block groups 16384 blocks per group, 16384 fragments per group 2024 inodes per group Superblock backups stored on blocks: 16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Description: centos6 to manually create the file system does not default ACL function, you need to use tune2fs -o acl / dev / sdb1 to add the default mount options have acl function
3, add the default mount options have acl function
[root@localhost ~]# tune2fs -l /dev/sdb1 tune2fs 1.41.12 (17-May-2010) Filesystem volume name: test Last mounted on: <not available> Filesystem UUID: be76ff36-e949-4434-9925-af60ce4e155a Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super 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: 131560 Block count: 1052240 Reserved block count: 10522 Free blocks: 998252 Free inodes: 131549 First block: 0 Block size: 2048 Fragment size: 2048 Reserved GDT blocks: 512 Blocks per group: 16384 Fragments per group: 16384 Inodes per group: 2024 Inode blocks per group: 253 Flex block group size: 16 Filesystem created: Tue Oct 22 02:45:40 2019 Last mount time: n/a Last write time: Tue Oct 22 02:45:40 2019 Mount count: 0 Maximum mount count: 39 Last checked: Tue Oct 22 02:45:40 2019 Check interval: 15552000 (6 months) Next check after: Sun Apr 19 02:45:40 2020 Lifetime writes: 97 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: 2c750580-3dd9-4af4-a1e9-581761cd9559 Journal backup: inode blocks [root@localhost ~]# tune2fs -o acl /dev/sdb1 tune2fs 1.41.12 (17-May-2010) [root@localhost ~]# tune2fs -l /dev/sdb1 tune2fs 1.41.12 (17-May-2010) Filesystem volume name: test Last mounted on: <not available> Filesystem UUID: be76ff36-e949-4434-9925-af60ce4e155a Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 131560 Block count: 1052240 Reserved block count: 10522 Free blocks: 998252 Free inodes: 131549 First block: 0 Block size: 2048 Fragment size: 2048 Reserved GDT blocks: 512 Blocks per group: 16384 Fragments per group: 16384 Inodes per group: 2024 Inode blocks per group: 253 Flex block group size: 16 Filesystem created: Tue Oct 22 02:45:40 2019 Last mount time: n/a Last write time: Tue Oct 22 02:46:53 2019 Mount count: 0 Maximum mount count: 39 Last checked: Tue Oct 22 02:45:40 2019 Check interval: 15552000 (6 months) Next check after: Sun Apr 19 02:45:40 2020 Lifetime writes: 97 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: 2c750580-3dd9-4af4-a1e9-581761cd9559 Journal backup: inode blocks [root@localhost ~]#
Note: You can see Default mount options: acl, said: have the acl mount option, the block size is 2048, Block count: 1052240 and Reserved block count: 10522 ratio is 100: 1, Filesystem volume name: test represents the label name to test
4. Check the label / dev / sdb1 of
[root@localhost ~]# e2label /dev/sdb1 test
5, power is provided to mount / test directory
[root@localhost ~]# mkdir /test [root@localhost ~]# echo '/dev/sdb1 /test ext4 defaults,acl 0 0 ' >> /etc/fstab [root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 17187708 1915396 14392544 12% / tmpfs 953456 0 953456 0% /dev/shm /dev/sda1 194241 40472 143529 22% /boot [root@localhost ~]# mount -a [root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 17187708 1915396 14392544 12% / tmpfs 953456 0 953456 0% /dev/shm /dev/sda1 194241 40472 143529 22% /boot /dev/sdb1 2005740 9236 1975460 1% /test [root@localhost ~]# mount /dev/sda3 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) /dev/sda1 on /boot type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sdb1 on /test type ext4 (rw,acl) [root@localhost ~]#
Note: You can see the / dev / sdb1 file system type is ext4, and to write, acl to mount / test
Four, creating a size of the at least two PV VG is composed of named testvg of 20G; PE claim size 16MB, then the size of 5G created logical volume in the volume group testlv; to mount / users directory
1, create a partition and specify the size of 10G, and the partition type to Linux LVM type
[root@localhost ~]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): p Disk /dev/sdb: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7a888819 Device Boot Start End Blocks Id System /dev/sdb1 1 262 2104483+ 83 Linux Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (263-5221, default 263): Using default value 263 Last cylinder, +cylinders or +size{K,M,G} (263-5221, default 5221): +10G Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (1569-5221, default 1569): Using default value 1569 Last cylinder, +cylinders or +size{K,M,G} (1569-5221, default 5221): +10G Command (m for help): p Disk /dev/sdb: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7a888819 Device Boot Start End Blocks Id System /dev/sdb1 1 262 2104483+ 83 Linux /dev/sdb2 263 1568 10490445 83 Linux /dev/sdb3 1569 2874 10490445 83 Linux Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx 5 Extended 42 SFS 86 NTFS volume set da Non-FS data 6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt 9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT 1e Hidden W95 FAT1 Hex code (type L to list codes): 8e Changed system type of partition 2 to 8e (Linux LVM) Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 8e Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p Disk /dev/sdb: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7a888819 Device Boot Start End Blocks Id System /dev/sdb1 1 262 2104483+ 83 Linux /dev/sdb2 263 1568 10490445 8e Linux LVM /dev/sdb3 1569 2874 10490445 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@localhost ~]#
Note: You can see the type of partition / dev / sdb1 and / dev / sdb2 for Linux LVM
2. Create pv
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 3G 0 part [SWAP] └─sda3 8:3 0 16.8G 0 part / sdb 8:16 0 40G 0 disk └─sdb1 8:17 0 2G 0 part /test sr0 11:0 1 1024M 0 rom [root@localhost ~]# partx -a /dev/sdb BLKPG: Device or resource busy error adding partition 1 [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 3G 0 part [SWAP] └─sda3 8:3 0 16.8G 0 part / sdb 8:16 0 40G 0 disk ├─sdb1 8:17 0 2G 0 part /test ├─sdb2 8:18 0 10G 0 part └─sdb3 8:19 0 10G 0 part sr0 11:0 1 1024M 0 rom [root@localhost ~]# pvcreate /dev/sdb2 /dev/sdb3 Physical volume "/dev/sdb2" successfully created Physical volume "/dev/sdb3" successfully created [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb2 lvm2 --- 10.00g 10.00g /dev/sdb3 lvm2 --- 10.00g 10.00g [root@localhost ~]# pvdisplay "/dev/sdb2" is a new physical volume of "10.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb2 VG Name PV Size 10.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID Yxsoub-DQJt-5g3T-uSca-839U-vmVV-A2t8Gl "/dev/sdb3" is a new physical volume of "10.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb3 VG Name PV Size 10.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID ChnbDg-DaSx-BhKz-a427-qEjc-VneO-A6V2jl [root@localhost ~]#
Description: After we partition may occur with lsblk phenomenon partition table is not synchronized, we can use partx -a / dev / sdb to inform the kernel synchronization, so that we can see our previous partition, then use the pvcreate command Creating pv, with the pvs or pvdisplay to see that we created a physical volume
3. Create VG (volume group), and set the size of 16m pe
root@localhost ~]# vgcreate "testvg" -s 16m /dev/sdb{2,3} Volume group "testvg" successfully created [root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree testvg 2 0 0 wz--n- 20.00g 20.00g [root@localhost ~]# vgdisplay --- Volume group --- VG Name testvg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 20.00 GiB PE Size 16.00 MiB Total PE 1280 Alloc PE / Size 0 / 0 Free PE / Size 1280 / 20.00 GiB VG UUID XgjjlR-jg4D-iOpA-W65s-S4WF-Qq8r-UaBjPW
Note: You can see that we have very successfully created a testvg, size 20G, pe size is 16m, pe is the smallest logical allocation unit, similar to the disk block size, and only created VG can see the size of pe , if not specified defaults to 4m
4, create a logical volume size 5G testlv
[root@localhost ~]# lvs [root@localhost ~]# lvdisplay [root@localhost ~]# lvcreate -n "testlv" -L 5G testvg Logical volume "testlv" created. [root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert testlv testvg -wi-a----- 5.00g [root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/testvg/testlv LV Name testlv VG Name testvg LV UUID RPUlTS-fVfA-etlO-Rzqz-KzMD-6xS1-dszf8F LV Write Access read/write LV Creation host, time localhost, 2019-10-22 03:55:08 +0800 LV Status available # open 0 LV Size 5.00 GiB Current LE 320 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 [root@localhost ~]#
Description: lvcreate -n indicates the name of the logical volume to be created, -L represents the size of the specified logical volume, of course, on the size of the logical -l specified manner, small pe l is the number of specified. Finally, specify the volume allocated in the group, to create a good lvs its true path in the / dev / dm-0, dm-0 because there is no real sense that we see the name do not know is that in the end the logical volume in the volume group created, so the system has given us to do a soft link, / dev / testvg / testlv, we saw the name of the logical volume is allocated from testvg inside.
5, create a file system on the created lvs
root@localhost ~]# mkfs.ext4 /dev/testvg/testlv 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 327680 inodes, 1310720 blocks 65536 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1342177280 40 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
6, mount the file system to create a good lvs
[root@localhost ~]# mount /dev/testvg/testlv /users/ [root@localhost ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 ext4 17G 1.9G 14G 12% / tmpfs tmpfs 932M 0 932M 0% /dev/shm /dev/sda1 ext4 190M 40M 141M 22% /boot /dev/sdb1 ext4 2.0G 9.1M 1.9G 1% /test /dev/mapper/testvg-testlv ext4 4.8G 10M 4.6G 1% /users [root@localhost ~]#
Note: To boot automatically mount the need to add the / dev / testvg / testlv / users ext4 defaults 0 0 this record in / etc / fstab file to automatically mount the boot can be achieved.