在CentOS 6 Linux下:不丢失数据对现有MBR分区进行扩容(小于2TB)

1、原/dev/sdb大小为500GB,通过VMware配置增加到1000GB

2、将/dev/sdb全部空间分配给/dev/sdb1

[root@hlht-test ~]# umount /u01

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

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

Disk /dev/sdb: 1073.7 GB, 1073741824000 bytes
255 heads, 63 sectors/track, 130541 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: 0x72d471d8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       65270   524281243+  83  Linux

# 删除之前的分区,然后建立新分区,注意开始的磁柱号要和原来的一致(保证数据不丢失的关键步骤),结束的磁柱号默认回车使用全部磁盘。

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/sdb: 1073.7 GB, 1073741824000 bytes
255 heads, 63 sectors/track, 130541 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: 0x72d471d8

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130541, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130541, default 130541): 
Using default value 130541

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3、调整分区

e2fsck -f /dev/sdb1 #检查分区信息
resize2fs /dev/sdb1 #调整分区大小

[root@hlht-test ~]# e2fsck -f /dev/sdb1
e2fsck 1.43-WIP (20-Jun-2013)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/sdb1: 57349/32768000 files (0.9% non-contiguous), 130385544/131070310 blocks

[root@hlht-test ~]# resize2fs /dev/sdb1
resize2fs 1.43-WIP (20-Jun-2013)
Resizing the filesystem on /dev/sdb1 to 262142637 (4k) blocks.
The filesystem on /dev/sdb1 is now 262142637 blocks long.

[root@hlht-test ~]# mount /dev/sdb1 /u01

[root@hlht-test ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_hlhttest-lv_root
                       66G   11G   53G  17% /
tmpfs                  24G   80K   24G   1% /dev/shm
/dev/sda1             477M   82M  366M  19% /boot
/dev/mapper/vg_hlhttest-lv_home
                       20G  9.7G  9.0G  52% /home
/dev/sdb1             985G  490G  445G  53% /u01

[root@hlht-test ~]# lsblk
NAME                           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                              8:0    0   97G  0 disk 
├─sda1                           8:1    0  500M  0 part /boot
└─sda2                           8:2    0 96.5G  0 part 
  ├─vg_hlhttest-lv_root (dm-0) 251:0    0 66.8G  0 lvm  /
  ├─vg_hlhttest-lv_swap (dm-1) 251:1    0  9.7G  0 lvm  [SWAP]
  └─vg_hlhttest-lv_home (dm-2) 251:2    0   20G  0 lvm  /home
sdb                              8:16   0 1000G  0 disk 
└─sdb1                           8:17   0 1000G  0 part /u01
[root@hlht-test ~]#

4、验证:

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注