Saturday, September 23, 2017

Running out of space in main Linux parttion, resize offline, solve screen flicker problem

I was looking for a light weight linux distribution for my old laptop and found this Lubuntu Zetsy. I had thought being lightweight, about 4 GB of Hard disk space would be enough with say 500 MB Swap space.

The main hard disk drive is 100 GB and windows 10 was installed in it. Earlier a 11 GB space was shrunk from this 100 GB drive and formatted as NTFS (Drive D:) This 100 GB drive was further shrunk using disk management utility in Windows 10 to create unallocated space of about 4 GB.

The partition table looks as follows:-


After installing Lubuntu Zetsy in 4 GB space, it was working fine, however, package upgrade messages started appearing, but there was not enough space to upgrade as total size available was only 3.43 GB (488 MB swap). I could ignore these messages but for a fact that subsequent login was taking to black screen and required two or three retries to reach main desktop (say after power save etc). Googling about the problem pointed to fact that upgrading the packages can solve the problem.

I was avoiding upgrading as disk space was minimal, one day I did take the chance and did apt-get upgrade from command line, the upgrade started and midway gave a message of insufficient disk space after about 200 MB of disk space was only left. root user was dismounted and system dropped to initramfs shell. In short, my Linux smoked out  :))

Now, I had to somehow add some storage to this original 4 GB partition. since it was bang adjacent to the 90 GB windows partition, I thought I could shrink some 4 GB from this 90 GB windows partition and add to original 4 GB to make it grow to 8 GB. question was how? and will my data be safe after this exercise? or will the entire thing go in smoke too :))

I decided to backup the complete laptop data onto another desktop just in case. after that, google helped me to zero on GPARTED, the linux utility to resize partitions.  Again, after shrinking 4 GB of unallocated space from Windows, booted using a live CD to Linux for my partition resize operation, this was the actual picture of partitions:-



Following are the step wise observations:-

1. It is only possible to have four primary partitions in MBR scheme of partitioning (sda1, sda4, sda2 & sda3 in my case were already there)

2. Note that the linux partitions sda5 (ext4 filesystem, 3.43 gb) & sda6 (swap, 488 mb) are contained in sda4 which is marked as extended partition.

3. I tried resizing sda5, but it wouldn't budge.

4. As I had booted into linux using live DVD, All hard disk partitions were unmounted by default except swap. A 'lock' symbol was appearing against sda6 & sda4.

5. Right clicked sda6 and clicked the swapoff and lock symbol vanished on sda6 & sda4. Now I could resize sda4 to the unallocated space adjacent. after this, i could resize sda5 which as you can see is inside sda4.

6. A warning was issued by gparted after resizing sda5 that linux may not boot.

7. swapon done on sda6 and lock symbol reappeared on sda4 & sda6.

8. Rt click in lower pane of gparted and click on ' apply all operations'. this is the confirmation step for all changes. it took 5 minutes to complete all operations.


REBOOTING
After Rebooting, GRUB2 boot menu appeared and I selected ubuntu, but same problem reappeared, that is trying to load GUI but failing and not even opening a terminal screen on pressing ctrl + Alt + F1. So, it appears that partition ops are success, now only linux issues need to be troubleshooted.

After turning on laptop, press ESC key continuously, after GRUB2 appears, you can see an extra entry "advance options for Ubuntu". Select this option  and select option of "fix broken packages". dpkg started installing the packages which were left off earlier midway after hard disk space had been exhausted.

After dpkg finished, I rebooted again to GRUB2 main entry ubuntu and everything worked perfectly! Rebooted again to windows an found everything was normal there too!.

So, resized partition offline without any loss of files.








No comments: