Introduction to Linux System Administrator (III)

Source: Internet
Author: User

Author Li Wanpeng
 
 
 
 
Team's department server has a total of 8 hard disks, each of which is 600 GB, but df-h. Check that there is only about GB. where is other seven harddisk? Use parted and lvm to solve this problem.
 
 
 
 
1. Use the parted tool:
 
 
 
 
[Root @ chinaltcdragon ~] # Parted
GNU parted2.1
Use/dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(Parted) p
Model: IBM ServeRAID M5015 (scsi)
Disk/dev/sda: 599 GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number Start End Size File system Name flag
1 1049kB 211 MB 210 MB fat16 boot
2 211 MB 735 MB 524 MB ext4
3 735 MB 599 GB 598 GB lvm
 
 
We can see that/dev/sda has already been divided into good partitions, so we can draw a picture based on the gourd and divide the other seven harddisk according to the partition specification.
 
First, fdisk-l finds their names:
 
/Dev/sdb1 1 72825 584959999 + ee GPT
Disk/dev/sda: 599.0 GB, 598999040000 bytes
/Dev/sda1 1 72825 584959999 + ee GPT
Disk/dev/sdd: 599.0 GB, 598999040000 bytes
/Dev/sdd1 1 72825 584959999 + ee GPT
Disk/dev/sdc: 599.0 GB, 598999040000 bytes
/Dev/sdc1 1 72825 584959999 + ee GPT
Disk/dev/sdh: 599.0 GB, 598999040000 bytes
/Dev/sdh1 1 72825 584959999 + ee GPT
Disk/dev/sdg: 599.0 GB, 598999040000 bytes
/Dev/sdg1 1 72825 584959999 + ee GPT
Disk/dev/sde: 599.0 GB, 598999040000 bytes
/Dev/sde1 1 72825 584959999 + ee GPT
Disk/dev/sdf: 599.0 GB, 598999040000 bytes
/Dev/sdf1 1 72825 584959999 + ee GPT
 
 
Partition/dev/sdd:
 
[Root @ chinaltcdragon ~] # Parted/dev/sdd
GNU parted2.1
Use/dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
 
View the harddisk information:
(Parted) p
Model: IBM ServeRAID M5015 (scsi)
Disk/dev/sdd: 599 GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number Start End Size File system Name flag
 
Run the mkpart command in parted to partition data. Enter help to view various commands of parted:
 
(Parted) mkpart
Partition name? []? 1
File System type? [Ext2]? Fat16
Start Point? 1049 k
End Point? 211 m
(Parted) mkpart
Partition name? []? 2
File System type? [Ext2]? Ext4
Start Point? 211 m
End Point? 735 m
(Parted) mkpart
Partition name? []? 3
File System type? [Ext2]? Ext4
Start Point? 735 m
End Point? 598 GB
 
Then set partition 1 as the boot partition:
 
(Parted) set 1 boot on
 
After the partition is completed, print the harddisk partition information again:
(Parted) p
Model: IBM ServeRAID M5015 (scsi)
Disk/dev/sdd: 599 GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number Start End Size File system Name flag
1 1049kB 211 MB 210 MB 1 Boot
2 211 MB 735 MB 524 MB 2
3 735 MB 598 GB 597 GB 3
If a partition is incorrectly distinguished during the partition process, you can use rm + Partition number to delete the partition. This input can be found through help.
 
 
 
 
Ii. Use LVM:
 
 
 
 
Here we will introduce several commands in lvm:
 
Vgscan, vgdisplay, lvscan, and pvscan.
 
The lvm operations are divided into several steps:
 
 
Create physical volume
Add physical volume to volume group
Add physical volume to logical volume
 
Create physical volume:
 
Lvm> pvcreate/dev/sdd3
Writing physical volume data to disk "/dev/sdd3"
Physical volume "/dev/sdd3" successfully created
 
View the name of the current volume group
 
Lvm> vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg_chinaltcdragon" using metadata type lvm2
 
 
Add physical volume to volume group
 
Lvm> vgextend vg_chinaltcdragon/dev/sdd3
Volume group "vg_chinaltcdragon" successfully extended
 
Check the logical volume in this volume group.
Lvm> lvscan
ACTIVE '/dev/vg_chinaltcdragon/lv_root' [50.00 GiB] inherit
ACTIVE '/dev/vg_chinaltcdragon/lv_home' [1.55 TiB] inherit
ACTIVE '/dev/vg_chinaltcdragon/lv_swap' [37.42 GiB] inherit
 
Here, three logical volumes exist in the volume group vg_chinaltcdragon.
 
Add physical volume to logical volume
Lvm> lvextend/dev/vg_chinaltcdragon/lv_home/dev/sdd3
Extending logical volume lv_home to 2.09 TiB
Logical volume lv_home successfully resized
 
Check logical volume
Lvm> lvscan
ACTIVE '/dev/vg_chinaltcdragon/lv_root' [50.00 GiB] inherit
ACTIVE '/dev/vg_chinaltcdragon/lv_home' [2.09 TiB] inherit
ACTIVE '/dev/vg_chinaltcdragon/lv_swap' [37.42 GiB] inherit
 
 
You can see that the logical volume size of/dev/vg_chinaltcdragon/lv_home has increased.
 
However, df-h does not actually change:
 
[Root @ chinaltcdragon ~] # Df-h
File System capacity in use available % mount point
/Dev/mapper/vg_chinaltcdragon-lv_root
50G 3.9G 43G 9%/
Tmpfs 18G 188 K 18G 1%/dev/shm
/Dev/sda2 485 M 62 M 398 M 14%/boot
/Dev/sda1 200 M 256 K 200 M 1%/boot/efi
/Dev/mapper/vg_chinaltcdragon-lv_home
1.6 T 140G 1.4 T 10%/home
 
 
Here is 1.6T, because the team's foreigners have installed two harddisks with parted and lvm.
 
Last, use the resize2fs tool to adjust the volume of logical volume:
 
[Root @ chinaltcdragon ~] # Resize2fs/dev/vg_chinaltcdragon/lv_home
Resize2fs 1.41.12 (17-May-2010)
Filesystem at/dev/vg_chinaltcdragon/lv_home is mounted on/home; on-line resizing required
Old desc_blocks = 100, new_desc_blocks = 134
Ming an on-line resize of/dev/vg_chinaltcdragon/lv_home to 561076224 (4 k) blocks.
The filesystem on/dev/vg_chinaltcdragon/lv_home is now 561076224 blocks long.
 
 
Check again, it has been expanded to 2 TB, OK, Well done!
 
[Root @ chinaltcdragon ~] # Df-h
File System capacity in use available % mount point
/Dev/mapper/vg_chinaltcdragon-lv_root
50G 3.9G 43G 9%/
Tmpfs 18G 188 K 18G 1%/dev/shm
/Dev/sda2 485 M 62 M 398 M 14%/boot
/Dev/sda1 200 M 256 K 200 M 1%/boot/efi
/Dev/mapper/vg_chinaltcdragon-lv_home
2.1 T 142G 1.9 T 8%/home

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.