Sunday, January 13, 2019

Suse Linux SLES 12 fdisk error "Value out of range"

Hello everyone this post i am writing for Linux admin who faced or will going to face following error , when they use fdisk command for doing partition on Suse Linux 12.

"Error : Value out of range"

Task details 
==============

Increase size of following file system to 100 GB

Procedure followed :
=================
Filesystem details 

# df -hT /data
Filesystem                 Type      Size    Used      Avail  Use% Mounted on

/dev/mapper/vg01-lvdata      50G   1.0G        49G   2% /data

# vgs
  VG     #PV #LV #SN Attr     VSize    VFree
  vg00     1       3     0      wz--n- 19.47g   1.47g

  vg01     1        8   0       wz--n-  50.0g   0.00 

Disk layout on which "/data" reside

sdb                          8:16   0  50G  0 disk
`-sdb1                       8:17   0  50G  0 part

  |-vg01-lvdata    254:3    0   50G  0 lvm  /data

SCSI details

root#  lsscsi

[0:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb

On vg01 there was no free space, so decided to extend existing disk to to 100 GB. so we provided SCSI details to VM team and requested increase size of /dev/sdb from 50 GB to 100 GB. after size increase from vmware team, we did disk re-scan using following command

#echo 1 >/sys/block/sdb/device/rescan

After re-scan output of lsblk is :

#lsblk |grep -i sdb
sdb                          8:16   0  100G  0 disk

now next step was to create new partition using fdisk utility. So i use command #fdisk /dev/sdb and printed existing partition table before creating new partition and observed that there is already one partition /dev/sdb1 there so new partition will be /dev/sdb2.

Steps followed for partitioning using fdisk :

#fdisk /dev/sdb

by pressing "n" started new partition creation process.

First sector : Press enter (it will take default value) // it will take value from where disk extended.

End sector , +sectors or +size{K,M,G}: +50G    // when press enter got following error

  "Error : Value out of range".  

After searching on google and took suggestion from senior,  always use "parted" for doing partition on SLES 12 when situation is like above, where disk is having one primary partition already then we need to create 2nd partition /dev/sdb2, then use "parted" command.

After this i used parted for creating partition on /dev/sdb like :

Procedure for doing partition using parted :
***please use parted command carefully , it can erase all data on your disk if you use it wrongly.



Linux#: parted /dev/sdb

GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print      //print partition details on /dev/sdb
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system
believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? fix     // enter fix

Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an
extra 629145600 blocks) or continue with the current setting?
Fix/Ignore? Fix   // enter fix

Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt_sync_mbr
Disk Flags:

Number  Start         End          Size   File system  Name     Flags
 1             1049kB  50GB      50GB                      primary  lvm         // Existing /dev/sdb1 partition

(parted) mkpart primary 50GB 100%      // Create /dev/sdb2  partition which start from 50 GB and end is use 100% space from 50GB onward.
(parted) print

Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt_sync_mbr
Disk Flags:
Number  Start   End    Size   File system  Name     Flags
 1      1049kB  50GB   50GB                  primary        lvm
 2       50GB    100GB   50GB                 primary  

(parted) set 2 lvm                                // setting flag to "lvm" for 2nd partition /dev/sdb2
New state?  [on]/off? on
(parted) print

Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt_sync_mbr
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  50GB  50GB               primary  lvm
 2      50GB   100GB  50GB               primary  lvm

(parted) quit
Information: You may need to update /etc/fstab.

#partx -a /dev/sdb      // Add the specified partition
#pvcreate /dev/sdb2
#vgextend vg01 /dev/sdb2

#vgs
VG       #PV #LV #SN Attr   VSize  VFree
  vg00     1      3      0     wz--n- 19.47g   1.47g
  vg01     1      1      0     wz--n-  100.0g    50.0g

#lvextend -L +50G /dev/mapper/vg01-lvdata
#xfs_growfs  /dev/mapper/vg01-lvdata

# df -hT /data
Filesystem                 Type      Size    Used      Avail  Use% Mounted on

/dev/mapper/vg01-lvdata      100G   1.0G   99G   1% /data


This way resized xfs filesysetm on Suse Linux 12, when  fdisk partitioning failing then used parted for partition and added that pv to vg01 and increased /data.

Thanks !!!

No comments:

Post a Comment