Syncing..done
由于/home原来的大小是47057,而我们希望在/home里面划分4G的空间出来,取整数/home的目标大小就是43000。所以在resize_reiserfs时为-s提供大小为43000M。 这样我们就已完成了文件系统大小调整的工作,下面让我们计算一下目标分区的大小,这个大小需要根据你的fdisk里面的Units值来计算,因为硬盘分区都是按照柱面来划分的,基本的计算方法为:43000*1024*1024/8225280=5481.7304699657640834111422346716,然后我们取最接近的值5482+1478=6960来作为分区结束的柱号,这里面的1478是/home分区开始的柱面号,在前面的fdisk里面能看到。 调整完文件系统的大小以后,再使用以下命令以文件系统进行全方面的检查:[root@ringmail root]# reiserfsck --check --fix-fixable /dev/hda6 目前我们已完成文件系统的大小调整工作,不过硬盘分区的大小仍然没有调整,还是跟先前相同大(能想像我们从书橱里面拿走了几本书,而书架的大小并没有调整,依然占用着原来的空间)。 目前我们要开始进行整个操作里面最危险的操作:如果没有必要的话,最佳不要进行下去,不过不必过于担心,按照以下操作进行即可。
启动fdisk,并按照以下步骤进行:[root@ringmail root]# fdisk /dev/hdaThe number of cylinders for this disk is set to 7476.There is nothing wrong with that, but this is larger than 1024,and could in certain setups 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): pDisk /dev/hda: 61.4 GB, 61492838400 bytes255 heads, 63 sectors/track, 7476 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/hda1 * 1 915 7349706 83 Linux/dev/hda2 916 1414 4008217+ 83 Linux/dev/hda3 1415 7476 48693015 5 Extended/dev/hda5 1415 1477 506016 82 Linux swap/dev/hda6 1478 7476 48186936 83 LinuxCommand (m for help): dPartition number (1-6): 6Command (m for help): nCommand action l logical (5 or over) p primary partition (1-4)lFirst cylinder (1478-7476, default 147: 1478
Last cylinder or +size or +sizeM or +sizeK (1478-7476, default 7476): 6960Command (m for help): pDisk /dev/hda: 61.4 GB, 61492838400 bytes255 heads, 63 sectors/track, 7476 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/hda1 * 1 915 7349706 83 Linux/dev/hda2 916 1414 4008217+ 83 Linux/dev/hda3 1415 7476 48693015 5 Extended/dev/hda5 1415 1477 506016 82 Linux swap/dev/hda6 1478 6960 44042166 83 LinuxCommand (m 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 resourcebusy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks. 这里需要说明的是,由于内核仍然使用旧的分区表,我需要通过重新启动才能刷新刚制作的分区信息,所以在进行完重划分区操作以后,我对系统进行了重新启操作。系统重启后再继续后续的操作过程。 通过以上步骤,我们已完成了硬盘分区大小调整的操作,接下来回到重新调整文件系统大小的问题上来。由于硬盘分区是按照柱面来计划的,我们要在resize_reiserfs步骤上就一步到位调整文件系统大小和硬盘分区大小正好相等是比较困难的事情。所以一般是调硬盘分区比文件系统要大一点点,然后再通过以下命令进行同步(当然如果你不在意硬盘分区里面存在部分空间的话也能忽略以下步骤):[root@ringmail root]# umount /home/[root@ringmail root]# resize_reiserfs /dev/hda6;reiserfsprogs 3.6.4ReiserFS report:blocksize 4096block count 11010541 (11008000)free blocks 4680574 (4678034)bitmap block count 337 (336)Syncing..done 完成以后原有分区的大小调整操作已结束,接下来需要创建新分区:[root@ringmail root]# fdisk /dev/hdaThe number of cylinders for this disk is set to 7476.There is nothing wrong with that, but this is larger than 1024,and could in certain setups 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): pDisk /dev/hda: 61.4 GB, 61492838400 bytes255 heads, 63 sectors/track, 7476 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/hda1 * 1 915 7349706 83 Linux/dev/hda2 916 1414 4008217+ 83 Linux/dev/hda3 1415 7476 48693015 5 Extended/dev/hda5 1415 1477 506016 82 Linux swap/dev/hda6 1478 6960 44042166 83 LinuxCommand (m for help): nCommand action l logical (5 or over) p primary partition (1-4)lFirst cylinder (6961-7476, default 6961):Using default value 6961Last cylinder or +size or +sizeM or +sizeK (6961-7476, default 7476):Using default value 7476Command (m for help): tPartition number (1-7): 7Hex code (type L to list codes): a5Changed system type of partition 7 to a5 (FreeBSD)Command (m for help): pDisk /dev/hda: 61.4 GB, 61492838400 bytes255 heads, 63 sectors/track, 7476 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/hda1 * 1 915 7349706 83 Linux/dev/hda2 916 1414 4008217+ 83 Linux/dev/hda3 1415 7476 48693015 5 Extended/dev/hda5 1415 1477 506016 82 Linux swap/dev/hda6 1478 6960 44042166 83 Linux/dev/hda7 6961 7476 4144738+ a5 FreeBSDCommand (m 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 resourcebusy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks. 至此,整个调整分区大小及创建新分区的操作全部完成。转贴的,忘了在那看到的,所以作者不要见怪。呵呵