1

I am trying to add additional 40 GB to the 60 GB disk and make it 100GB. Disk is added from backend and in fdisk it shows 100GB. However, when trying to create new partition I get error "No free sectors available".

While trying to create partition with fdisk /dev/sda as below:

]# fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

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): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0006d1e9

   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        6528    51915776   8e  Linux LVM
/dev/sda3            6528        7832    10481740   8e  Linux LVM
/dev/sda4            7833        9137    10482412+   5  Extended
/dev/sda5            7833        9137    10482381   8e  Linux LVM
Partition 5 does not start on physical sector boundary.

Command (m for help): n
No free sectors available

Command (m for help): q

The fdisk -l output is below:

 ~]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0006d1e9

   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        6528    51915776   8e  Linux LVM
/dev/sda3            6528        7832    10481740   8e  Linux LVM
/dev/sda4            7833        9137    10482412+   5  Extended
/dev/sda5            7833        9137    10482381   8e  Linux LVM
Partition 5 does not start on physical sector boundary.

Disk /dev/mapper/vg_nkpdpbn01-lv_root: 69.2 GB, 69247959040 bytes
255 heads, 63 sectors/track, 8418 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_nkpdpbn01-lv_swap: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Additionally:

 ~]# lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                               8:0    0  100G  0 disk
ââsda1                            8:1    0  500M  0 part /boot
ââsda2                            8:2    0 49.5G  0 part
â ââvg_nkpdpbn01-lv_root (dm-0) 253:0    0 64.5G  0 lvm  /
â ââvg_nkpdpbn01-lv_swap (dm-1) 253:1    0    5G  0 lvm  [SWAP]
ââsda3                            8:3    0   10G  0 part
â ââvg_nkpdpbn01-lv_root (dm-0) 253:0    0 64.5G  0 lvm  /
ââsda4                            8:4    0    1K  0 part
ââsda5                            8:5    0   10G  0 part
  ââvg_nkpdpbn01-lv_root (dm-0) 253:0    0 64.5G  0 lvm  /
sr0                              11:0    1 1024M  0 rom



 ~]# pvs
File descriptor 63 (pipe:[355848]) leaked on pvs invocation. Parent PID 20225: -bash
  PV         VG           Fmt  Attr PSize  PFree
  /dev/sda2  vg_nkpdpbn01 lvm2 a--  49.51g    0
  /dev/sda3  vg_nkpdpbn01 lvm2 a--   9.99g    0
  /dev/sda5  vg_nkpdpbn01 lvm2 a--   9.99g    0
 ~]# lvs
File descriptor 63 (pipe:[356102]) leaked on lvs invocation. Parent PID 20225: -bash
  LV      VG           Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root vg_nkpdpbn01 -wi-ao---- 64.49g
  lv_swap vg_nkpdpbn01 -wi-ao----  5.00g
 ~]# vgs
File descriptor 63 (pipe:[356125]) leaked on vgs invocation. Parent PID 20225: -bash
  VG           #PV #LV #SN Attr   VSize  VFree
  vg_nkpdpbn01   3   2   0 wz--n- 69.49g    0


~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_nkpdpbn01-lv_root
                       64G   44G   17G  73% /
tmpfs                 3.9G  4.0K  3.9G   1% /dev/shm
/dev/sda1             477M  115M  337M  26% /boot

2 Answers 2

1

I guess you are having 3 primary ( sda1,sda2,sda3), 1 extended (sda4) partitions and sd5 as logical one. with parted , try to resize partition 4.

Example:

parted /dev/sdb

    Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  1049GB  1049GB  primary   ntfs
 2      1049GB  1796GB  747GB   extended
 5      1049GB  1796GB  747GB   logical

(parted) resizepart
Partition number? 2
End?  [1796GB]? 2000GB
(parted) p
Model: WD My Passport 0748 (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  1049GB  1049GB  primary   ntfs
 2      1049GB  2000GB  951GB   extended
 5      1049GB  1796GB  747GB   logical

And now try to add new logical partition, using fdisk or parted whichever you want to use.

With fdisk, you would need to delete sda4, and sd5 and add it again keeping the same beginning , overlapping sda4 and sd5 could create problem.

Note: Keep backup of your data and first understand and test it and do at your own risk Probably below way, but not tested:

  1. Delete partition 4  ( Command (m for help): d and enter number 4 )
     2. Add it again and keep the first sector as old one ( Command (m for help): n, choose extended partition e
        , Partition number 4 , First Sector - 7833 , Last Sector - Default

     3. Add logical partition 5 -
     ( Command (m for help): n, Adding logical partition 5 , choose default for first and last sector 

    4 Modify beginning of logical partition 5 to old value ,  Expert command (m for help): b
    Partition number (1,2,5, default 5):5
    New beginning of data - 7833

    5 print table and verify
4
  • Since I have an extended partition, can't I add a 6th partition? Will I have to delete the partition even if I have extended partition? Sep 5, 2018 at 6:29
  • @Arun , not an extended one, but logical one yes, if you have free space in your extended partition, and you can only have one extended partition i.e 4 in your case, and to create new logical if you say 6 , you would need more space, which will be once you extend your extended partition.
    – Bharat
    Sep 5, 2018 at 6:34
  • also your extended and logical partition beginning is overlapping, i.e 7833, it might be difficult to get that, but you can try , don't save the table
    – Bharat
    Sep 5, 2018 at 6:36
  • may be with parted, you can resize the extended partition easily
    – Bharat
    Sep 5, 2018 at 6:53
0

I found a solution. 1. Increase the extended volume size with parted. - From the command line enter command "parted". No need to unmount the volume or go to rescue mode.

parted

Print the table and see current allocation:

(parted) print
  • resize the extended partition from current size to new available size. In my case it is 100GB

    (parted) resize 4 64.4GB 100GB

  • print and see the new allocation

    (parted) print

  • Now do fdisk partition and create new partition sda6

    fdisk /dev/sda

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .