Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I just decided to delete my Windows partition and only use Linux.

My old partition table was:

  • sda1: W7 boot partition
  • sda2: W7 partition
  • sda3: Linux
  • sda4: start of logic partitions
  • sda5: swap.

I deleted sda1 and sda2, and then expanded sda3. Now my partition table is:

  • sda3: Linux
  • sda4: start of logic partitions
  • sda5: swap

I would like to change the sda3 to sda1, how?

Also my fstab keep showing me the old Windows partition:

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>

proc    /proc   proc    defaults    0   0
#Entry for /dev/sda3 :
UUID=059c7142-b4d8-4ab0-8d0f-ee460fce905e   /   ext4    rw,errors=remount-ro    0   1
#Entry for /dev/sdb1 :
UUID=5632BCEF32BCD569   /media/Datos    ntfs-3g defaults,locale=en_US.UTF-8 0   0
#Entry for /dev/sda2 :
UUID=60D8A6E5D8A6B8A4   /media/Windows  ntfs-3g defaults,locale=en_US.UTF-8 0   0
#Entry for /dev/sda5 :
UUID=53cd360a-1321-497f-8c3a-ff3adf4cf82c   swap    swap    sw  0   0
share|improve this question
    
Looks like you already reinstalled, but why do you care how the partitions are labelled? –  haziz Dec 3 '12 at 8:20
    
just a matter of order. –  yzT Dec 3 '12 at 10:19

3 Answers 3

First of all, if you have moved the beginning of the partition, chances are rather high, that you can only wave the filesystem there goodbye. The reason is, that the beginning of a filesystem usually contains a very important data structures (usually called supeblock) without which the data in the filesystem is inaccessible. Maybe some utility exists that could move the superblock and fix the filesystem (because sectors numbers, which are used for data addressing in the end, would change since these are counted from the beginning of the partition), but I would be very cautious about using any such thing. Especially if you intended to use it on a mounted partition.

If you did it on a living system, the kernel still has the old partition table cached and will create a new one on reboot (it can reread it when no partitions are mounted on the device - you can request this e.g. with hdparm -z). If you still can get the old patition boundaries (sector-exact) somewhere I would recommend to reset it and retry as described below. If you don't have the information any more, there are utilities that try to find out the original partitions boundaries by scanning the disk for superblocks (or probably by checking the kernel cached data).

That said, the correct way to do the resize is:

  1. copy filesystem from /dev/sda3 to /dev/sda1 - either file by file, or with a dump utility, or directly with dd if the destination is bigger than source with. In the last case, you should extend the filesystem as described later.

  2. fix all important references in the filesystem on /dev/sda1 from /dev/sda3 to /dev/sda1 - this includes:

    • bootloader configuration

      • where to find kernel to boot

      • kernel option root= which tells the kernel what partition to mount as /

    • /etc/fstab - you must do this by hand - again there could be a utility for that, but for this type of things, I wouldn't rely on it.

  3. boot from /dev/sda1

  4. either extend /dev/sda1 to cover /dev/sda2 and /dev/sda3 or repartition the now unused space spanned by those. If extending, use the utility for your filesystem to grow it at the end (for EXT2/3 this would be resize2fs, for XFS xfs_growfs etc.).

  5. update /etc/fstab again if necesary.

Renumbering: fdisk has fix partition order (in the extra functionality sub-menu), gdisk has sort partitions (in the main menu). Then you have to check /etc/fstab and possibly also the bootloader configuration again to see whether any intervention is needed.

share|improve this answer
    
I have done the partition move/resize already without any problem with Gparted. The problem I'm facing is the order and fdisk doesn't help. </br> Expert command (m for help): f Nothing to do. Ordering is correct already. –  yzT Dec 2 '12 at 1:04
1  
In that case (correct ordering), you can remove the partition (sda3) and create a new one (sda1) with exactly the same boundaries. Be careful to use a utility that won't destroy the filesystem in the area though. –  peterph Dec 2 '12 at 10:29
2  
Or just leave it as it is. It really doesn't matter that much and you are probably not going to touch it for the next couple of years anyway. –  peterph Dec 2 '12 at 11:26
    
I ended reinstalling the system. It's all fine now. –  yzT Dec 2 '12 at 14:16

You have to manually remove entries from /etc/fstab. Why do you care what the partition number is anyhow? It doesn't really matter, but if you really want to, you can use fdisk in sector mode ( use -u or the u command ) to list the current partitions, delete them, and recreate them with different numbers, but the same start and end sectors.

share|improve this answer
    
Command (m for help): u Changing display/entry units to cylinders (DEPRECATED!) I think I'm going to install the system again today, nothing better to do xD –  yzT Dec 2 '12 at 9:47

The dangerous way to do it is to play with gpart or TestDisk... (TestDisk has actually been updated in the last 10 years...)

It will look through the disk for partitions and propose a new partition table based on what it finds. It is meant to be used if you somehow lost a partition table, but should work for this as well.

sda5 would be harder, since it is an extended partition, but you might just as well delete it and recreate it.. (since it is a swap partition)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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