Since 90% of my computer time i spent on Ubuntu, i needed more space and the only easy way was to shrink a Windows partition, format the new partition ext4 (Linux file system) and mount it in Ubuntu.
The setup before:
- dual-boot Linux/windows
- Linux partitions:
- root partition – /
- swap partition
- home partition – /
- Windows partitions:
- system – C:
- data partitions – D:
So i wanted to shrink the D: drive, minus 80 GB and use that 80 GB as a Linux partition and this is what i have done:
- FIRST BACKUP YOUR DATA on the partition you want to shrink. (A little secret…i skipped this part but don’t do that, you won’t be that like maybe)
- Back in Linux, install GParted if it’s not installed. The most easy way is to go to Applications > Ubuntu Software Center > [here search for gparted and hit Install]
- MAKE SURE THAT THE PARTITION YOU WANT TO SHRINK IS NOT MOUNTED, IF IT IS, UNMOUNT IT (in Nautilus, right click > Unmount).
- After install, start GParted (it should be in Applications > Accessories)
- You will now see all your partitions being Linux or Windows, explore this. You should see the partitions like /dev/sda1, /dev/sda2 etc. for how many partitions yo have. EG: if you have 8, our new partition will be /dev/sda9.
- Right click on the partition you want to shrink and click on Resize/Move
- You will see a left arrow at the beginning of the partition and a right arrow at the end of the partition. Drag the right arrow to the left to the desired size. Make sure that there will still be some free space on the shrinked partition. You can setup this visually or enter the desired values. Play a little with the arrows and watch the values updating.
- when you are ready, hit OK, and you should see the new shrinked partition with the new size and some unallocated space (this will be the new Linux partition)
- while we are still here, right click on the “Unallocated Space” and Format (i did an ext4 file system and put a name (like DATA) for the partition on the Label field), hit OK
- at the bottom of GParted you will see 2 tasks pending, the first is the resizing and the second is the formatting of the new partition
- if you are ready, hit apply (the green check mark at the top of GParted)
- wait till the magic happens
- now in GParted you should see the shrinked partition and our brand Linux partition (EG: the sda9 partition above)
- we now have the let’s say /dev/sda9 partition with the label DATA
- open a Terminal and type: sudo fdisk -l, and it should list all you partitions, including the new one
- to permanently have the DATA partition mounted we need to make a directory and mount the new partition there
- in the Terminal type this: sudo mkdir /data
- then type: ls -l /dev/disk/by-uuid
- this will list your partitons UUID. I have something like this:
- lrwxrwxrwx 1 root root 10 2010-10-15 20:56 3dc8c97a-76e2-4176-a3ae-2aa7bca80067 -> ../../sda7
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 46183BE7183BD521 -> ../../sda5
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 51148f5b-e51f-4dde-af92-84e3fbc1ae2f -> ../../sda9
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 72A427B4A42779AD -> ../../sda1
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 759C-E00A -> ../../sdg1
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 77234bd3-2683-4fb1-b798-82271750058e -> ../../sda8
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 A163-5F05 -> ../../sdb1
lrwxrwxrwx 1 root root 10 2010-10-15 20:56 e108dced-77d6-4530-ad35-228b698cdc1e -> ../../sda6
- see the new sd9 and the bold red UUID. Copy that on the clipboard.
- now you have to edit the fstab (the file with the partitions and mounting settings)
- first backup it: sudo cp /etc/fstab /etc/fstab_backup
- open for edit fstab (i use gvim, you can use whatever text editor you like):
- sudo gvim /etc/fstab
- and add a line like this:
- UUID=56 51148f5b-e51f-4dde-af92-84e3fbc1ae2f /data ext4 defaults 0 0
- the red UUID should be yours and corresponding to your new partition, the one you get at step 18
- save and close the file
- tell Linux to be aware of the new changes:
- in Terminal type: sudo mount -a
- now you have to link your user to the mount point (the directory created in step 17) and the partition, and to give read/write permissions for the mount point:
- sudo chown -R yourusername:yourusername /data
- sudo chmod -R 755 /data
Now open Nautilus and go to File System (the root), where you should see the /data directory. Drag this to the left to make a shortcut to the mount point/partition for easy accessing.
That’s it ! Seems complicated but it’s not, next time you will do it in no time.
PS: no windows partitions were harmed during the process.