2

I have a disk with the following partitions:

GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free                                                       
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 85.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
        0.00B   511B    512B              Free Space
 1      512B    4302MB  4302MB  primary   ext3            type=83
 2      4302MB  15.0GB  10.7GB  primary   ext3            type=83
 3      15.0GB  15.2GB  140MB   primary   linux-swap(v1)  type=82
 4      15.2GB  85.9GB  70.7GB  extended                  type=05
 5      15.2GB  16.3GB  1078MB  logical                   type=83
 6      16.3GB  75.1GB  58.8GB  logical                   type=83
 7      75.1GB  85.8GB  10.7GB  logical   ext3            type=83
 8      85.8GB  85.9GB  70.3MB  logical                   type=83
        85.9GB  85.9GB  3545kB            Free Space
        85.9GB  85.9GB  2747kB            Free Space

The question is why there are two "Free Space" rows shown in the parted output? Is this normal or is it some problem related to the initial partitioning of the disk? If it is OK, then how can I merge them into one using parted?

Here is the output for fdisk -l /dev/sda

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders, total 167772160 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: 0x00002eb8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1     8401994     4200997   83  Linux
/dev/sda2         8401995    29382884    10490445   83  Linux
/dev/sda3        29382885    29655989      136552+  82  Linux swap / Solaris
/dev/sda4        29655990   167766794    69055402+   5  Extended
/dev/sda5        29655991    31760504     1052257   83  Linux
/dev/sda6        31760506   146641319    57440407   83  Linux
/dev/sda7       146641321   167622209    10490444+  83  Linux
/dev/sda8       167622656   167759871       68608   83  Linux
  • What does fdisk -l /dev/sda have to say about it? – slm Dec 28 '13 at 21:21
  • Searching on this I found this SO Q that one of the answers showed as having multiple "Free Space" areas, they're probably just free space that isn't contiguous. stackoverflow.com/questions/12313384/… – slm Dec 28 '13 at 21:33
  • I don’t have access to the system now. Will try the command later. – coffeMug Dec 28 '13 at 21:48
  • OK, the fact that it's showing 2 different sizes would lead me to believe that those are in fact 2 blocks of free space. – slm Dec 28 '13 at 22:02
  • Oh! There is also another one in the beginning of the partition table. I have not noticed that one. :-| – coffeMug Dec 28 '13 at 22:08
1

In looking at your output I'm thinking that you have several chunks of sectors that are not contiguous, and so when you print your partitions in parted these chunks are showing up as multiple blocks of free space.

The default output of parted makes this difficult to see so I'd suggest changing the units from size based (kB, MB, GB, etc.) to sectors. You can use the command unit s within parted interactively or you can change it when you invoke it.

Examples

Here's the default view on my Fedora 19 system.

$ sudo parted /dev/sda
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: ATA ST95005620AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  525MB  524MB  primary  ext4         boot
 2      525MB   500GB  500GB  primary               lvm

(parted)                                                                  

Now we can change the units like so:

(parted) unit s                                                           
(parted) print                                                          
Model: ATA ST95005620AS (scsi)
Disk /dev/sda: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start     End         Size        Type     File system  Flags
 1      2048s     1026047s    1024000s    primary  ext4         boot
 2      1026048s  976773119s  975747072s  primary               lvm

(parted)                                             

Or we can make it the default when we invoked parted like so:

$ sudo parted /dev/sda unit s print
Model: ATA ST95005620AS (scsi)
Disk /dev/sda: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start     End         Size        Type     File system  Flags
 1      2048s     1026047s    1024000s    primary  ext4         boot
 2      1026048s  976773119s  975747072s  primary               lvm

$

Consolidating the free space

If this is the case then you'll need to use dd or gparted to move whatever partition happens to be causing this free space to be split up, so that you can make use of it.

I would've thought you could do this with parted but in researching how to do this it appears the move command was removed from version 2.4 and higher of parted.

excerpt from parted docs

Note that after version 2.4, the following commands were removed: check, cp, mkfs, mkpartfs, move, resize.

NOTE: Here's also a thread titled: Resizing/moving partition with parted-3.0 where one of the developers discussed the rational for why these commands were removed.

Details on doing this move using dd are covered here in this SU Q&A titled: How to move a partition in GNU/Linux?.

However I would encourage you to do this operation using gparted instead. I've done it several times using gparted and have never run into any problems, since it does much of the heavy lifting for you. Using dd & fdisk though possible, can be tricky.

This tutorial should get your started with doing this operation using gparted, titled: Modify Your Partitions With GParted Without Losing Data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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