LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   fdisk command and fixing paritions (https://www.linuxquestions.org/questions/linux-server-73/fdisk-command-and-fixing-paritions-934101/)

devUnix 03-12-2012 03:21 PM

fdisk command and fixing paritions
 
From this output, how to determine how much disk space is available for partitioning?

Code:

[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x000dc80a

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          77      614400  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              77        1352    10240000  83  Linux
/dev/sda3            1352        1543    1536000  82  Linux swap / Solaris
/dev/sda4            1543        2611    8580096    5  Extended
/dev/sda5            1543        1671    1024000  83  Linux
/dev/sda6            1671        1735      512000  83  Linux
/dev/sda7            1735        1745      86185  83  Linux
[root@localhost ~]#


"parted" command tells me that in a nice manner:

Code:

[root@localhost ~]# parted
GNU Parted 2.1
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: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End    Size    Type      File system    Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  630MB  629MB  primary  ext4            boot
 2      630MB  11.1GB  10.5GB  primary  ext4
 3      11.1GB  12.7GB  1573MB  primary  linux-swap(v1)
 4      12.7GB  21.5GB  8786MB  extended
 5      12.7GB  13.7GB  1049MB  logical  ext4
 6      13.7GB  14.3GB  524MB  logical  ext4
 7      14.3GB  14.4GB  88.3MB  logical
        14.4GB  21.5GB  7122MB            Free Space

(parted)

One more thing:
Code:

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          77      614400  83  Linux
Partition 1 does not end on cylinder boundary.

How do we fix that?

T3RM1NVT0R 03-12-2012 03:56 PM

@ Reply
 
Hi devUnix,

If you want to find out free space using fdisk then you have to do some calculation. The easiest way I can think of is to convert total space into MB (you can use GB when dealing with large partitions). Divide total space by number of cylinders. This will give you size / cylinder. fdisk show you total number of cylinder. Deduct used cylinder from total number of cylinder this will give you free cylinder. So free space = free cylinder * size per cylinder.

For your next query:

Code:

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          77      614400  83  Linux
Partition 1 does not end on cylinder boundary.

This is quite common error that you get when you create one partition using fdisk and another using parted. This is because the difference between the way these two tools calculate disk space total and the way they see the device.

See below:

Code:

#fdisk /dev/sdc

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/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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: 0x000598c0

  Device Boot      Start        End      Blocks  Id  System
/dev/sdc1              1        132    1060258+  83  Linux
/dev/sdc2            133        249      937984  83  Linux
Partition 2 does not end on cylinder boundary.

Command (m for help):

I have created partition 1 using fdisk and partition 2 using parted. When I get into fdisk I can see the same error reported by fdisk on the partition that I have created using parted.

I would recommend that you use one tool only when you are creating partition on a disk.

PTrenholme 03-12-2012 04:35 PM

To fix the partition order (if you feel a need to do so), umount the drive, start fdisk on the drive, go to the "expert" menu, run the "fix" command, write out the fixed partition table, and remount the disk.

Note that the partition order is of no particular significance, as suggested by T3RM1NVT0R, above.

syg00 03-12-2012 05:08 PM

Quote:

Originally Posted by devUnix (Post 4625085)
Code:

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          77      614400  83  Linux
Partition 1 does not end on cylinder boundary.

How do we fix that?

Nothing to fix.
That is an informational message, not an error - it's not even a warning in the strictest sense. Use an older version of fdisk, and you won't even see it.

Partition alignment was never an issue until (relatively) recently - probably still isn't an issue for most home users. As newer (4k sector) disks get more common, even cylinder alignment should be forgotten.

techguru666 08-24-2012 11:45 AM

You can check this quick link for tutorial on fdisk command.

http://www.expertslogin.com/linux-ad...stem-on-linux/


All times are GMT -5. The time now is 04:41 AM.