首页 » 科学 » linux分区满了若何进行扩容_分区_年夜众

linux分区满了若何进行扩容_分区_年夜众

神尊大人 2025-01-23 05:53:51 0

扫一扫用手机浏览

文章目录 [+]

1. 前辈入虚拟机设置里增大磁盘空间

把稳:将25改成50,以扩大空间。
这里一定要写比25大的数,由于他是“增加到”50GB,而不是“增加了25GB”

2. 下图可以看到,硬盘空间增大为53.7GB,在设备那里可以看到有两个分区,sda1跟sda2(请忽略sda3)。
接下来增加一个分区。

linux分区满了若何进行扩容_分区_年夜众 linux分区满了若何进行扩容_分区_年夜众 科学

键入命令:fdish /dev/sda

linux分区满了若何进行扩容_分区_年夜众 linux分区满了若何进行扩容_分区_年夜众 科学
(图片来自网络侵删)

键入:m(获取帮助)

键入:n (增加分区)

键入:p(增加主分区)

键入:回车(起始跟结束扇区)

末了:w(退出)

把稳:“起始扇区”那里直接回车,随便乱写随意马虎造成空间摧残浪费蹂躏

现在系统就有3个分:sda1,sda2,sda3

3. 创建物理卷

键入命令:pvcreate /dev/sda3

如果提示sda3找不到,键入:partprobe或者重启虚拟机。

4. 利用vgscan查询物理卷

4.1可以查到本机物理卷名称为“cl”,

4.2利用新增物理卷扩展cl:

键入命令:vgextendcl /dev/sda3

5. 扩展lv

键入命令:lvextend -L +24G 加上要扩展的分区名

接着用 dh –f,创造实际容量并没有变革,由于我们的系统还不认识刚刚添加进来的磁盘的文件系统,以是还须要对文件系统进行扩容。

键入:xfs_growfs 加上要扩展的分区名

或者

resize2fs – f 加 上要扩展的分区名

LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)

给某个硬盘增加分区之后

[root@Mysql01-213-66 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg_mysql0121366-LogVol02 7.7G 2.6G 4.8G 36% /

tmpfs 495M 0 495M 0% /dev/shm

/dev/sda1 194M 29M 155M 16% /boot

/dev/mapper/vg_mysql0121366-LogVol01 8.0G 3.1G 5.0G 38% /data

这里增加/data大小

[root@Mysql01-213-66 ~]# fdisk -l /dev/sda

Disk /dev/sda: 40.8 GB, 40802189312 bytes

255 heads, 63 sectors/track, 4960 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: 0x000eb81f

Device Boot Start End Blocks Id System

/dev/sda1 1 26 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 26 2350 18668544 8e Linux LVM

进行分区

[root@Mysql01-213-66 ~]# 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): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 3

First cylinder (2350-4960, default 2350):

Using default value 2350

Last cylinder, +cylinders or +size{K,M,G} (2350-4960, default 4960):

Using default value 4960

Command (m for help): p

Disk /dev/sda: 40.8 GB, 40802189312 bytes

255 heads, 63 sectors/track, 4960 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: 0x000eb81f

Device Boot Start End Blocks Id System

/dev/sda1 1 26 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 26 2350 18668544 8e Linux LVM

/dev/sda3 2350 4960 20966832 83 Linux

Command (m for help): t

Partition number (1-4): 3

Hex code (type L to list codes): 8e

Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): w

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 will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

重启做事器或者 partprobe

创建物理卷

[root@Mysql01-213-66 ~]# pvcreate /dev/sda3

Physical volume \"大众/dev/sda3\"大众 successfully created

利用vgscan查询物理卷

[root@Mysql01-213-66 ~]# vgscan

Reading all physical volumes. This may take a while...

Found volume group \公众vg_mysql0121366\"大众 using metadata type lvm2

利用新增物理卷扩展vg

[root@Mysql01-213-66 ~]# vgextend vg_mysql0121366 /dev/sda3

Volume group \公众vg_mysql0121366\"大众 successfully extended

[root@Mysql01-213-66 ~]# vgscan

Reading all physical volumes. This may take a while...

Found volume group \"大众vg_mysql0121366\"大众 using metadata type lvm2

查询vg

[root@Mysql01-213-66 ~]# vgdisplay

--- Volume group ---

VG Name vg_mysql0121366

System ID

Format lvm2

Metadata Areas 2

Metadata Sequence No 5

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 3

Open LV 3

Max PV 0

Cur PV 2

