Linux添加硬盘并扩容LVM磁盘空间—《江苏智简云网络安全小知识》

发布时间:2022-11-25 12:44

                                            Linux添加硬盘并扩容LVM磁盘空间—《江苏智简云网络安全小知识》

后台经常由小伙伴私信会问道Linux怎么添加硬盘并扩容LVM磁盘空间?今天呢我们江苏智简云的客服人员来给大家讲一下这方面的相关网络安全小知识!http://idc31.com/

 

Linux环境:

virtual box 下,redhat5 64位版本,原来系统默认分区.

新添加一个8G的硬盘sdb,将新加的硬盘容量扩充到原来的/上去.

1.分区,

[root@test ~]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1044     8281507+  8e  Linux LVM

 

Disk /dev/sdb: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

 

[root@test ~]# fdisk /dev/sdb

-----此处有一段英文省略

Command (m for help): n(输入n)

Command action

   e   extended

   p   primary partition (1-4)

p(输入p)

Partition number (1-4): 1 (输入1)

First cylinder (1-1044, default 1): (回车)

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): (回车)

Using default value 1044

Command (m for help): w(输入w)

w保存退出!

 

2.创建pv

[root@test ~]# pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created

 

查看pv

root@test ~]# pvdisplay

  /dev/hdc: open failed: No medium found

  --- Physical volume ---

  PV Name               /dev/sda2

  VG Name               VolGroup00

  PV Size               7.90 GB / not usable 23.41 MB

  Allocatable           yes (but full)

  PE Size (KByte)       32768

  Total PE              252

  Free PE               0

  Allocated PE          252

  PV UUID               ntpCtU-7gX3-988d-ifQv-SCyb-oFcx-S0jFrM

   

  "/dev/sdb1" is a new physical volume of "8.00 GB"

  --- NEW Physical volume ---

  PV Name               /dev/sdb1

  VG Name               

  PV Size               8.00 GB

  Allocatable           NO

  PE Size (KByte)       0

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               2XiyBc-5hJD-LJDQ-Fslo-t3CD-go4j-Zt8nxO

 

3.查看vg

vgdisplay

  /dev/hdc: open failed: No medium found

  --- Volume group ---

  VG Name               VolGroup00

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               2

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               7.88 GB

  PE Size               32.00 MB

  Total PE              252

  Alloc PE / Size       252 / 7.88 GB

  Free  PE / Size       0 / 0   

  VG UUID               Mjkp7h-lSOy-qR7r-RQ1b-FRrH-rNjQ-BOJYDY

 

4.扩容vg

[root@test ~]# vgextend VolGroup00 /dev/sdb1

  /dev/hdc: open failed: No medium found

  Volume group "VolGroup00" successfully extended

 

5.检查vg

[root@test ~]# vgdisplay

  /dev/hdc: open failed: No medium found

  --- Volume group ---

  VG Name               VolGroup00

  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               15.84 GB

  PE Size               32.00 MB

  Total PE              507

  Alloc PE / Size       252 / 7.88 GB

  Free  PE / Size       255 / 7.97 GB

  VG UUID               Mjkp7h-lSOy-qR7r-RQ1b-FRrH-rNjQ-BOJYDY

 

6.查看lv

[root@test ~]# lvdisplay

  /dev/hdc: open failed: No medium found

  --- Logical volume ---

  LV Name                /dev/VolGroup00/LogVol00

  VG Name                VolGroup00

  LV UUID                KBRr5T-kBNg-UfqY-5kEE-snsd-eKl3-1dtUT9

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                6.88 GB

  Current LE             220

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

   

  --- Logical volume ---

  LV Name                /dev/VolGroup00/LogVol01

  VG Name                VolGroup00

  LV UUID                YMu5P9-nuwE-GbD6-9T9P-knzk-H1rQ-ccyzYX

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                1.00 GB

  Current LE             32

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:1

 

7.扩容lv

[root@test ~]# lvextend /dev/VolGroup00/LogVol00 /dev/sdb1

  /dev/hdc: open failed: No medium found

  Extending logical volume LogVol00 to 14.84 GB

  Logical volume LogVol00 successfully resized

 

8.查看lv

[root@test ~]# lvdisplay

  /dev/hdc: open failed: No medium found

  --- Logical volume ---

  LV Name                /dev/VolGroup00/LogVol00

  VG Name                VolGroup00

  LV UUID                KBRr5T-kBNg-UfqY-5kEE-snsd-eKl3-1dtUT9

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                14.84 GB

  Current LE             475

  Segments               2

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

   

  --- Logical volume ---

  LV Name                /dev/VolGroup00/LogVol01

  VG Name                VolGroup00

  LV UUID                YMu5P9-nuwE-GbD6-9T9P-knzk-H1rQ-ccyzYX

  LV Write Access        read/write

  LV Status              available

  # open                 1

  LV Size                1.00 GB

  Current LE             32

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:1

 

9.扩容 /  磁盘空间

[root@test ~]# mount

/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda1 on /boot type ext3 (rw)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

[root@test ~]# res

reset           resize          reslisa         restorecon      restore.static  

resetall        resize2fs       restore         restorecond     

[root@test ~]# resize2fs /dev/mapper/VolGroup00-LogVol0

VolGroup00-LogVol00  VolGroup00-LogVol01  

[root@test ~]# resize2fs /dev/mapper/VolGroup00-LogVol00

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required

Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 3891200 (4k) blocks.

The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 3891200 blocks long.

 

[root@test ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       15G  6.2G  7.5G  46% /

/dev/sda1              99M   13M   82M  14% /boot

tmpfs                 250M     0  250M   0% /dev/shm

磁盘空间添加完成

 

公司主页:http://idc31.com/
公司全称:江苏智简云计算有限公司

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

### 江苏智简江苏智简云江苏智简云计算idc31.comwww.idc31.com徐州华为云徐州服务器租用徐州服务器托管徐州数据中心徐州云服务器徐州网站建设徐州APP搭建徐州小程序开发徐州APP开发徐州网络安全徐州网络维护徐州网站维护徐州网站搭建徐州网络搭建徐州网络攻击解决方案徐州租用服务器徐州托管服务器徐州电信机房徐州联通机房徐州移动机房徐州单线机房徐州双线机房徐州多线机房徐州BGP线路机房徐州系统安装徐州VPS徐州虚拟空间徐州域名注册徐州网站下载 ,徐州idc公司徐州网络公司徐州IDC公司排名徐州网络公司排名徐州互联网公司徐州互联网公司排名江苏华为云江苏服务器租用江苏服务器托管江苏数据中心江苏云服务器江苏网站建设江苏APP搭建江苏小程序开发江苏APP开发江苏网络安全江苏网络维护江苏网站维护江苏网站搭建江苏网络搭建江苏网络攻击解决方案江苏租用服务器江苏托管服务器江苏电信机房江苏联通机房江苏移动机房江苏单线机房江苏双线机房江苏多线机房江苏BGP线路机房江苏系统安装江苏VPS江苏虚拟空间江苏域名注册江苏网站下载 ,江苏idc公司江苏网络公司江苏IDC公司排名江苏网络公司排名江苏互联网公司江苏互联网公司排名企业服务器租用游戏服务器租用华为云服务器阿里云服务器腾讯云服务器百度云服务器 虚拟云主机网站备案云虚拟主机徐州电信高防IP免费永久服务器云服务器网站企业云服务器网站云服务器### 

客户热线:0516-85619661

客户服务中心