In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The concept of GPT,LVM and the basics of shell scripts describe what GPT is and how it should be used
The full name of 1.GPT is Globally Unique Identifier Partition Table, which means GUID partition table, and GUID partition table (GPT) was introduced as part of the Extensible Firmware Interface (EFI) plan. Compared with the master boot record (MBR) partitioning scheme commonly used in PC, GPT provides a more flexible disk partitioning mechanism. Partitions refer to the storage space on physical or logical disks that are connected to each other, but provide functionality like physically separated disks. Partitions are visible to system firmware and installed operating systems. Before the operating system starts, the access to the partition is controlled by the system firmware, and after the operating system starts, it is controlled by the operating system.
two。 It has the following advantages:
(1) support large hard drives above 2TB
(2) there is almost no limit on the number of partitions per disk (a maximum of 128partitions are allowed in Windows systems)
(3) there is almost no limit to the partition size. Another "almost". Because it uses 64-bit integers to represent the sector number, that is, = 18446744073709551616
(4) the partition table comes with backup. A copy of the same partition table is saved at the beginning and end of the disk, and after one copy is destroyed, it can be restored by the other.
(5) the cyclic redundancy test value is calculated for the key data structure, which improves the probability of data crash detection.
(6) although MBR provides a 1-byte partition type code, GPT uses a 16-byte globally unique identifier (GUID) value to identify the partition type, which makes the partition type less prone to conflict.
(7) each partition can have a name (different from the volume label).
3. To use GPT partition table must be UEFI BIOS environment, UEFI and GPT complement each other, both are indispensable, the current server motherboard basically adopts UEFI+BIOS coexistence mode, and BIOS integrates UEFI startup items, if our system disk size exceeds 2T, we need to use UEFI mode for system installation and system boot, when partitioning non-system disks greater than 2T, we need to choose GPT partition format. Create a 10G partition and format it as an ext4 file system:
Requirements: (1) block size is 2048, reserved space is 20%, and volume label is MYDATA.
(2) Mount to the / mydata directory, which requires that the program is not allowed to run automatically when mounted, and the access timestamp of the file is not updated.
(3) it can be booted and mounted automatically.
(1) fdisk creates 10G partition [root@localhost ~] # fdisk / dev/sdaWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Command (m for help): nAll primary partitions are in useAdding logical partition 6First sector (141940736-419430399, default 141940736): Using default value 141940736Last sector, + sectors or + size {KLING} (141940736-419430399) Default 419430399): + 10GPartition 6 of type Linux and of size 10 GiB is setCommand (m for help): wThe 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 atthe next reboot or after you run partprobe (8) or kpartx (8) Syncing disks.
(2) mkfs creates a file system:
[root@localhost] # mkfs.ext4-b 2048-m 20-L MYDATA / dev/sda6/mke2fs 1.42.9 (28-Dec-2013) Could not stat / dev/sda6/-Not a directory [root@localhost ~] # mkfs.ext4-b 2048-m 20-L MYDATA / dev/sda6mke2fs 1.42.9 (28-Dec-2013) Filesystem label=MYDATAOS type: LinuxBlock size=2048 (log=1) Fragment size=2048 (log=1) Stride=0 blocks, Stripe width=0 blocks655360 inodes 5242880 blocks1048576 blocks (20.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=273678336320 block groups16384 blocks per group, 16384 fragments per group2048 inodes per groupSuperblock backups stored on blocks: 16384,49152,81920,114688,147456,409600,442368,802816,1327104,2048000, 3981312Allocating group tables: doneWriting inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done
(3) Mount to the / mydata directory, which requires that the program is not allowed to run automatically when mounted, and the access timestamp of the file is not updated. And set up boot automatic mount.
[root@localhost ~] # mkdir-p / mydata [root@localhost ~] # vim / etc/fstab/dev/sda6 / mydata ext4 defaults,noatime Noexec 0 [root@localhost ~] # mount-a [root@localhost ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/sda2 47G 5.2G 42G 12% / devtmpfs 523M 0523M 0% / devtmpfs 538M 0538M 0% / dev/shmtmpfs 538M 7.8M 530M 2% / runtmpfs 538M 0538M 0% / sys/fs/cgroup/dev / sda1 497M 151M 346M 31% / boot/dev/sda3 19G 39M 19G 1% / datatmpfs 108M 4.0K 108m 1% / run/user/42tmpfs 108M 32K 108m 1% / run/user/1000/dev/sr0 8.1g 8.1g 0100% / run/media/wl/CentOS 7 x86_64tmpfs 108M 0108M 0% / run/user/ 0/dev/sda6 9.8G 13m 7.8G 1% / mydata create a swap partition with a size of 1G And enable: [root@localhost ~] # fdisk / dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Command (m for help): nAll primary partitions are in useAdding logical partition 7First sector (162914304-419430399, default 162914304): Using default value 162914304Last sector, + sectors or + size {K Magne M ·G} (162914304-419430399, default 419430399): + 1GPartition 7 of type Linux and of size 1 GiB is setCommand (m for help): tPartition number (1-7) Default 7): 7Hex code (type L to list all codes): 82Changed type of partition 'Linux' to' Linux swap / Solaris'Command (m for help): wThe 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 atthe next reboot or after you run partprobe (8) or kpartx (8) Syncing disks. [root@localhost ~] # mkswap / dev/sda7 Setting up swapspace version 1, size = 1048572 KiBno label UUID=ba42d9ae-41a0-4829-bd14-a32834cf6ec9 [root@localhost ~] # swapon / dev/sda7 [root@localhost ~] # vim / etc/fstab / dev/sda7 swap swap defaults 0 write a script to calculate the sum of the 10th user and the 20th user id in the etc/passwd file #! / bin/bash# to determine whether there are 20 user id_sum=$ in the system (cat / etc/passwd | wc-l) [${id_sum}-lt 20] & & echo "number of users less than 20" & & exit 2id1users $(head-10 / etc/passwd | tail-1 | cut-d:-f3) id2=$ (head-20 / etc/passwd | tail-1 | cut-d:-f3) idsum=$ [${id1} + ${id2}] echo "Ths sum is $idsum" [root@localhost scripts] # bash-x idsum2.sh + + cat / etc / passwd++ wc-1 + id_sum=58+'['58-lt 20']'+ + head-10 / etc/passwd++ tail-1 hosts + cut-d:-f3 + id1=11++ head-20 / etc/passwd++ tail-1 records + cut-d:-f3 + id2=997+ idsum=1008+ echo 'Ths sum is 1008'Ths sum is 1008 saves the current hostname to the hostName variable If the hostname is empty, or
Localhost.localdomain will be set to www.magedu.composer binbinBash hostName name $(hostname) [- z "${hostName}"-o "${hostName}" = "localhost.localdomain"-o "${hostName}" = "locahost"] & & hostnamectl set-hostname www.magedu.com | | echo "hostname: ${hostName} Do not modify "[root@localhost scripts] # bash-x hostname.sh + + hostname+ hostName=localhost.localdomain+'['- z localhost.localdomain-o localhost.localdomain = = localhost.localdomain-o localhost.localdomain = = locahost']'+ hostnamectl set-hostname www.magedu.com to write scripts Pass in a user name through the command line parameter to determine whether the id number is even or odd. / the bin/bash# script determines the parity type of the parameter user ID [$#-lt 1] & & echo "At least a username" & & exit 1! Id $1 & & echo "No such user" & exit 2useridcards $(id-u $1) useri=$ [${userid}% 2] if [${useri}-eq 0]; thenecho "$1 ID is even" elseecho "$1 ID is odd" firoot@localhost scripts] # bash-xv id.sh user3 username binapace base # script determines the parity type of user ID [$#-lt 1] & & echo "At least a username" & & exit 1 +'['1-lt 1']'! Id $1 & & echo "No such user" & & exit 2 + id user3uid=1003 (user3) gid=1003 (user3) groups=1003 (user3) userid=$ (id-u $1) + + id-u user3+ userid=1003useri=$ [${userid}% 2] + useri=1if [${useri}-eq 0]; then echo "$1 ID is even" else echo "$1 ID is odd" fi+'['1-eq 0']'+ echo 'user3 ID is odd' user3 ID is odd lvm basic applications and extension reduction implementation
(1) description of LVM principle
LVM is the abbreviation of (Logical Volume Manager) logical volume management. It is a mechanism for managing disk partitions in Linux environment. LVM is a logical layer based on hard disk and partition, which shields the underlying disk layout and facilitates dynamic adjustment of disk capacity to improve the flexibility of disk partition management. It can organize one or more underlying block devices into a volume group of logical devices. Administrators can create logical volume groups (logical volumes) on volume groups at will, and further create file systems on logical volume groups. Administrators can easily resize storage volume groups through LVM, and disk storage can be named, managed and allocated according to groups.
(2) basic terms of LVM:
(a) physical storage media (PhysicalStorageMedia): refers to the lowest level of physical storage devices on the system: disks, such as / dev/sda, / dev/sdb, etc. (B) physical volumes (Physical Volume, PV): refers to disks, disk partitions, or RAID devices Before using LVM, you need to make it into a physical volume PV (c) volume group (Volume Group, VG) that is easy to identify. The volume group consists of one or more physical volume PV, and one or more logical volume LV can be created on top of the volume group. The volume group VG is similar to the physical disk (d) logical volume (Logical Volume, LV) of a non-LVM system: it is based on the volume group VG, which is equivalent to a logical partition, and can perform a series of operations (for example, formatting, mounting, etc.) on the logical volume LV. Logical volume LV is similar to disk partition (d) physical extension block (Physical Extent, PE) of non-LVM system: when physical volume PV joins a volume group VG, it is divided into basic unit PE,PE is the smallest unit of LVM addressing. The size of the PE is configurable and defaults to 4m. (e) logical extension blocks (Logical Extent, LE): the volume group VG divides the PE into the logical volume LV, and the PE in the logical volume LV is called LE. In the same volume group VG, PE and LE are of the same size and correspond to each other. LE is also the smallest addressing unit for LVM.
(3) basic operation of LVM:
(a) pv management tools:
Pvs: brief pv Information display pvdisplay: display pv details pvcreate / dev/DEVICE: create pv
(B) vg management tools:
Vgsvgdisplayvgcreate [- s # [kKmMgGtTpPeE]] VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] vgextend VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] vgreduce VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] Do pvmovevgremove first.
(C) lv management tools:
Lvslvdisplaylvcreate-L # [mMgGtT]-n NAME VolumeGroupvremove / dev/VG_NAME/LV_NAME
(d) extend logical volumes:
# lvextend-L [+] # [mMgGtT] / dev/VG_NAME/LV_NAME# resize2fs / dev/VG_NAME/LV_NAME (e) reduce logical volumes: # umount / dev/VG_NAME/LV_NAME# e2fsck-f / dev/VG_NAME/LV_NAME# resize2fs / dev/VG_NAME/LV_NAME# [mMgGtT] # lvreduce-L [-] # [mMgGtT] / dev/VG_NAME/LV_NAME# mount
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.