troubleshooting Question

Mesed up with Linux partition resizing...

Avatar of Andrej Pirman
Andrej PirmanFlag for Slovenia asked on
LinuxLinux Distributions
9 Comments1 Solution705 ViewsLast Modified:
Hi,

I messed up today with production server on Linux Ubuntu 10.04 LTS. I wanted to extend LVM partition on Virtual Linux server (ESX 5.0), something came out during my work and I I forgot to make snapshot!

What I did already?
First, I shut down Linux server (with intention to make snapshot...but I forgot), added some 35GB to virtual DISK space in ESX, and powered up machine.

This is BEFORE any changes:
root@enginex:/home/labsy# fdisk -l

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f1f94

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32        2611    20719617    5  Extended
/dev/sda3            2611        5221    20967186+  83  Linux
/dev/sda5              32        2611    20719616   8e  Linux LVM
After Virtual disk RESIZING, I did this:
root@enginex:/home/labsy# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders, total 157286400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f1f94

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    41940991    20719617    5  Extended
/dev/sda3        41940992    83875364    20967186+  83  Linux
/dev/sda5          501760    41940991    20719616   8e  Linux LVM

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Selected partition 4
First sector (499712-157286399, default 499712):
Using default value 499712
Last sector, +sectors or +size{K,M,G} (499712-501757, default 501757):
Using default value 501757

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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
Rebooted again.

Then my situation was as follows:
root@enginex:/home/labsy# fdisk -l

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f1f94

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32        2611    20719617    5  Extended
/dev/sda3            2611        5221    20967186+  83  Linux
/dev/sda4              32          32        1023   83  Linux
Partition 4 does not end on cylinder boundary.
/dev/sda5              32        2611    20719616   8e  Linux LVM

Partition table entries are not in disk order
Here I should have fixed partition table entries, but I did not!
MISTAKE!

So I messed up with the following commands, which I need to UNDO somehow:
root@enginex:/home/labsy# pvcreate /dev/sda4
  Physical volume "/dev/sda4" successfully created
root@enginex:/home/labsy# vgdisplay | grep "Name"
  VG Name               enginex
root@enginex:/home/labsy# vgextend enginex /dev/sda4
  Volume group "enginex" successfully extended
root@enginex:/home/labsy# vgdisplay enginex | grep "Free"
  Free  PE / Size       2 / 8.00 MiB
Please, advice, how to proceed.
As you see, I extended with WRONG volume, which is only 8MB in size, instead of 35GB.
I need to revert these TWLO last actions to get partition tables fixed first.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros