Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
fdisk issue - setting the partition start to other positions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
bastibasti
Guru
Guru


Joined: 27 Nov 2006
Posts: 568

PostPosted: Mon Jul 11, 2016 2:16 pm    Post subject: fdisk issue - setting the partition start to other positions Reply with quote

Hi,

I am trying to increase my root (sda6) partition of a vmware box while it is up.

My idea was:
- Delete all partitions
- Recreate the partitions at the same starting position as before (increasing p2 and p6)
-> sda6 is the last partition -> size increased
- reboot
- rise ext4 fs

however I hit some issues trying to set the same starting positions of the partitions

as you can see fdisk wont allow me to set the same starting position of sda6 and for sda2 i already have to correct the starting position manually. Why is that?

Code:


Command (m for help): p
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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
Disklabel type: dos
Disk identifier: 0x9b4179ac

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *         63     80324     80262 39.2M 83 Linux
/dev/sda2         80325 104856254 104775930   50G  5 Extended
/dev/sda5         80388   4289354   4208967    2G 82 Linux swap / Solaris
/dev/sda6       4289418 104856254 100566837   48G 83 Linux

Command (m for help): d
Partition number (1,2,5,6, default 6): 6

Partition 6 has been deleted.

Command (m for help): d
Partition number (1,2,5, default 5): 5

Partition 5 has been deleted.

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 2):
First sector (80325-209715199, default 81920): 80325
Last sector, +sectors or +size{K,M,G,T,P} (80325-209715199, default 209715199):

Created a new partition 2 of type 'Extended' and of size 100 GiB.

Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (82373-209715199, default 83968): ^C
Back to top
View user's profile Send private message
bstaletic
Apprentice
Apprentice


Joined: 05 Apr 2014
Posts: 225

PostPosted: Mon Jul 11, 2016 2:34 pm    Post subject: Reply with quote

Fdisk is not denying you anything. It's just notifying you that you cant make a primary partition and proceeds with questioning you about the partition creation.

With MBR you can only have up to 4 primary partitions, or 3 primary and 1 extended. Besides that, size of those partitions can't be larger than the total size of the disk. What you've done is you've allocated all disk space to the extended partition, minus the sda1.

Now extended partition is just a workaround for some MBR shortcomings. The space allocated to extended partition can be "devided" into logical partitions. This is what fdisk is saying and just informing you about it.

Nowdays there's an alternative to MBR that doesn't have the aforementioned partition number limit and is called GPT.
Back to top
View user's profile Send private message
bastibasti
Guru
Guru


Joined: 27 Nov 2006
Posts: 568

PostPosted: Mon Jul 11, 2016 2:39 pm    Post subject: Reply with quote

The issue is that fdisk seems to need more space inbetween the partitions compared to the older fdisk version i created the disk 10 years ago with.
The sda6 must be spot on the same starting sector otherwise the system cannot boot.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2970
Location: Germany

PostPosted: Mon Jul 11, 2016 2:59 pm    Post subject: Reply with quote

it's probably because your partitions aren't aligned. (which is fine if your disk has physical sector size of 512 bytes)

consider using parted? it has a `resizepart` command which leaves the start sector alone, just gives a new end sector. You can also specify start and end as sectors (63s), you will have to tell it to ignore the alignment but it will create the partition for you as requested. use `unit s`, `print free` to see what is available. note that parted modifies the partition table live - it does not ask you to save.

another possibility would be sfdisk where you can put a dump of the partition table in a text file and edit that. not sure how strict it is about making aligned partitions though.
Back to top
View user's profile Send private message
bstaletic
Apprentice
Apprentice


Joined: 05 Apr 2014
Posts: 225

PostPosted: Mon Jul 11, 2016 3:00 pm    Post subject: Reply with quote

Sorry, I didn't read the sector numbers carefully.

You have successfully created thenew extended partition starting at 80325. But none of your logical partitions begin at that sector. Your swap partition starts at sector 80388, and your sda6 at 4289418.

So you should be trying to recreate the partition at 80388, but even then you wouldn't be able to access the data, as metadata relevant to the partition beginning at 80388 says it's a swap partition not one of type 83 (ext4 formated?). The metadata you need are tied to the partition beginning at 4289418.

The only way to "expand" your partition I see is to make a backup, reformat and restore the files.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43186
Location: 56N 3W

PostPosted: Mon Jul 11, 2016 7:09 pm    Post subject: Reply with quote

bastibasti,

Its a bit more complex with logical partitions. That's the ones created inside the extended partition.

You are correct to delete the logical partitions, then the extended partition to start.
Then create the extended partition but bigger with the same starting sector.

Since you created your original partition table, fdisk has been 'improved' to enforce alignment by default.
It has an expert mode that will let you do what you want.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Irre
Guru
Guru


Joined: 09 Nov 2013
Posts: 340
Location: Stockholm

PostPosted: Mon Jul 11, 2016 7:31 pm    Post subject: Reply with quote

Why not delete partitions and create 4 primary partitions:
Code:
/dev/sda1  *         63     80324     80262 39.2M 83 Linux
/dev/sda2         80388   4289354   4208967    2G 82 Linux swap / Solaris
/dev/sda3       4289418 104856254 100566837   48G 83 Linux
/dev/sda4       104856358   ? ? ? 83 Linux (let fdisk calculate)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum