I was trying to resize my partition with parted and resize2fs.
I tried the following:
#parted
Partition Table: msdos
Number Start End Size Type File system Flags
1 2097kB 21.0GB 21.0GB primary ext4 boot
2 21.0GB 500GB 479GB primary ext4
3 500GB 500GB 536MB primary linux-swap(v1)
(parted) rm 2
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? ext4
Start? 41GB
End? 500GB
(parted) q
Information: You may need to update /etc/fstab.
#resize2fs /dev/sda2
resize2fs 1.42.5 (29-Jul-2012)
resize2fs: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
Unfortunately I can't understand why this doesn't work. It was an ext4 partition. I would like to resize the partition without loss of data.
fdisk list before operation:
Device Boot Start End Blocks Id System
/dev/sda1 * 4096 40962047 20478976 83 Linux
/dev/sda2 40962048 975718399 467378176 83 Linux
/dev/sda3 975718400 976764927 523264 82 Linux swap / Solaris
Now fdisk shows:
Device Boot Start End Blocks Id System
/dev/sda1 * 4096 40962047 20478976 83 Linux
/dev/sda2 80078848 975718399 447819776 83 Linux
/dev/sda3 975718400 976764927 523264 82 Linux swap / Solaris