【2017年整理】重新调整ext3格式分区大小的方法

上传人:豆浆 文档编号:1069582 上传时间:2017-05-27 格式:DOC 页数:8 大小:53KB
返回 下载 相关 举报
【2017年整理】重新调整ext3格式分区大小的方法_第1页
第1页 / 共8页
【2017年整理】重新调整ext3格式分区大小的方法_第2页
第2页 / 共8页
【2017年整理】重新调整ext3格式分区大小的方法_第3页
第3页 / 共8页
【2017年整理】重新调整ext3格式分区大小的方法_第4页
第4页 / 共8页
【2017年整理】重新调整ext3格式分区大小的方法_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《【2017年整理】重新调整ext3格式分区大小的方法》由会员分享,可在线阅读,更多相关《【2017年整理】重新调整ext3格式分区大小的方法(8页珍藏版)》请在金锄头文库上搜索。

1、重新调整 ext3 格式分区大小的方法本篇文章主要介绍如何调整格式为 ext3 的分区的大小,并确保不丢失数据。它将向你讲述如何增加或者缩小已存在的 ext3 分区的大小。分区的调整必须在设备 umount 的情况下进行。如果你要调整的分区为存放 Linux 系统重要文件的分区(比如:/、/boot),请事先准备一张 Live Linux-CD 启动盘(这个很容易就可以在网上找到),以备稍后使用;如果你仅仅只是调整普通分区的大小(比如:/home),则可以直接使用本机系统进行,而无须进入 Live CD 系统。另外,请确保你的系统上已安装了以下工具:fdisk、umount、fsck、tune

2、2fs、e2fsck、resize2fs,系统最小化安装时这些工具就已经集成在系统中了,直接使用就可。如果你要在用于商业用途的 Linux 系统上调整分区大小,请先确保系统数据已备份完成。下面我将以/dev/sda5 分区举例。先查看以下系统分区信息:rootlocalhost # df B 4krootlocalhost # df hrootlocalhost # df -B 4kFilesystem 4K-blocks Used Available Use% Mounted on/dev/sda2 990087 500195 438786 54% /dev/sda5 3575306 418

3、28 3348932 2% /home/dev/sda1 11659 2638 8419 24% /boottmpfs 67424 0 67424 0% /dev/shmrootlocalhost # df -hFilesystem Size Used Avail Use% Mounted on/dev/sda2 3.8G 2.0G 1.7G 54% /dev/sda5 14G 164M 13G 2% /home/dev/sda1 46M 11M 33M 24% /boottmpfs 264M 0 264M 0% /dev/shmdf B 4k 以 4k 为以单位查看,这个稍后会用得到我的/d

4、ev/sda5 设备对应/home 目录,大小为 14Grootlocalhost # fdisk lDisk /dev/sda: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sda1 * 1 6 48163+ 83 Linux/dev/sda2 7 515 4088542+ 83 Linux/dev/sda3 516 7

5、72 2064352+ 82 Linux swap / Solaris/dev/sda4 773 2610 14763735 5 Extended/dev/sda5 773 2610 14763703+ 83 Linux如果你修改的是/、/boot 分区的大小,要先重启进入 Live CD 系统进行操作,因为调整时设备必须为 umount,所以需要借助 Live CD 进行rootlocalhost # init 0 重启进入 Live 的系统后,先进行设备卸载rootlocalhost # umount /dev/sda5接着运行rootlocalhost # fsck n /dev/sda

6、5fsck 1.39 (29-May-2006)e2fsck 1.39 (29-May-2006)/home: clean, 18/3691936 files, 157447/3690925 blocks-n 表示只把一些简单的报告和问题输出到标准输出,而不去修复。接着将 ext3 格式转化为 ext2 格式rootlocalhost # tune2fs -O has_journal /dev/sda5tune2fs 1.39 (29-May-2006)我尝试了好几种工具都不能直接将 ext3 文件系统改变大小,因此我们先将它转换为ext2 格式,然后再调整大小使用 e2fsck 检查 ext

7、2 文件系统是否正常rootlocalhost # e2fsck -f /dev/sda5e2fsck 1.39 (29-May-2006)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/home: 18/3691936 files (5.6% non-cont

8、iguous), 124645/3690925 blocks接着我们调整文件系统的大小。这里注意,如果是缩小文件系统的大小,要确保缩小后的文件系统空间大于文件系统已经使用的空间。我的/dev/sda5 已使用 164M,这里我给它分配 5G 空间。rootlocalhost # resize2fs /dev/sda5 5000Mresize2fs 1.39 (29-May-2006)Resizing the filesystem on /dev/sda5 to 1280000 (4k) blocks.The filesystem on /dev/sda5 is now 1280000 bloc

9、ks long.You have mail in /var/spool/mail/root这里记下/dev/sda5 的大小 1280000 和单位 4K,稍后使用。接着使用 fdisk 工具进行重新分区rootlocalhost # fdisk /dev/sda注意这里是/dev/sda 而非/dev/sda5The number of cylinders for this disk is set to 2610.There is nothing wrong with that, but this is larger than 1024,and could in certain setups

10、 cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): mCommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partition

11、l list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partitions system idu change display/entry unitsv verify the partition tablew write table to

12、disk and exitx extra functionality (experts only)Command (m for help):删除分区(/dev/sda5)Command (m for help): dPartition number (1-5): 5创建新分区Command (m for help): nFirst cylinder (773-2610, default 773): 773这里会被询问填写新分区的大小,开始柱面默认即可,现在关键介绍结束柱面的计算。由前面数据可知,文件系统的大小为 1280000*4K,为了确保我们的分区足够大以包含文件系统,这里可以增加文件系统

13、大小的 3%5%来作为分区大小。因此分区大小为 Size=1280000*4K*1.05=5376000KLast cylinder or +size or +sizeM or +sizeK (773-2610, default 2610): +5376000K接着使用参数 aCommand (m for help): aPartition number (1-5): 5选项 a 的解释为 toggle a bootable flag 对于这个选项不是很理解,但一个明显的作用就是为新的分区分配区号,这里选择 5(/dev/sda5)。接着将修改写入分区表并退出 fdiskCommand (m

14、for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks.接着重新启动系统。修改/、/boot 分区的还须进入

15、 Live CD 系统rootlocalhost # rebootBroadcast message from root (pts/0) (Fri Mar 19 11:53:42 2010):The system is going down for reboot NOW!重启后检查 ext2 文件系统rootlocalhost # fsck -n /dev/sda5fsck 1.39 (29-May-2006)e2fsck 1.39 (29-May-2006)/home: clean, 18/1306880 files, 48160/1280000 blocks与调整分区大小前的 fsck 比较我

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

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