I'm a new user of Ubuntu and when I have install it, it takes the whole hard-disk space. When I tried to divide the hard-disk using Gparted partition Editor from external Ubuntu on USB, I found what you can see on the following screenshot. I can't divide the hard disk.
Can anybody helps me?
As we can see on the screen shot from the question you are currently using LVM on the partition
/dev/sda5. Gparted have limited support of LVM and this is the reason to show it as full while in fact it is not full.
If this is a new installation the easiest way is to backup your user's files, reinstall the OS and split the disk during the installation process - but this is another question. Otherwise backup your user's files and follow the next steps on your own risk.
Here is short manual how to shrink this partition step-by-step. I'm assuming you are running Live Ubuntu from an installation CD/USB and you want to resize the existing Ubuntu installation. For the current example I'm using virtual machine (powered by VMWare) and some outputs could be slightly different from the real situation.
Investigate your LVM setup
There are two basic terms:
VG- volume group - that you can imagine as equivalent of the entire free space (disk drive) within LVM.
LV- logical volume - that you can imagine as equivalent of partition.
Open new terminal window and execute the command
sudo lvsthat will output all VGs and their LVs. If you've used the automatic installation process of Ubuntu the output should be as the follow.
Here we have
swap_1and another one called
root, that we want to resize.
To output the current characteristics of the
rootLV you can use the command
sudo lvdisplay /dev/ubuntu-vg/root. To check the free space on this LV you can use
df -h /dev/ubuntu-vg/root, but first you should mount it:
We can see there is 16G free space. Here is what Gparted shows for this installation at this point (it is identical with your case):
Shrink the partition
The main source of this part is the article How to Extend/Reduce LVM’s on TechMint. The first advice given there is: Before starting, it is always good to backup the data, so that it will not be a headache if something goes wrong.
Here we will reduce the
rootlogical volume, then will move
swap_1into the beginning of the free space within the volume group and then we will resize
1. Mount the file system and defragment it:
2. Unmount the file system for reducing (check if it is unmounted by the command:
3. Check for the file-system error using following command (the test must pass in all 5 steps; 0.1-1% of non-contiguous files will give us good chance to reduce the file-system):
4. Reduce the file-system with 5G (for this example) and Reduce the LV with 5GB:
5. Resize the file-system back and check for the file-system errors:
If there is any error that means the file-system is corrupted and maybe we should reinstall and use our backup. If there is no error the process should be successfully finished. Note: At this point you could create another LV.
6. Move the free space out of VG. The command
pvscould show us where the free space is located within the partition
/dev/sda5. In this example the swap is to the end, so we will delete and create it again (using its PE size), thus it will be moved into the begging of the free space.
7. Now you can use some tool like Gparted to resize the partition
/dev/sda5and create a new one or leave the space unallocated to use it for the another OS installation.
Note the small gap of empty space that we commit due to incorrect calculations. We can make more precise calculations (honestly I've lost my self within GB, G and GiB) or we can add it to some of the LVs by a command as this:
sudo pvs -v --segments /dev/sda5to investigate the new state.
8. Now you can reboot the system. Within the example I created one NTFS partition -
/dev/sda6, shown on the next image.
9. The final step is to enable the swap (as it is show on the picture above):
How to Extend/Reduce LVM’s (Logical Volume Management) in Linux – Part II
Reduce the size of an LVM logical volume
How to reduce Volume Group size in LVM?
Move free space out of LVM
How to Defragment Linux Systems