首页 > Unix > linux扩根分区

linux扩根分区

1 根本55GB

[root@quickstart ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_quickstart-lv_root
55G 18G 34G 35% /
tmpfs 16G 76K 16G 1% /dev/shm
/dev/sda1 477M 42M 411M 10% /boot
cm_processes 16G 3.5M 16G 1% /var/run/cloudera-scm-agent/process


2 加一块硬盘设备200,分区为/dev/sdb1

[root@quickstart sdc1]# 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): p

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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: 0x235460ea

Device Boot Start End Blocks Id System
/dev/sdb1 1 26108 209712478+ 83 Linux

Command (m for help): d
Selected partition 1

Command (m for help): 1
1: unknown command
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: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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: 0x235460ea

Device Boot Start End Blocks Id System

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3 设备添加到vg

[root@quickstart sdc1]# pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created
[root@quickstart sdc1]# vgextend /dev/VolGroup00 /dev/sdb1
Volume group “VolGroup00” not found
Cannot process volume group VolGroup00

[root@quickstart sdc1]# vgextend /dev/vg_quickstart /dev/sdb1
Volume group “vg_quickstart” successfully extended
[root@quickstart sdc1]# vgdisplay
— Volume group —
VG Name vg_quickstart
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 263.50 GiB
PE Size 4.00 MiB
Total PE 67457
Alloc PE / Size 16258 / 63.51 GiB
Free PE / Size 51199 / 200.00 GiB
VG UUID Gyqv7E-lctP-38oq-ZmY2-bhn0-ROJI-Ehe4mz

4 扩根所在lv

[root@quickstart sdc1]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_quickstart-lv_root
55G 18G 35G 35% /
tmpfs 16G 76K 16G 1% /dev/shm
/dev/sda1 477M 42M 411M 10% /boot
cm_processes 16G 4.0M 16G 1% /var/run/cloudera-scm-agent/process
/dev/sdc1 197G 23G 165G 12% /sdc1

[root@quickstart sdc1]# lvextend -L +199G /dev/mapper/vg_quickstart-lv_root
Size of logical volume vg_quickstart/lv_root changed from 55.51 GiB (14210 extents) to 254.51 GiB (65154 extents).
Logical volume lv_root successfully resized
[root@quickstart sdc1]# vgdispaly
-bash: vgdispaly: command not found
[root@quickstart sdc1]# vgdisplay
— Volume group —
VG Name vg_quickstart
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 263.50 GiB
PE Size 4.00 MiB
Total PE 67457
Alloc PE / Size 67202 / 262.51 GiB
Free PE / Size 255 / 1020.00 MiB
VG UUID Gyqv7E-lctP-38oq-ZmY2-bhn0-ROJI-Ehe4mz

5 扩根文件系统

[root@quickstart sdc1]# /sbin/resize2fs /dev/mapper/vg_quickstart-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_quickstart-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 16
Performing an on-line resize of /dev/mapper/vg_quickstart-lv_root to 66717696 (4k) blocks.
The filesystem on /dev/mapper/vg_quickstart-lv_root is now 66717696 blocks long.

[root@quickstart sdc1]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_quickstart-lv_root
251G 18G 220G 8% /
tmpfs 16G 76K 16G 1% /dev/shm
/dev/sda1 477M 42M 411M 10% /boot
cm_processes 16G 4.0M 16G 1% /var/run/cloudera-scm-agent/process
/dev/sdc1 197G 23G 165G 12% /sdc1

6 xfs
从linux7开始默认使用xfs文件系统,需使用xfs_growfs命令
eg:

xfs_growfs /dev/vgpg/lv_pgdata

分类: Unix 标签: , ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.