Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i did as like below steps

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 (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): 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 #

But after this i can't able to connect. whether it's right or wrong? how to rescue the server?

share|improve this question
    
Is it a physical or virtual server? –  MadHatter Jul 27 '13 at 15:46
4  
Resising your root partition (or any valuable partition really) is not something that should be attempted until you have a solid understanding of how the underlying technology and all the associated tools work. This is something that is absurdly easy to screw up and can quickly become non-salvageable. –  tylerl Jul 27 '13 at 23:46

4 Answers 4

I found myself involuntarily shouting 'nooooooo!' as I read your transcript. It seems that you tried to resize the root filesystem on a running system while it was mounted. You changed the partition table, but it wasn't re-read by the kernel (read the messages carefully). Then the resize2fs didn't happen because the old partition length was used.

If I'm right and this is what you did, it was a really bad idea. Only attempt to resize partitions that are not mounted, and never ever do anything to the root partition on a running system.

Your best bet now is to boot from rescue media and try to figure out what state your partition table and filesystem are in. You'll need console access to the server to do any kind of recovery.

share|improve this answer
    
Actually i thought it was because of i didn't chose the boot partition... –  user183298 Jul 27 '13 at 17:56
    
I'm afraid you did. I've just noticed that after you re-created it, the root partition doesn't have its boot flag set. That might be your first port of call. –  Flup Jul 28 '13 at 18:57
2  
@Flup In general, there is no problem resizing a partition, even if it is the root partition. I have done so several times on ext4, where it is explicitly supported. –  glglgl Jul 29 '13 at 10:57

I did a test with plain partition on kvm guest, without lvm you can't do a online resize, this is the result after i resized the partition and i used partprobe and blockdev && 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.
share|improve this answer

Alas, you had your fdisk in cylinder display mode. I suppose it starts at a slighty different address now in comparison to before.

If your server has by any means a rescue mode (rescue system which can be booted into, serial terminal which you can connect to, ...), you should try it and have a look what is wrong.

share|improve this answer

CLI is a good way to do that,Partition Assistant developed by AOMEI offers u a great help in doing that,it's time saving and protect your data from losing.i believe it would help u.The third party software may offer u a great help.the disk management tool I've resolved that kind of problem with Partition Assistant developed by AOMEI Tech. I believe it would help u in solving the problems u counterd.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.