博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS添加新硬盘到新的分区(xfs/ext4) 或者添加新分区
阅读量:6269 次
发布时间:2019-06-22

本文共 8090 字,大约阅读时间需要 26 分钟。

 CentOs添加新硬盘到新的分区(xfs/ext4)  添加新分区

转载请注明:

这篇文章介绍怎么添加一块新的硬盘,然后将其添加到一个新的分区或者一个已有的分区,比如增加根分区的大小

比如在virtualbox中添加的硬盘也可以用这样的

 添加新分区

fdisk -l可以看到新的硬盘 /dev/sdbfdisk /dev/sdb输入m查看提示输入n添加分区输入1新建一个分区然后默认回车2次创建成功(有人说第二次按w保存,但是我直接回车好像也没问题额)格式化分区 mkfs -t xfs  /dev/sdb新建一个自己想要挂载的目录 mkdir /opt/data/data1然后 mount -t xfs /dev/sdb /opt/data/data1df -lhT可以看到信息,ok了

 

添加新硬盘到新的分区(xfs/ext4)

fdisk -l可以看到新的硬盘 /dev/sdbfdisk /dev/sdb输入m查看提示输入n添加分区输入p选择primary输入1新建一个分区然后默认回车2次创建成功(有人说第二次按w保存,但是我直接回车好像也没问题额)格式化分区 mkfs -t xfs  /dev/sdb查看pv(物理卷)[root@wb201 /]# pvdisplay  --- Physical volume ---  PV Name               /dev/sda2  VG Name               centos  PV Size               7.51 GiB / not usable 3.00 MiB  Allocatable           yes   PE Size               4.00 MiB  Total PE              1922  Free PE               10  Allocated PE          1912  PV UUID               8AV96r-QBvP-Hy6Q-uP1l-YI4b-UYom-GgIUNV   创建pv[root@wb201 /]# pvcreate /dev/sdb WARNING: xfs signature detected on /dev/sdb at offset 0. Wipe it? [y/n]: y  Wiping xfs signature on /dev/sdb.  Physical volume "/dev/sdb" successfully created[root@wb201 /]# pvdisplay  --- Physical volume ---  PV Name               /dev/sda2  VG Name               centos  PV Size               7.51 GiB / not usable 3.00 MiB  Allocatable           yes   PE Size               4.00 MiB  Total PE              1922  Free PE               10  Allocated PE          1912  PV UUID               8AV96r-QBvP-Hy6Q-uP1l-YI4b-UYom-GgIUNV     "/dev/sdb" is a new physical volume of "20.78 GiB"  --- NEW Physical volume ---  PV Name               /dev/sdb  VG Name                 PV Size               20.78 GiB  Allocatable           NO  PE Size               0     Total PE              0  Free PE               0  Allocated PE          0  PV UUID               OjyuLL-5f4X-BoVB-hZBS-AJpZ-IeMV-JO6UHF   查看vg(卷组)[root@wb201 /]# vgdisplay  --- Volume group ---  VG Name               centos  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.51 GiB  PE Size               4.00 MiB  Total PE              1922  Alloc PE / Size       1912 / 7.47 GiB  Free  PE / Size       10 / 40.00 MiB  VG UUID               iLRzhR-myQz-XQwG-XBnd-yH2V-2vhu-VWTtgm   增加卷组 [root@wb201 /]# vgextend centos /dev/sdb  Volume group "centos" successfully extended查看lv(卷组)[root@wb201 /]# lvdisplay  --- Logical volume ---  LV Path                /dev/centos/swap  LV Name                swap  VG Name                centos  LV UUID                dBjVT5-KvtT-t4zS-hWkh-cDvn-rXch-hc7SaA  LV Write Access        read/write  LV Creation host, time localhost, 2016-02-22 22:43:17 +0800  LV Status              available  # open                 2  LV Size                820.00 MiB  Current LE             205  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:1     --- Logical volume ---  LV Path                /dev/centos/root  LV Name                root  VG Name                centos  LV UUID                6IJGJT-QEyI-bsQ2-O180-hRcI-T5U8-QBUcMA  LV Write Access        read/write  LV Creation host, time localhost, 2016-02-22 22:43:17 +0800  LV Status              available  # open                 1  LV Size                6.67 GiB  Current LE             1707  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:0   看看现在卷组的情况[root@wb201 /]# vgdisplay  --- Volume group ---  VG Name               centos  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               28.28 GiB  PE Size               4.00 MiB  Total PE              7240  Alloc PE / Size       1912 / 7.47 GiB  Free  PE / Size       5328 / 20.81 GiB  VG UUID               iLRzhR-myQz-XQwG-XBnd-yH2V-2vhu-VWTtgm   看看现在逻辑卷的情况[root@wb201 /]# lvdisplay  --- Logical volume ---  LV Path                /dev/centos/swap  LV Name                swap  VG Name                centos  LV UUID                dBjVT5-KvtT-t4zS-hWkh-cDvn-rXch-hc7SaA  LV Write Access        read/write  LV Creation host, time localhost, 2016-02-22 22:43:17 +0800  LV Status              available  # open                 2  LV Size                820.00 MiB  Current LE             205  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:1     --- Logical volume ---  LV Path                /dev/centos/root  LV Name                root  VG Name                centos  LV UUID                6IJGJT-QEyI-bsQ2-O180-hRcI-T5U8-QBUcMA  LV Write Access        read/write  LV Creation host, time localhost, 2016-02-22 22:43:17 +0800  LV Status              available  # open                 1  LV Size                6.67 GiB  Current LE             1707  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:0   增加物理卷到根目录,可以看到根目录是在/dev/centos/root [root@wb201 /]# lvextend -L +20.81G /dev/centos/root  Rounding size to boundary between physical extents: 20.81 GiB  Size of logical volume centos/root changed from 6.67 GiB (1707 extents) to 27.48 GiB (7035 extents).  Logical volume root successfully resized.现在还没有增加,因为还没有更新[root@wb201 /]# df -hFilesystem               Size  Used Avail Use% Mounted on/dev/mapper/centos-root  6.7G  5.5G  1.3G  82% /devtmpfs                 1.9G     0  1.9G   0% /devtmpfs                    1.9G     0  1.9G   0% /dev/shmtmpfs                    1.9G  8.4M  1.9G   1% /runtmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup/dev/sda1                497M  205M  292M  42% /boottmpfs                    380M     0  380M   0% /run/user/0如果不xfs用resize2fs更新,但是xfs需要用xfs_growfs[root@wb201 /]# resize2fs /dev/centos/rootresize2fs 1.42.9 (28-Dec-2013)resize2fs: Bad magic number in super-block while trying to open /dev/centos/rootCouldn't find valid filesystem superblock.[root@wb201 /]# df -hFilesystem               Size  Used Avail Use% Mounted on/dev/mapper/centos-root  6.7G  5.5G  1.3G  82% /devtmpfs                 1.9G     0  1.9G   0% /devtmpfs                    1.9G     0  1.9G   0% /dev/shmtmpfs                    1.9G  8.4M  1.9G   1% /runtmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup/dev/sda1                497M  205M  292M  42% /boottmpfs                    380M     0  380M   0% /run/user/0[root@wb201 /]# xfs_growfs /dev/centos/rootmeta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=436992 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=0        finobt=0data     =                       bsize=4096   blocks=1747968, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=0log      =internal               bsize=4096   blocks=2560, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 1747968 to 7203840现在看就ok啦,哈哈[root@wb201 /]# df -hFilesystem               Size  Used Avail Use% Mounted on/dev/mapper/centos-root   28G  5.5G   23G  20% /devtmpfs                 1.9G     0  1.9G   0% /devtmpfs                    1.9G     0  1.9G   0% /dev/shmtmpfs                    1.9G  8.4M  1.9G   1% /runtmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup/dev/sda1                497M  205M  292M  42% /boottmpfs                    380M     0  380M   0% /run/user/0

 

ok了,完美~

你可能感兴趣的文章
oracle数据库从入门到精通之四
查看>>
自定义圆形图片控件
查看>>
sharepoint 2013 补丁升级步骤
查看>>
asp.net core 2.0 web api基于JWT自定义策略授权
查看>>
Skype for Business Server 2015-04-前端服务器-3-安装-管理工具
查看>>
第12章代码《跟老男孩学习Linux运维:Shell编程实战》
查看>>
我们为什么从Python转到go?
查看>>
5.Azure负载均衡(上)
查看>>
轻松精通awk数组企业问题案例
查看>>
26.Azure备份服务器(下)
查看>>
从“网上说的能信么”说开去---学习的思考
查看>>
DHCP 日志分析
查看>>
.NET Micro Framework动态调用C/C++底层代码(原理篇)
查看>>
Windows Server 2012正式版RDS系列⒃
查看>>
Shell脚本之awk篇
查看>>
微软发布Azure Stack硬件需求
查看>>
python socket编程详细介绍
查看>>
Windows Server 2016第三个技术预览版新技术
查看>>
Everything 本地磁盘文件搜索工具下载!
查看>>
Python dict(字典) 详细总结
查看>>