RHEL7 cannot use all partitions when using fdisk partitions

Source: Internet
Author: User
In Linux, the original four primary partitions on RedHat7 are sda1, sda2, sda3, and sda4, where sda1 is the primary partition, 200 M, and the remaining three primary partitions are 40 GB in total, the last three primary partitions are lvm. Currently, the disk space is insufficient. linux can only divide four primary partitions. Currently, all four primary partitions are occupied. If you delete them directly, data will be lost, we recommend that you use pvmove to minimize the space of/dev/sda3 in order to expand the space of the/dev/rhel/root partition.

In Linux, the original four primary partitions on RedHat7 are sda1, sda2, sda3, and sda4, where sda1 is the primary partition, 200 M, and the remaining three primary partitions are 40 GB in total, the last three primary partitions are lvm. Currently, the disk space is insufficient. linux can only divide four primary partitions. Currently, all four primary partitions are occupied. If you delete them directly, data will be lost, we recommend that you use the pvmove command to minimize the space of the/dev/rhel/root partition in the lvm during the preliminary partitioning, move all data in/dev/sda3 to/dev/sda2, and then remove/dev/sda3.

Pvmove/dev/sda3/dev/sda2
Pvremove/dev/sda3


Device Boot Start End Blocks Id System
/Dev/sda1*2048 411647 204800 83 Linux
/Dev/sda2 411648 63916031 31752192 8e Linux LVM
/Dev/sda4 64530432 68724735 2097152 8e Linux LVM


After the movement is completed, the system has 100 MB of space. In vmware, the hard disk space is extended to 107.4 GB, partprobe/dev/sda is used, and fdisk-l is used to view the hard disk space, which is displayed as GB.

Disk/dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dos
Disk identifier: 0x000c5098

Then, use fdisk/dev/sda to add the extended partition, use n, select the extended partition, and press enter for the initial block. When the block is ended, the end sector 209715200 cannot be entered, you can only enter the MB space provided by the system by default. The problem persists after restart and the 60 GB space added after the restart cannot be identified. It is suspected that the partition is in the middle and cannot be consecutively partitioned with the subsequent rows.

Partition using parted Tool

[Root @ server ~] # Parted
GNU parted3.1
Using/dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(Parted) help
Align-check type n check partition N for TYPE (min | opt) alignment
Help [COMMAND] print general help, or help on COMMAND
Mklabel, mktable LABEL-TYPE create a new disklabel (partition table)
Mkpart PART-TYPE [FS-TYPE] start end make a partition
Name number name partition NUMBER as name
Print [devices | free | list, all | NUMBER] display the partition table, available devices, free space, all found partitions, or
Particle partition
Quit exit program
Rescue start end rescue a lost partition near START and END
Rm NUMBER delete partition NUMBER
Select DEVICE choose the device to edit
Disk_set flag state change the FLAG on selected device
Disk_toggle [FLAG] toggle the state of FLAG on selected device
Set number flag state change the FLAG on partition NUMBER
Toggle [NUMBER [FLAG] toggle the state of FLAG on partition NUMBER
Unit UNIT set the default unit to UNIT
Version display the version number and copyright information of GNU Parted
(Parted)

Run the print list command to check that the ending partition is 35.6 GB. Run the mkpart extended command, enter 36 GB of the starting partition, 107 GB of the ending partition, and use partprobe/dev/sda to update the partition table.

Run cat/proc/partitions to check whether the extended partition/dev/sda3 is added.

Use fdisk/dev/sda to partition and add 30 GB space in/dev/sda5

Device Boot Start End Blocks Id System
/Dev/sda1*2048 411647 204800 83 Linux
/Dev/sda2 411648 63916031 31752192 8e Linux LVM
/Dev/sda3 70311936 209715199 69701632 f W95 Ext 'd (LBA)
/Dev/sda4 64530432 68724735 2097152 8e Linux LVM
/Dev/sda5 70313984 133228543 31457280 83 Linux

Next, use pvcreate/dev/sda5 to add a pv.

Use vgextend rhel/dev/sda5 to expand vg

Vgextend rhel/dev/sda5

Use lvextend to expand the root partition size and divide space from/dev/sda5

Lvextend-L + 10G/dev/rhel/root/dev/sda5

Use the xfs_info file provided by the system to view the slice information. You can see that each slice is 4 kb and 10 Gb is converted into a 2621440 slice. In addition, the original xfs_info file is 5181440.


Xfs_growfs-D 5242880/dev/mapper/rhel-root

Run df-h to view the mounting information.

[Root @ server ~] # Df-h
Filesystem Size Used Avail Use % Mounted on
/Dev/mapper/rhel-root 20G 631 M 20G 4%/
Devtmpfs 912 M 0 912 M 0%/dev
Tmpfs 921 M 164 K 921 M 1%/dev/shm
Tmpfs 921 M 9.0 M 912 M 1%/run
Tmpfs 921 M 0 921 M 0%/sys/fs/cgroup
/Dev/mapper/rhel-usr 5.0G 4.2G 834 M 84%/usr
/Dev/mapper/rhel-home 4.9G 115 M 4.8G 3%/home
/Dev/mapper/rhel-var 9.8G 515 M 9.3G 6%/var
/Dev/sda1 197 M 89 M 109 M 45%/boot


The root directory has been extended to 20 GB. If the root directory is added later, you can add a partition from the extended partition, and then add it back using this operation method.

For more information about RedHat, see RedHat topic page http://www.linuxidc.com/topicnews.aspx? Tid = 10

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2016-01/126958.htm

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.