原来linux不用LVM也能扩展文件系统
以前总以为UNIX/LINUX使用了lvm才能扩展或缩小卷和文件系统,今天才发现我错了:即使没有lvm,linux也能扩展卷和及其相应的文件系统而不会丢失原有数据。
以下是测试步骤,记录备查。
1、系统是redhatlinux 6
[root@localhostku]# uname -r
2.6.32-131.0.15.el6.x86_64
2.6.32-131.0.15.el6.x86_64
[root@localhostku]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 6.1 (Santiago)
[root@localhostku]#
Red Hat Enterprise Linux Server release 6.1 (Santiago)
[root@localhostku]#
2、创建/dev/sdb1及其文件系统,创建文本文件
[root@localhostku]# echo welcome to redhat world >ricky
[root@localhostku]# more ricky
welcome to redhat world
[root@localhostku]# more ricky
welcome to redhat world
3、目前/dev/sdb1对应的文件系统/ku为1.2G
[root@localhostku]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
16G 3.7G 11G 25% /
tmpfs 613M 88K 613M 1% /dev/shm
/dev/sda1 485M 32M 428M 7% /boot
/dev/sdb1 1.2G 34M 1.1G 3% /ku
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
16G 3.7G 11G 25% /
tmpfs 613M 88K 613M 1% /dev/shm
/dev/sda1 485M 32M 428M 7% /boot
/dev/sdb1 1.2G 34M 1.1G 3% /ku
4、卸载/ku
[root@localhostku]# cd /
resized[root@localhost /]# umount /ku
[root@localhost /]#
resized[root@localhost /]# umount /ku
[root@localhost /]#
5、用fdisk命令删除/dev/sdb1分区,然后重新创建/dev/sdb1分区,并指定大小为4G
[root@localhost /]# 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').
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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: 0x54f7c6df
255 heads, 63 sectors/track, 652 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: 0x54f7c6df
Device Boot Start End Blocks Id System
/dev/sdb1 1 393 3156741 83 Linux
/dev/sdb1 1 393 3156741 83 Linux
Command (m for help): d
Selected partition 1
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): +4G
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): +4G
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论