resize/挂载点(但不是在lvm中)

我像下面的步骤一样

sr1-server:/dev # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 38G 35G 1022M 98% / udev 3.9G 88K 3.9G 1% /dev sr1-server:/dev # fdisk -l Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00083481 Device Boot Start End Blocks Id System /dev/sda1 1 262 2104483+ 82 Linux swap / Solaris /dev/sda2 * 263 5221 39833167+ 83 Linux sr1-server:/dev # fdisk /dev/sda The number of cylinders for this disk is set to 6527. 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 (eg, old versions of LILO) 2) booting and partitioning software from other OSs (eg, DOS FDISK, OS/2 FDISK) Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): d Partition number (1-4): 2 Command (m for help): p Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00083481 Device Boot Start End Blocks Id System /dev/sda1 1 262 2104483+ 82 Linux swap / Solaris Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (263-6527, default 263): Using default value 263 Last cylinder, +cylinders or +size{K,M,G} (263-6527, default 6527): Using default value 6527 Command (m for help): p Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00083481 Device Boot Start End Blocks Id System /dev/sda1 1 262 2104483+ 82 Linux swap / Solaris /dev/sda2 263 6527 50323612+ 83 Linux Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): w The 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. sr1-server:/dev # fdisk -l Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00083481 Device Boot Start End Blocks Id System /dev/sda1 1 262 2104483+ 82 Linux swap / Solaris /dev/sda2 263 6527 50323612+ 83 Linux sr1-server:/dev # resize2fs /dev/sda2 resize2fs 1.41.1 (01-Sep-2008) The filesystem is already 9958291 blocks long. Nothing to do! sr1-server:/dev # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 38G 35G 1022M 98% / udev 3.9G 88K 3.9G 1% /dev sr1-server:/dev # sr1-server:/dev # sr1-server:/dev # reboot Broadcast message from root (pts/1) (Sat Jul 27 06:24:26 2013): The system is going down for reboot NOW! sr1-server:/dev # 

但之后,我无法连接。 无论是对还是错? 如何拯救服务器?

我发现自己不由自主地大叫“不,不! 当我读你的成绩单。 看起来你试图调整正在运行的系统上的根文件系统,同时它被挂载。 您更改了分区表,但是内核没有重新读取(仔细阅读消息)。 然后resize2fs没有发生,因为使用了旧的分区长度。

如果我是对的,这是你所做的,这是一个非常糟糕的主意。 只尝试调整未挂载的分区的大小,并且永远不要对正在运行的系统上的根分区执行任何操作。

你现在最好的select是从应急媒体启动,并试图找出你的分区表和文件系统在什么状态。你需要控制台访问服务器来做任何types的恢复。

我使用kvm guest的简单分区进行testing,没有lvm你不能做一个在线resize,这是我调整分区的大小后,我使用partprobeblockdev && sfdisk

  partprobe /dev/vdb Error: Partition(s) 1 on /dev/vdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. blockdev --rereadpt /dev/vdb BLKRRPART: Device or resource busy sfdisk -R /dev/vdb BLKRRPART: Device or resource busy sfdisk: This disk is currently in use. 

唉,你有你的fdisk在圆柱体显示模式。 现在和以前相比,我想这个地址稍微有些不同。

如果你的服务器有一个救援模式(可以启动的救援系统,你可以连接的串行terminal,…),你应该尝试一下,看看有什么不对。