天天看点

lvm linux根目录扩容,vmware下linux非LVM管理的根目录扩容经历

因为根目录会包含很多系统应用运行的配置等,肯定不能直接卸载,所以要采用一种既不破坏数据,又能扩容的方法:

1.关机

2.设置->扩展磁盘容量

3.开机

[[email protected] ~]#df -hT-T 文件系统Filesystem     Type    Size  Used Avail Use% Mounted on/dev/sda2ext418G15G  2.6G85%/tmpfs          tmpfs   491M  148K  491M   1% /dev/shm

/dev/sda1      ext4    291M   34M  242M  13% /boot

[[email protected] ~]#fdisk -l

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          39      307200   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda239        2358    1863168083Linux非LVM

[[email protected] ~]#fdisk /dev/sda

d删除分区

2删除/dev/sda2

n新增

p主分区

2新增/dev/sda2

回车默认

回车默认

w保存

[[email protected] ~]#reboot

因为是ext4格式,用resize2fs

[root@localhost ~]#resize2fs /dev/sda2resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/sda2 is mounted on /; on-line resizing required

old desc_blocks = 2, new_desc_blocks = 3

Performing an on-line resize of /dev/sda2 to 10407364 (4k) blocks.

The filesystem on /dev/sda2 is now 10407364 blocks long.

[[email protected] ~]#df -hTFilesystem     Type    Size  Used Avail Use% Mounted on

/dev/sda2      ext4     40G   15G   24G38%/

tmpfs          tmpfs   491M   80K  491M   1% /dev/shm

/dev/sda1      ext4    291M   34M  242M  13% /boot

.host:/        vmhgfs  921G  171G  751G  19% /mnt/hgfs

[r[email protected] ~]#lsblkNAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sr0     11:0    1 1024M  0 rom

sda      8:0    0   40G  0 disk

├─sda1   8:1    0  300M  0 part /boot

└─sda2   8:2    039.7G0 part /

由于sda2挂载在根目录下,sda2是最后一个分区,所以新增的空间跟sda2是连续的,在最后选择start和end的时候,就能连接上,这也是成功的一个条件