linux非lvm下文件系统扩容

上传人:xiao****1972 文档编号:84823086 上传时间:2019-03-05 格式:DOCX 页数:12 大小:103.44KB
返回 下载 相关 举报
linux非lvm下文件系统扩容_第1页
第1页 / 共12页
linux非lvm下文件系统扩容_第2页
第2页 / 共12页
linux非lvm下文件系统扩容_第3页
第3页 / 共12页
linux非lvm下文件系统扩容_第4页
第4页 / 共12页
linux非lvm下文件系统扩容_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《linux非lvm下文件系统扩容》由会员分享,可在线阅读,更多相关《linux非lvm下文件系统扩容(12页珍藏版)》请在金锄头文库上搜索。

1、原来linux不用LVM也能扩展文件系统以前总以为UNIX/LINUX使用了lvm才能扩展或缩小卷和文件系统,今天才发现我错了:即使没有lvm,linux也能扩展卷和及其相应的文件系统而不会丢失原有数据。以下是测试步骤,记录备查。1、系统是redhat linux 6rootlocalhost ku# uname -r2.6.32-131.0.15.el6.x86_64rootlocalhost ku# more /etc/redhat-releaseRed Hat Enterprise Linux Server release 6.1 (Santiago)rootlocalhost ku#2

2、、创建/dev/sdb1及其文件系统,创建文本文件rootlocalhost ku# echo welcome to redhat world rickyrootlocalhost ku# more rickywelcome to redhat world3、目前/dev/sdb1对应的文件系统/ku为1.2Grootlocalhost ku# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 16G 3.7G 11G 25% /tmpfs 613M 88K 613M 1% /dev/shm/

3、dev/sda1 485M 32M 428M 7% /boot/dev/sdb1 1.2G 34M 1.1G 3% /ku4、卸载/kurootlocalhost ku# cd /rootlocalhost /# umount /kurootlocalhost /#5、用fdisk命令删除/dev/sdb1分区,然后重新创建/dev/sdb1分区,并指定大小为4Grootlocalhost /# fdisk /dev/sdbWARNING: DOS-compatible mode is deprecated. Its strongly recommended to switch off the

4、 mode (command c) and change display units to sectors (command u).Command (m for help): pDisk /dev/sdb: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal):

5、512 bytes / 512 bytesDisk identifier: 0x54f7c6df Device Boot Start End Blocks Id System/dev/sdb1 1 393 3156741 83 LinuxCommand (m for help): dSelected partition 1Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-652, default 1):Usin

6、g default value 1Last cylinder, +cylinders or +sizeK,M,G (1-652, default 652): +4GCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.rootlocalhost /#6、fdisk -l /dev/sdb输出可以看出,cylinder已经由393扩为523rootlocalhost /# fdisk -l /dev/sdbDisk /

7、dev/sdb: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x54f7c6df Device Boot Start End Blocks Id System/dev/sdb

8、1 1 523 4200966 83 Linux7、先check文件系统rootlocalhost /# e2fsck -f /dev/sdb1e2fsck 1.41.12 (17-May-2010)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/sdb

9、1: 12/73760 files (0.0% non-contiguous), 13234/307200 blocks8、将文件系统resize为2Grootlocalhost /# resize2fs /dev/sdb1 2Gresize2fs 1.41.12 (17-May-2010)Resizing the filesystem on /dev/sdb1 to 524288 (4k) blocks.The filesystem on /dev/sdb1 is now 524288 blocks long.rootlocalhost /# mount /dev/sdb1 /kurootl

10、ocalhost /# df -hFilesystem 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 2.0G 34M 1.9G 2% /kurootlocalhost /#9、检查扩容前的文件是否正确无损rootlocalhost /# cd /kurootlocalhost ku# more rickywelcome to redhat

11、worldrootlocalhost ku#10、当然也可以在线扩展文件系统rootlocalhost ku# resize2fs /dev/sdb1 2500Mresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/sdb1 is mounted on /ku; on-line resizing requiredold desc_blocks = 1, new_desc_blocks = 1Performing an on-line resize of /dev/sdb1 to 640000 (4k) blocks.The filesystem o

12、n /dev/sdb1 is now 640000 blocks long.rootlocalhost ku# df -hFilesystem 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 2.5G 34M 2.3G 2% /kurootlocalhost ku#11、但是不可以在线缩小;要缩小文件系统必须先卸载文件系统rootlocalho

13、st ku# resize2fs /dev/sdb1 1Gresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/sdb1 is mounted on /ku; on-line resizing requiredOn-line shrinking from 640000 to 262144 not supported.rootlocalhost ku# cd /rootlocalhost /# umount /kurootlocalhost /# resize2fs /dev/sdb1 1Gresize2fs 1.41.12 (17-May-2010

14、)Please run e2fsck -f /dev/sdb1 first.rootlocalhost /# e2fsck -f /dev/sdb1e2fsck 1.41.12 (17-May-2010)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/sdb1: 12/

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号