Wednesday, April 8, 2015

Cisco Prime Partition Resizing


It is expected that when you run an image .iso or .ova, whatever, everything is gonna be all right at the end of the process. After all, we are handling a blackbox created by someone really specialized. But, you may find some surprise out there.
I was happily performing a restore from Prime version 1.3 to a 1.4. Nothing could be wrong on that, I thought!  But not!
When I was running the restore command, I got the following errors:

 Stage 1 of 9: Transferring backup file ...

  -- complete.
  Stage 2 of 9: Decrypting backup file ...

  -- complete.
  Stage 3 of 9: Unpacking backup file ...
  --complete.
 ERROR: Not enough space to continue restore

What ? How is that possible? My Virtual Machine has 1 Tera on its HD!!
Well, looking for some information on the Internet, I have found some interesting tips. According to that, Cisco Prime wrongly allocate the /opt partition sometimes. In my case, it has reserved 120 G and was using 60%. That´s the problem.

ade # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/smosvg-rootvol
                      3.8G  295M  3.4G   9% /
/dev/mapper/smosvg-storeddatavol
                      9.5G  151M  8.9G   2% /storeddata
/dev/mapper/smosvg-localdiskvol
                       29G  235M   27G   1% /localdisk
/dev/sda2              97M  5.6M   87M   7% /storedconfig
/dev/mapper/smosvg-home
                       93M  5.6M   83M   7% /home
/dev/mapper/smosvg-optvol
                      120G   68G   46G  60% /opt
/dev/mapper/smosvg-varvol
                      3.8G  115M  3.5G   4% /var
/dev/mapper/smosvg-usrvol
                      6.6G  1.2G  5.1G  19% /usr
/dev/mapper/smosvg-tmpvol
                      1.9G   36M  1.8G   2% /tmp
/dev/mapper/smosvg-recvol
                       93M  5.6M   83M   7% /recovery
/dev/mapper/smosvg-altrootvol
                       93M  5.6M   83M   7% /altroot
/dev/sda1             485M   18M  442M   4% /boot
tmpfs                  12G  6.0G  5.8G  52% /dev/shm


The solution proposed was resize that partition. It is possible?  Well, some time ago I was not even aware that it is possible access the Unix side of the Cisco Prime!
The answer is: It is possible!

For those of you not really familiar with Cisco Prime, to get access to the Linux side, you can enable it firstly:

root_enable

Then, just type root at the command line and provide the root password. It is expected the following prompt:

ade #

 From now  we can move on:

ade # fdisk /dev/sda

The number of cylinders for this disk is set to 156650.
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): p

Disk /dev/sda: 1288.4 GB, 1288490188800 bytes
255 heads, 63 sectors/track, 156650 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64          77      102400   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3              77       25497   204184576   8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (25497-156650, default 25497):
Using default value 25497
Last cylinder or +size or +sizeM or +sizeK (25497-156650, default 156650):
Using default value 156650

Command (m for help): p

Disk /dev/sda: 1288.4 GB, 1288490188800 bytes
255 heads, 63 sectors/track, 156650 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64          77      102400   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3              77       25497   204184576   8e  Linux LVM
/dev/sda4           25497      156650  1053491125   83  Linux

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 1288.4 GB, 1288490188800 bytes
255 heads, 63 sectors/track, 156650 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64          77      102400   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3              77       25497   204184576   8e  Linux LVM
/dev/sda4           25497      156650  1053491125   8e  Linux LVM

Command (m for help): v
Partition 1 does not end on cylinder boundary.
Partition 2 does not end on cylinder boundary.
2197 unallocated sectors

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.
ade #
ade #

If you are following the instructions, pay attention to the letters in front of Command (m for help):
Type the same letters used here. It is expected that you end up with the same message.
Reboot the machine. As soon as it is back, use the following command to create a new partition:

ade # pvcreate /dev/sda4
  Physical volume "/dev/sda4" successfully created

You can see what you just created:

ade # vgdisplay
  --- Volume group ---
  VG Name               smosvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  12
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                11
  Open LV               11
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               194.72 GB
  PE Size               32.00 MB
  Total PE              6231
  Alloc PE / Size       6231 / 194.72 GB
  Free  PE / Size       0 / 0
  VG UUID               1TBYXf-d59o-mpCo-88Yj-MjjO-paCV-7WIsV

The next step is add this brand new partition to /opt:

ade # lvextend /dev/mapper/smosvg-optvol /dev/sda4
  Physical Volume "/dev/sda4" not found in Volume Group "smosvg"
ade #

As we can see above, we got an error. This can be fixed with the following command:

ade # vgextend smosvg /dev/sda4
  Volume group "smosvg" successfully extended

And the 'grand finale':

ade # lvextend /dev/mapper/smosvg-optvol /dev/sda4
  Extending logical volume optvol to 1.10 TB
  Logical volume optvol successfully resized

ade # resize2fs /dev/mapper/smosvg-optvol
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/smosvg-optvol is mounted on /opt; on-line resizing required
Performing an on-line resize of /dev/mapper/smosvg-optvol to 295665664 (4k) blocks.

If you succeed this output may appear:

ade # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/smosvg-rootvol
                      3.8G  295M  3.4G   9% /
/dev/mapper/smosvg-storeddatavol
                      9.5G  151M  8.9G   2% /storeddata
/dev/mapper/smosvg-localdiskvol
                       29G  235M   27G   1% /localdisk
/dev/sda2              97M  5.6M   87M   7% /storedconfig
/dev/mapper/smosvg-home
                       93M  5.6M   83M   7% /home
/dev/mapper/smosvg-optvol
                      1.1T   67G  970G   7% /opt
/dev/mapper/smosvg-varvol
                      3.8G  117M  3.5G   4% /var
/dev/mapper/smosvg-usrvol
                      6.6G  1.2G  5.1G  19% /usr
/dev/mapper/smosvg-tmpvol
                      1.9G   36M  1.8G   2% /tmp
/dev/mapper/smosvg-recvol
                       93M  5.6M   83M   7% /recovery
/dev/mapper/smosvg-altrootvol
                       93M  5.6M   83M   7% /altroot
/dev/sda1             485M   18M  442M   4% /boot
tmpfs                  12G  6.0G  5.8G  52% /dev/shm

This concludes the objective of this article. Resizing Cisco Prime partition. As mentioned above, it is expected that everything works fine but sometime we have this situations. Most probably you´ll not find anything about it on Cisco docs. So, this information is very precious!





No comments:

Post a Comment