您的位置:首页 > 运维架构 > Linux

linux硬盘扩容

2015-08-28 10:50 627 查看
[root@bigdata~]# fdisk -l

Disk /dev/sdb: 899.0 GB, 898999779328 bytes

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

Disk /dev/sda: 899.0 GB, 898999779328 bytes

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

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

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xc8c7b959.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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): m

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): n

Command action

   e   extended

   p   primary partition (1-4)
p
Partition number (1-4): 1

First cylinder (1-109297, default 1): 

Using default value 1

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

Using default value 109297

Command (m for help): p

Disk /dev/sdb: 899.0 GB, 898999779328 bytes

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

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1      109297   877928121   83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.
[root@bigdata ~]# pvs

  PV         VG     Fmt  Attr PSize   PFree  

  /dev/sda2  rootvg lvm2 a--  836.25g 773.26g
[root@bigdata ~]# pvcreate /dev/sdb1

  dev_is_mpath: failed to get device for 8:17

  Physical volume "/dev/sdb1" successfully created
[root@bigdata  ~]# pvs

  PV         VG     Fmt  Attr PSize   PFree  

  /dev/sda2  rootvg lvm2 a--  836.25g 773.26g

  /dev/sdb1         lvm2 a--  837.26g 837.26g
[root@bigdata ~]# vgextend rootvg /dev/sdb1

  Volume group "rootvg" successfully extended
[root@bigdata ~]# pvs

  PV         VG     Fmt  Attr PSize   PFree  

  /dev/sda2  rootvg lvm2 a--  836.25g 773.26g

  /dev/sdb1  rootvg lvm2 a--  837.25g 837.25g
[root@bigdata ~]# df -h

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/rootvg-lvroot  9.9G  388M  9.0G   5% /

tmpfs                      253G  224K  253G   1% /dev/shm

/dev/sda1                 1008M   63M  895M   7% /boot

/dev/mapper/rootvg-lvhome 1008M   34M  924M   4% /home

/dev/mapper/rootvg-lvopt   4.0G  136M  3.7G   4% /opt

/dev/mapper/rootvg-lvtmp   3.0G   69M  2.8G   3% /tmp

/dev/mapper/rootvg-lvusr   7.9G  2.3G  5.3G  31% /usr

/dev/mapper/rootvg-lvvar   2.0G  168M  1.8G   9% /var
[root@bigdata ~]# lvextend -L +837G /dev/mapper/rootvg-lvroot /dev/sdb1

  Extending logical volume lvroot to 847.00 GiB

  Logical volume lvroot successfully resized
[root@bigdata ~]# resize2fs /dev/mapper/rootvg-lvroot

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/rootvg-lvroot is mounted on /; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 53

Performing an on-line resize of /dev/mapper/rootvg-lvroot to 222035968 (4k) blocks.

The filesystem on /dev/mapper/rootvg-lvroot is now 222035968 blocks long.

[root@bigdata ~]# df -h

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/rootvg-lvroot  834G  409M  791G   1% /

tmpfs                      253G  224K  253G   1% /dev/shm

/dev/sda1                 1008M   63M  895M   7% /boot

/dev/mapper/rootvg-lvhome 1008M   34M  924M   4% /home

/dev/mapper/rootvg-lvopt   4.0G  136M  3.7G   4% /opt

/dev/mapper/rootvg-lvtmp   3.0G   69M  2.8G   3% /tmp

/dev/mapper/rootvg-lvusr   7.9G  2.3G  5.3G  31% /usr

/dev/mapper/rootvg-lvvar   2.0G  168M  1.8G   9% /var
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: