LinuxSay - A Discussion Forum for Linux Enthusiasts

How to resize the partition in ext4 filesystem


#1

HI

I want to extend my 6th partition. How can we get it done.

Parted command could not support ext4 filesystem to resize.

Is there any other way to increase or decrease my partition.

Please help me…


#2

You need to boot from external device (USB, CDROM) and use application to resize - the idea is that the disk should not be used durring resize
You can use for example:

http://gparted.org/livecd.php

If you have setup LVM it would be a matter of 2 commands but in your case you need to perform external booting.


#3

@balajitk88

On which Linux distribution you want to resize the partition? I think its CentOS 7?


#4

You are using the ext4 partition for increasing

# resize2fs /dev/sda6 NEWSIZE

#5

@ravisaive

I am using CentOS 6.6 Linux distribution


#6

@balajitk88

Hi if you want to resize the 6th partition by using parted utility you can resize it by using resize parted command, you can increase or decrease the partition size of a partition once look at below
example.


#7

@raghuu

Parted command will support only ext2 filesystem. I am using ext4 filesystem


#8

#9

@balajitk88

Hi you can try gparted instead of parted or you can use cfdisk to resize the partition

#cfdisk /dev/sda

after that delete the partition (6th) no need to worry about your data, it will remain there until using mkfs.ext4 (dont use mkfs.ext4)

Now recreate the same partition with the size you want. But here you must and should give the same sector as the original one otherwise you will loose the data.

Now run resize2fs to resize the filesystem

#resize2fs /dev/sda6


#10

@raghuu

I have the free space in my system. But as you told i have run the command i am getting the error


#11

Pls let us know what to do and how to solve this error


#12

@balajitk88

Dear Balaji

if you have free space fro ex: 2GB on /dev/sda6 then you can reduce it by using the resize2fs /dev/sda6 1G
But for extending please fallow the below steps

  • Unmount the partition /dev/sda6

#umount /dev/sda6

  • Now delete the 6th partition

#fdisk /dev/sda

print the partitions and note the starting sector of the /dev/sda6 partition §
delete the partition /dev/sda6 (d)
save and exit (wq)

  • Recreate the partition /dev/sda6 with more size and with the same sector (starting sector) of /dev/sd6

#fdisk /dev/sda

print the partitions §
create the partition (n)
select the partition type (l)
assign the number to partition (6)

Note: you have to mention only the sectors not M or G
now here you have to give the starting sector of old /dev/sda6
next you can give your won sector based on your size

save and quit (wq)

  • finally you have to resize the file system by using

#resize2fs /dev/sda6

and also once post the output of

#fdisk -l


How to extend the partition size in ubuntu
#13

@raghuu

Thanks for your reply and support


#14

You can resize partition if there is enough space after partition
otherwise you must backup next partition, decrease it, restore it
for LVM, you can add other partition or device