partitioning - Extend Existing Linux partition
2014-07
I had a dual boot hard drive with Windows / Centos 6.5.
I no longer needed Windows so I removed the /dev/sda1 and /dev/sda2 via fdisk. It now looks like:
Device Boot Start End Blocks Id System
/dev/sda3 * 21891 21955 512000 83 Linux
/dev/sda4 21955 31131 73707864 5 Extended
/dev/sda5 21955 21981 204800 83 Linux
/dev/sda6 21981 23511 12288000 82 Linux swap / Solaris
/dev/sda7 23511 31131 61211648 83 Linux
I would like to take the space that was used by Windows and add it to sda7
I have played around with parted,resize2fs,lvextend, etc but I can't seem to figure out exactly how to do this. Can anyone help by providing me with specific fully-working steps/commands?
Thanks!
Before performing this task, it's highly recommended that you backup your data.
You cannot resize the partition under the Operating System working/running from the same partition.
In your case, if the /dev/sda7
is your /
file system from which you work and try to resize it, then you need to boot your machine from different place. You can make live CD, boot the machine from DVD or USB and run gparted
from there.
You can boot from Ubuntu's LiveCD and use GParted on it or download GParted's LiveCD .iso, burn it to a CD and boot into it.
Unmount (if it's mounted) the partition that will be involved in the resize/move operation, /dev/sdaX (by right clicking and selecting unmount from the context menu),
Since the unallocated space is to the left of the ext4 partition you wish to resize, you'll first need to move the partition to the left of the unallocated space, which might cause boot error. Follow GParted's instructions on moving partitions.
As Gparted moves partitions, not unallocated space, it is may be quite complicated task to get your aim. This is because you have a number of partitions. So you probably need to move them all to the left. At the final step your partition /dev/sda7
will be moved and resized (increased).
Moving partitions is a copying itself, so it is going to take many hours. So probably it would be easier to save all critical data as backup to external drive, and then delete all partitions, design a new partitioning, reinstall OS and restore your data from backup.
i am playing with grub and i change the root using:
root (hda,x)
how can i know what's x for /dev/sda7
?
fdisk -l
Device Boot Start End Blocks Id System /dev/sda1 * 1 1958 15727603+ 7 HPFS/NTFS /dev/sda2 1959 7476 44323335 f W95 Ext'd (LBA) /dev/sda5 1959 4569 20972826 7 HPFS/NTFS /dev/sda6 4570 5352 6289416 83 Linux /dev/sda7 6373 7119 6000246 83 Linux /dev/sda8 7120 7476 2867571 83 Linux /dev/sda9 5353 6135 6289416 83 Linux /dev/sda10 6136 6372 1903671 82 Linux swap / Solaris
the problem is that in Gparted view, the order is not like sda5, sda6, sda7, ... but the order is like:
- sda6
- sda9
- sda10
- sda7
- sda8
so what's x for /dev/sda7
?
First off, you need to realize that in grub, it does not use normal linux hard drive identifiers. Instead, the letters correlate to numbers, starting with zero (i.e. hda = hd0, hdb = hd1, etc).
Secondly, the partition number starts at 0, not 1 like in Linux, so subtract 1 from the linux partition number.
An example is: hda1 = (hd0, 0)
Finally, grub does not differentiate between hd and sd devices, so everything is labeled hd.
Thus, in your case, your grub entry for /dev/sda6 should read (hd0, 5)
Easiest way to be sure is from grub cli and using tab completion.
start by typing... root (hd0,
then hit [tab]
The tab completion should then list the partitions available.
pick the one you think makes most sense close off the parentheses and on the next line type
kernel /
then hit [tab] again... if the files and directory structure look right you picked the right one... if not.. back up and redo the root line.