linux磁盘扩容

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/ljx1528/article/details/88821045

1、添加新磁盘(略)
2、查看添加的磁盘

node5:~ # fdisk -l

Disk /dev/xvda: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0005f01f

Device     Boot   Start      End  Sectors  Size Id Type
/dev/xvda1         2048  2988031  2985984  1.4G 82 Linux swap / Solaris
/dev/xvda2 *    2988032 83886079 80898048 38.6G 83 Linux

Disk /dev/xvdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/VolGroup00-LogVol00: 500 GiB, 536866717696 bytes, 1048567808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/xvdc: 1000 GiB, 1073741824000 bytes, 2097152000 sectors  #此处添加了一块1000G的磁盘
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

3、增加分区

node5:~ # fdisk /dev/xvdc

Welcome to fdisk (util-linux 2.25).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xd53125b0.

Command (m for help): n     #创建新分区
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p            # p为主分区    e为扩展分区
Partition number (1-4, default 1): 3       #磁盘的编号,不重复即可
First sector (2048-2097151999, default 2048):         #默认即可,直接回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151999, default 2097151999):   #默认即可,直接回车

Created a new partition 3 of type 'Linux' and of size 1000 GiB.

Command (m for help): t           #输入t
Selected partition 3
Hex code (type L to list all codes): 8e          #输入8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w              #保存
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

4、初始化分区并加入卷组
4.1、卷扩容添加进LVM组

pvcreate /dev/xvdc3	初始化刚才的分区
node5:~ # pvcreate /dev/xvdc3
  Physical volume "/dev/xvdc3" successfully created

4.2、查看卷组并将初始化的分区加入到虚拟卷组
为卷组VolGroup00添加新的物理卷/dev/xvdc3增加卷组的容量

node5:~ # vgdisplay 
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               500.00 GiB
  PE Size               4.00 MiB
  Total PE              127999
  Alloc PE / Size       127999 / 500.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               VG2XU7-DhS6-4814-UuJJ-2di3-iF2T-HjUq0d

4.3、将初始化的分区加入到虚拟组

node5:~ # vgextend VolGroup00 /dev/xvdc3
  Volume group "VolGroup00" successfully extended

5、扩展逻辑卷的大小
5.1、现在才能扩展逻辑卷的大小

node5:~ # lvextend -L +995G /dev/mapper/VolGroup00-LogVol00
  Size of logical volume VolGroup00/LogVol00 changed from 500.00 GiB (127999 extents) to 1.46 TiB (382719 extents).
  Logical volume LogVol00 successfully resized

5.2、最后使用resizefs2命令重新加载逻辑卷的大小才能生效

node5:~ # resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.42.11 (09-Jul-2014)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /app; on-line resizing required
old_desc_blocks = 32, new_desc_blocks = 94
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 391904256 blocks long.

5.3、检查磁盘容量

node5:~ # df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/xvda2                        38G  3.9G   33G  11% /
devtmpfs                          16G     0   16G   0% /dev
tmpfs                             16G     0   16G   0% /dev/shm
tmpfs                             16G  922M   15G   6% /run
tmpfs                             16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/VolGroup00-LogVol00  1.5T  430G  977G  31% /app     #此为新增加的磁盘容量
展开阅读全文

Linux磁盘扩容和增加磁盘

11-29

各位道友好,本人VirtualBox虚拟机安装了CentOS6,之前按LiveCD自动安装,导致操作系统没使用全部硬盘空间,共有10G空间,但系统总空间只有5G,现在空间快用完了。rn问题1: 如何扩容使用全部空间?rn问题2: 新建了一块盘,如何格式化和挂载?rn谢谢!rn以下是硬盘信息:rn[code=text]rn[root@localhost spark]# fdisk -lrnrnDisk /dev/sda: 10.7 GB, 10737418240 bytesrn255 heads, 63 sectors/track, 1305 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x000ae1f9rnrn Device Boot Start End Blocks Id Systemrn/dev/sda1 * 1 64 512000 83 LinuxrnPartition 1 does not end on cylinder boundary.rn/dev/sda2 64 1306 9972736 8e Linux LVMrnrnDisk /dev/sdb: 10.7 GB, 10737418240 bytesrn255 heads, 63 sectors/track, 1305 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x00000000rnrnDisk /dev/sdb doesn't contain a valid partition tablernrnDisk /dev/mapper/vg_livedvd-lv_root: 5981 MB, 5981077504 bytesrn255 heads, 63 sectors/track, 727 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x00000000rnrnDisk /dev/mapper/vg_livedvd-lv_root doesn't contain a valid partition tablernrnDisk /dev/mapper/vg_livedvd-lv_swap: 4227 MB, 4227858432 bytesrn255 heads, 63 sectors/track, 514 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x00000000rnrnDisk /dev/mapper/vg_livedvd-lv_swap doesn't contain a valid partition tablernrnrn[root@localhost spark]# df -hrn文件系统 容量 已用 可用 已用%% 挂载点rn/dev/mapper/vg_livedvd-lv_rootrn 5.4G 5.4G 0 100% /rntmpfs 372M 308K 371M 1% /dev/shmrn/dev/sda1 477M 49M 403M 11% /bootrnShare 139G 128G 12G 92% /media/sf_Sharern[root@localhost spark]# rn[/code] 论坛

linux扩容,添加磁盘出现的问题

04-01

添加了一个硬盘 Disk /dev/sdb: 1097.4 GB 之前不知道怎么整的,在网上看了攻略就整坏了,分区呀,lv什么的都不懂,现在还搞不定!求救!rnrn[root@FJXM-DM-ResPool-VM84 ~]# fdisk -lrnrnDisk /dev/sda: 536.9 GB, 536870912000 bytesrn255 heads, 63 sectors/track, 65270 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x0002cf95rnrn Device Boot Start End Blocks Id Systemrn/dev/sda1 * 1 64 512000 83 LinuxrnPartition 1 does not end on cylinder boundary.rn/dev/sda2 64 65271 523774976 8e Linux LVMrnrnDisk /dev/sdb: 1097.4 GB, 1097364144128 bytesrn255 heads, 63 sectors/track, 133413 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x2b5965e2rnrn Device Boot Start End Blocks Id Systemrn/dev/sdb1 1 133413 1071639891 8e Linux LVMrnrnDisk /dev/mapper/vg_fjxmdmrespoolvm84-lv_root: 53.7 GB, 53687091200 bytesrn255 heads, 63 sectors/track, 6527 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x00000000rnrnDisk /dev/mapper/vg_fjxmdmrespoolvm84-lv_root doesn't contain a valid partition tablernrnDisk /dev/mapper/vg_fjxmdmrespoolvm84-lv_swap: 19.1 GB, 19075694592 bytesrn255 heads, 63 sectors/track, 2319 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x00000000rnrnDisk /dev/mapper/vg_fjxmdmrespoolvm84-lv_swap doesn't contain a valid partition tablernrnDisk /dev/mapper/vg_fjxmdmrespoolvm84-lv_home: 471.1 GB, 471095836672 bytesrn255 heads, 63 sectors/track, 57274 cylindersrnUnits = cylinders of 16065 * 512 = 8225280 bytesrnSector size (logical/physical): 512 bytes / 512 bytesrnI/O size (minimum/optimal): 512 bytes / 512 bytesrnDisk identifier: 0x00000000rnrnDisk /dev/mapper/vg_fjxmdmrespoolvm84-lv_home doesn't contain a valid partition tablernrnrnrn我想直接创建文件系统,挂在某个目录下,可是:rnrn[root@FJXM-DM-ResPool-VM84 ~]# mkfs.ext3 /dev/sdb1rnmke2fs 1.41.12 (17-May-2010)rn/dev/sdb1 is apparently in use by the system; will not make a 文件系统 here!rn[root@FJXM-DM-ResPool-VM84 ~]# vgdisplayrn --- Volume group ---rn VG Name vg_fjxmdmrespoolvm84rn System ID rn Format lvm2rn Metadata Areas 2rn Metadata Sequence No 6rn VG Access read/writern VG Status resizablern MAX LV 0rn Cur LV 3rn Open LV 3rn Max PV 0rn Cur PV 2rn Act PV 2rn VG Size 507.16 GiBrn PE Size 4.00 MiBrn Total PE 129834rn Alloc PE / Size 129666 / 506.51 GiBrn Free PE / Size 168 / 672.00 MiBrn VG UUID 6kXeqX-crf3-Nfhy-0xxv-nDnE-eARk-oP0pdCrn[root@FJXM-DM-ResPool-VM84 ~]# pvdisplayrn --- Physical volume ---rn PV Name /dev/sda2rn VG Name vg_fjxmdmrespoolvm84rn PV Size 499.51 GiB / not usable 3.00 MiBrn Allocatable yes (but full)rn PE Size 4.00 MiBrn Total PE 127874rn Free PE 0rn Allocated PE 127874rn PV UUID TJVNBO-tTLx-Tr9z-HJuC-z8N1-Sad2-EbMEnKrn rn --- Physical volume ---rn PV Name /dev/sdb1rn VG Name vg_fjxmdmrespoolvm84rn PV Size 7.66 GiB / not usable 4.21 MiBrn Allocatable yes rn PE Size 4.00 MiBrn Total PE 1960rn Free PE 168rn Allocated PE 1792rn PV UUID 3MfE7e-kpiw-ILyK-IHxd-P2I2-q0vd-BbLrU0rnrn 论坛

没有更多推荐了,返回首页