Moving Partitions

I'm having trouble with partitions in Linux Mint 17.2. I have it installed on my ASUS Zenbook UX305FA laptop. The laptop shipped with Windows 8.1, and I originally had the laptop dual-booting to test to see if Linux would work well on it. As a result, the root and swap partitions are on /dev/sda5 and /dev/sda6. When I deleted Windows, there was a large unallocated partition before the Linux partitions and a small partition after it. Unlike in Windows, I am unable to simply expand the root partition to absorb the empty space with Gparted. How would I go about doing this? Currently I have the large empty space set up as another partition, but I would prefer this be combined with the root partition.

The third button on the toolbar is called 'resize/move', use it to move the swap partition forward on the drive, until the free space is after the root partition. Then use it one last time to expand the root partition.

alternatively you can disable swap:

$ sudo swapoff -a

then delete the swap partition, click the resize/move button to expand your root partition the desired amount, and then recreate the swap partition at the end of the drive, and reenable swap by the end:

$ sudo swapon -a
1 Like

I'm planning to move my boot/root partition to the front of the disk this weekend and doing my research I found that I will also have to rebuild grub2 - otherwise the system will not boot up. Does anyone have experience with this and how to do that? Will I have to do it?

indeed you would need to reinstall grub. There are good guides around on how to do that, but not knowing your machine/set-up, I shan't recommend one. One thing I will say is make sure you have a working live usb at the ready, because the only way to know if it worked is to reboot, and if you reboot and it doesn't work, you'll be won't be able to fix grub without a live usb (which are kind of hard to make, when the system doesn't boot).

Another thing, if you're moving windows around in the process, you may find that it breaks the activation.

Adding to @bnorgd's comment, i would have a boot-repair iso on standby in the case of things going tits up.

Ok, so I have moved my boot partition yesterday and here is how:
- boot up your machine from ubuntu live cd usb
- open gparted (sudo gparted)
- move / resize the boot partition
- execute and wait for gparted to finish
- install boot-repair and run recommended repair like described here
- restart and boot to your linux (not the usb one)
- at this stage I have had a problem that grub wouldn't show windows boot option so I just ran update-grub and that fixed it

that was it, thanks

1 Like

@ jackiechamp
Looks like sda2 is empty. The 2.77g usage is probably just .trash file. Foremost: this drive needs to be zeroed and partitioned correctly. the safest bet would be to back-up/copy essentials (personal stuff, dotfiles, /.config contents, etc) to external, run zeros over this drive, format, reinstall your OS, migrate essentials back as appropriate. I assume that wont happen so next best thing would be delete sda2 and absorb it into sda5.(make sure to toggle the drive "bootable" if its not) This will probably take a while, and you could potentially lose data or render the system unbootable. Manipulating blocks like this really stresses the normal operation of the drive and reduces the overall life of the device. Additionally, you are absorbing blocks that were previously allocated to ntfs (.net) without resetting the space. You could agitate existing misalignment/superblock errors. If you proceed and see "bad superblock" errors ...dont be surprised.

Im not familiar with why sda1 is formated to fat32 and is hosting a boot sector. Is this a Mint thing? If so, I imagine they have a reason but seems kind of irrelevant. Where is Grub installed? If all the above works Id move grub and the boot sector in with the rest of the system till you get everything moved and stable. If you delete sda2, expand sda5, after you refresh, the new large sector will be sda2. You can install grub to this sector like this.

from Live cd/usb

sudo su -
TARGET=/media/sda2
mkdir -p $TARGET
mount /dev/sda2 $TARGET
mount --bind /dev $TARGET/dev
mount --bind /dev/pts $TARGET/dev/pts
mount --bind /proc $TARGET/proc
mount --bind /sys $TARGET/sys
cp /etc/resolv.conf $TARGET/etc/
chroot $TARGET /bin/bash

you are now chroot into your drive project

from the updated root terminal

grub-install /dev/sda2
update-grub

To Exit CHROOT

control-D

umount -l $TARGET/dev/pts
umount -l $TARGET/dev
umount -l $TARGET/proc
umount -l $TARGET/sys

reboot into your drive and cross your fingers.

This is the UEFI boot partition, it is required to boot on systems without legacy BIOS