This is my disk layout. I want to expand /dev/sda2 to occupy all the free space

I'm running this command from a live session:

sudo resize.f2fs -t 449984510 /dev/sda2

I realize that something is missing:

resize.f2fs [ -t target sectors ] [ -d debugging-level ] device

Maybe it is:

resize.f2fs -t /dev/sda2 449984510 /dev/sda

Sorry but the manual is confusing and short

And this is the output I get:

Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 223944704 (109348 MB)
Info: MKFS version
  "Linux version 4.10.0-28-generic (buildd@lgw01-12) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017"
Info: FSCK version
  from "Linux version 4.10.0-19-generic (buildd@lcy01-13) (gcc version 6.3.0 20170321 (Ubuntu 6.3.0-10ubuntu1) ) #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017"
    to "Linux version 4.10.0-19-generic (buildd@lcy01-13) (gcc version 6.3.0 20170321 (Ubuntu 6.3.0-10ubuntu1) ) #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017"
Info: superblock features = 0 : 
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 223944704 (109348 MB)
Info: CKPT version = 1b43

enter image description here

Here's the sector info on the partitions:

sudo fdisk -l /dev/sda
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3fff99f8

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048   2099199   2097152     1G 83 Linux
/dev/sda2         2099200 284313599 282214400 134.6G 83 Linux
/dev/sda4       452085760 468860927  16775168     8G 82 Linux swap / Solaris
share|improve this question
    
According to gparted.org you won't be able to use their program to do this: You will need to learn to use the command line tools for that purpose, and probably this cannot be done while the disk is mounted. – Charles Green Oct 12 '17 at 21:27

From your original three partition setup, you simply needed to first expand the partition sda2 to the 452083711 sector, then expand the filesystem. Adding another partition in the free space will not work, the filesystem has no room to expand. Now gparted will allow increasing the size of a running filesystem at the end, but not sure if f2fs will work (ext? definietly will). So use gparted to expand the partition, then run your resize.f2fs like you did.


In gparted, I think you can just drag the right end of the partition into the unallocated space. The start of the new, bigger partition is the same as the current sda2 start, 2099200, and the end will be the end of what sda4 was, 452083711. With that start,end, you can run a command line tool like fdisk , (assuming you have already deleted sda4), and edit the end of sda2. I think it would be OK to delete the old sda2 (note type too), then make a new sda2 with the new numbers. As long as the start of the partition does not change, the filesystem will be recognized. Now with a larger partition, you can expand the filesystem, which may have to be done offline for f2fs (ext4 could be left online).


I don't see resize.f2fs in the Ubuntu 16.04 f2fs-tools package,nor any other package. If the documented syntax does not work, you might try the resize with the filesystem unmounted, or worst case, backup, then remake the filesystem full size, then restore.

mkfs.f2fs /dev/sda2 449984511
share|improve this answer
    
Please add the example to this case, basically what the command would be – userDepth Oct 13 '17 at 22:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.