Act PV 2

VG Size 37.79 GiB

PE Size 4.00 MiB

Total PE 9675

Alloc PE / Size 4557 / 17.80 GiB

Free PE / Size 5118 / 19.99 GiB

VG UUID Zy2PVv-xSsx-NEAv-L6ba-G8Oy-tBBq-5zXKQm

查询lv

[root@Mysql01-213-66 ~]# lvdisplay

--- Logical volume ---

LV Path /dev/vg_mysql0121366/LogVol01

LV Name LogVol01

VG Name vg_mysql0121366

LV UUID 5znkJ2-wdeZ-Y2o1-ECDS-gzzl-PqaS-qo2yZR

LV Write Access read/write

LV Creation host, time Mysql01-213-66, 2015-08-30 20:42:13 +0800

LV Status available

# open 1

LV Size 8.00 GiB

Current LE 2048

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:2

--- Logical volume ---

LV Path /dev/vg_mysql0121366/LogVol00

LV Name LogVol00

VG Name vg_mysql0121366

LV UUID b1FV1n-iKyK-kZ23-glRO-opFh-gDRp-TzWNcL

LV Write Access read/write

LV Creation host, time Mysql01-213-66, 2015-08-30 20:42:14 +0800

LV Status available

# open 1

LV Size 2.00 GiB

Current LE 512

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

--- Logical volume ---

LV Path /dev/vg_mysql0121366/LogVol02

LV Name LogVol02

VG Name vg_mysql0121366

LV UUID eoVdk3-cbcP-9PlI-kZBL-6pY2-Jpbl-1WI2uH

LV Write Access read/write

LV Creation host, time Mysql01-213-66, 2015-08-30 20:42:14 +0800

LV Status available

# open 1

LV Size 7.80 GiB

Current LE 1997

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:1

[root@Mysql01-213-66 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg_mysql0121366-LogVol02 7.7G 2.6G 4.8G 35% /

tmpfs 495M 0 495M 0% /dev/shm

/dev/sda1 194M 29M 155M 16% /boot

/dev/mapper/vg_mysql0121366-LogVol01 8.0G 3.1G 5.0G 38% /data

扩展lv

[root@Mysql01-213-66 ~]# lvextend -L +19G /dev/mapper/vg_mysql0121366-LogVol01

Extending logical volume LogVol01 to 27.00 GiB

Logical volume LogVol01 successfully resized

[root@Mysql01-213-66 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg_mysql0121366-LogVol02 7.7G 2.6G 4.8G 35% /

tmpfs 495M 0 495M 0% /dev/shm

/dev/sda1 194M 29M 155M 16% /boot

/dev/mapper/vg_mysql0121366-LogVol01 8.0G 3.1G 5.0G 38% /data

若不是xfs我们可以用resize2fs,这里报错了

[root@Mysql01-213-66 ~]# resize2fs -f /dev/mapper/vg_mysql0121366-LogVol01

resize2fs 1.41.12 (17-May-2010)

resize2fs: Bad magic number in super-block while trying to open /dev/mapper/vg_mysql0121366-LogVol01

Couldn't find valid filesystem superblock.

[root@Mysql01-213-66 ~]# xfs_growfs /dev/mapper/vg_mysql0121366-LogVol01

meta-data=/dev/mapper/vg_mysql0121366-LogVol01 isize=256 agcount=4, agsize=524288 blks

= sectsz=512 attr=2, projid32bit=0

data = bsize=4096 blocks=2097152, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0

log =internal bsize=4096 blocks=2560, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 2097152 to 7077888

[root@Mysql01-213-66 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg_mysql0121366-LogVol02 7.7G 2.6G 4.8G 35% /

tmpfs 495M 0 495M 0% /dev/shm

/dev/sda1 194M 29M 155M 16% /boot

/dev/mapper/vg_mysql0121366-LogVol01 27G 3.1G 24G 12% /data

标签:

相关文章

TCOOP-M101-433M发射模块_暗记_波形

遥控器参数遥控器采取HS2245PT芯片,吸收模块采取LR43B无线射频吸收模块遥控器与吸收模块选用的是下图所示的两款:由于LR4...

科学 2025-01-24 阅读0 评论0

源代码遭泄露是谁在扰乱_北碚区_产物

“感谢审查机关对民营企业著作权的重视和保护,帮我们挽回丢失,现在我们加强了软件源代码保密事情……”1月26日,重庆市北碚区审查院审...

科学 2025-01-24 阅读0 评论0