Linux extended root partition detailed steps

Source: Internet
Author: User

Linux virtual machine extension root partition!


Virtual machine root partition space is not enough, in the virtual machine management interface for a single disk expansion (graphical interface operation slightly), such as the original 30G, extended to 40G, (extension needs to be shutdown after operation)

Where the 10G space needs to be re-partitioned, the following partition-related operations allow the extended space to take effect:

After logging in to the system:

Df-h found that the space has not changed:

[Email protected] ~]# df-h

Filesystem Size used Avail use% mounted on

/dev/mapper/volgroup-lv_root

25G 19G 4.2G 82%/

Tmpfs 642M 0 642M 0%/dev/shm

/DEV/SDA1 485M 34M 426M 8%/boot


Fdisk-l found that the total capacity has been expanded.

[Email protected] ~]# fdisk-l

disk/dev/sda:42.9 GB, 42949672960 bytes

255 heads, Sectors/track, 5221 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x00069f1c

------------------------------

To partition an extended disk:

[Email protected] ~]# FDISK/DEV/SDA


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): P


disk/dev/sda:42.9 GB, 42949672960 bytes

255 heads, Sectors/track, 5221 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x00069f1c


Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 512000 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 4047 31992832 8e Linux LVM


Command (M for help): N

Command Action

E Extended

P primary partition (1-4)

3

Invalid partition number for type ' 3 '

Command Action

E Extended

P primary partition (1-4)

P

Partition number (1-4): 3

First cylinder (4047-5221, default 4047):

Using Default Value 4047

Last cylinder, +cylinders or +size{k,m,g} (4047-5221, default 5221):

Using Default Value 5221


Command (M for help): P-------View after partitioning

disk/dev/sda:42.9 GB, 42949672960 bytes

255 heads, Sectors/track, 5221 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x00069f1c


Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 512000 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 4047 31992832 8e Linux LVM

/dev/sda3 4047 5221 9431826+-up Linux

---The new Sda3

Command (M for help): W Save partition

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 is being used at

The next reboot or after you run Partprobe (8) or KPARTX (8)

Syncing disks.

[Email protected] ~]#



--------------------Use the command to discover that the PARTPROBE/DEV/SDA3 discovery partition does not work:

[Email protected] ~]# Partprobe/dev/sda3

Error:could not stat device/dev/sda3-no such file or directory.

[Email protected] ~]# Pvcreate/dev/sda3

Device/dev/sda3 not found (or ignored by filtering).

-----Reboot the system.




------LVM operation. Extending the root partition

[Email protected] ~]# Pvcreate/dev/sda3

Physical volume "/dev/sda3" successfully created

[Email protected] ~]# VGS

VG #PV #LV #SN Attr vsize vfree

VolGroup 1 2 0 wz--n-30.51g 0


[Email protected] ~]# vgextend Volgroup/dev/sda3

Volume Group "VolGroup" successfully extended

[Email protected] ~]# VGS

VG #PV #LV #SN Attr vsize vfree

VolGroup 2 2 0 wz--n-39.50g 8.99g


[Email protected] ~]# lvextend-l +8.99g/dev/mapper/volgroup-lv_root

Rounding size to boundary between physical extents:8.99 GiB

Extending logical Volume Lv_root to 33.50 GiB

Logical Volume Lv_root successfully resized


[Email protected] ~]# Resize2fs/dev/mapper/volgroup-lv_root

RESIZE2FS 1.41.12 (17-may-2010)

Filesystem at/dev/mapper/volgroup-lv_root is mounted on/; On-line resizing required

Old desc_blocks = 2, new_desc_blocks = 3

Performing an on-line resize of/dev/mapper/volgroup-lv_root to 8781824 (4k) blocks.

The filesystem on/dev/mapper/volgroup-lv_root is now 8781824 blocks long.


----command to operate the root partition, the discovery has taken effect:

[Email protected] ~]# df-h

Filesystem Size used Avail use% mounted on

/dev/mapper/volgroup-lv_root

33G 19G 13G 60%/

Tmpfs 642M 0 642M 0%/dev/shm

/DEV/SDA1 485M 34M 426M 8%/boot

[Email protected] ~]#


Complete the extension.


This article is from the "Laotaibuxiao" blog, make sure to keep this source http://lubcdc.blog.51cto.com/3785870/1763133

Linux extended root partition detailed steps

Related Article

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.