1

Topic: Gparted can't shrink linux partition

I'm trying to shrink my `home` partition, and use that space to extend my `root` partition.

I have booted using LiiveCD and I'm using GParted to make changes to Ubuntu image installed on a hard disk.

This is my hard drive :

Device                 Start           End       Sectors         Size               Type
/dev/sde1            2048           487423        485376             237M          Linux filesystem
/dev/sde2          487424         29784063      29296640           14G            Linux filesystem
/dev/sde3        29784064        37783551       7999488           3.8G          Linux swap
/dev/sde4        37783552        38369279       585728             286M         EFI System
/dev/sde5        38369280        234452991     196083712       93.5G        Linux filesystem

Here, `/dev/sde2` is my `root` partition, and `/dev/sde5` is my `home` partition.

On trying to `move/resize` `/dev/sde5` to shrink it to 40GB, it gives the error:

Please run 'e2fsck -f /dev/sde5' first

Running that gives me the result:

e2fsck 1.45.5 (07-Jan-2020)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sde5: 346311/6127616 files (0.9% non-contiguous), 5783486/24510464 blocks

This is the saved log from GParted :

GParted 1.0.0

configuration --enable-libparted-dmraid --enable-online-resize

libparted 3.3

========================================
Device:    /dev/sda
Model:    ATA Samsung SSD 850
Serial:    S3NYNF0JA56023F
Sector size:    512
Total sectors:    488397168
 
Heads:    255
Sectors/track:    2
Cylinders:    957641
 
Partition table:    msdos
 
Partition    Type    Start    End    Flags    Partition Name    File System    Label    Mount Point
/dev/sda1    Primary    2048    1187839    boot        ntfs    System Reserved    
/dev/sda2    Primary    1187840    488394751            ntfs        

========================================
Device:    /dev/sdb
Model:    ATA TOSHIBA MQ01ABD1
Serial:    96JNTZN7T
Sector size:    512
Total sectors:    1953525168
 
Heads:    255
Sectors/track:    2
Cylinders:    3830441
 
Partition table:    msdos
 
Partition    Type    Start    End    Flags    Partition Name    File System    Label    Mount Point
/dev/sdb1    Primary    2048    1953523711            ntfs    Local Disk    

========================================
Device:    /dev/sdd
Model:    Generic Flash Disk
Serial:    none
Sector size:    512
Total sectors:    15728640
 
Heads:    255
Sectors/track:    2
Cylinders:    30840
 
Partition table:    none
 
Partition    Type    Start    End    Flags    Partition Name    File System    Label    Mount Point
/dev/sdd    Unpartitioned    0    15728639            iso9660    Ubuntu 20.04.1 LTS amd64    

========================================
Device:    /dev/sde
Model:    StoreJet Transcend
Serial:    174265450211
Sector size:    512
Total sectors:    234455040
 
Heads:    255
Sectors/track:    2
Cylinders:    459715
 
Partition table:    gpt
 
Partition    Type    Start    End    Flags    Partition Name    File System    Label    Mount Point
/dev/sde1    Primary    2048    487423            ext4        
/dev/sde2    Primary    487424    29784063            ext4        
/dev/sde3    Primary    29784064    37783551    swap        linux-swap        
/dev/sde4    Primary    37783552    38369279    boot, esp        fat32        
/dev/sde5    Primary    38369280    234452991            ext4        

========================================
Shrink /dev/sde5 from 93.50 GiB to 48.83 GiB  00:00:10    ( ERROR )
         
calibrate /dev/sde5  00:00:01    ( SUCCESS )
         
path: /dev/sde5 (partition)
start: 38369280
end: 234452991
size: 196083712 (93.50 GiB)
check file system on /dev/sde5 for errors and (if possible) fix them  00:00:09    ( SUCCESS )
         
e2fsck -f -y -v -C 0 '/dev/sde5'  00:00:09    ( SUCCESS )
         
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

346311 inodes used (5.65%, out of 6127616)
2770 non-contiguous files (0.8%)
186 non-contiguous directories (0.1%)
# of inodes with ind/dind/tind blocks: 0/0/0
Extent depth histogram: 345683/75
5783486 blocks used (23.60%, out of 24510464)
0 bad blocks
5 large files

302064 regular files
43687 directories
0 character device files
0 block device files
0 fifos
0 links
551 symbolic links (545 fast symbolic links)
0 sockets
------------
346302 files
e2fsck 1.45.5 (07-Jan-2020)
shrink file system  00:00:00    ( ERROR )
         
resize2fs -p '/dev/sde5' 51200000K  00:00:00    ( ERROR )
         
resize2fs 1.45.5 (07-Jan-2020)
Please run 'e2fsck -f /dev/sde5' first.

Can you please help me out ?

2

Re: Gparted can't shrink linux partition

As a first action: be sure to perform a proper shutdown of the operating system (no sleep / hibernation) before booting into the GParted LiveCd. 

Further step (if the above one doesn't work), run the command 'e2fsck -f /dev/sde5' from a terminal window (as root or sudo if needed). Be sure to use the right drive letter (e in this case). It can change if you change the connectors where the various hard disks are connected.

*** It is highly recommended to backup any important files before doing resize/move operations. ***

3

Re: Gparted can't shrink linux partition

I see that you already ran e2fsck.
Sometimes shrinking a partition to a very smaller size (as in this case) gives error. You can try to shrink it in more smaller steps, for example from 93.5G to 75-80G, then to 60-65G etc.

*** It is highly recommended to backup any important files before doing resize/move operations. ***