[Trilug-ontopic] how to shrink superblock?

Tom Roche Tom_Roche at pobox.com
Mon Aug 8 08:56:39 EDT 2011


summary: while in latest GParted liveCD, examining an ext3 partition/filesystem:

user at debian:~$ sudo e2fsck -fy /dev/sda6
> e2fsck 1.42-WIP (02-Jul-2011)
> The filesystem size (according to the superblock) is 54871597 blocks
> The physical size of the device is 54871342 blocks
> Either the superblock or the partition table is likely to be corrupt!
> Abort? yes
user at debian:~$ sudo resize2fs -f /dev/sda6
> resize2fs 1.42-WIP (02-Jul-2011)
> Resizing the filesystem on /dev/sda6 to 54871342 (4k) blocks.
> resize2fs: Attempt to read block from filesystem resulted in short read while trying to resize /dev/sda6
> Please run 'e2fsck -fy /dev/sda6' to fix the filesystem
> after the aborted resize operation.

How to make superblock report size=54871342 (the smaller value)?

details:

I've got an ubuntu lucid box with a single HD:

$ lsb_release -ds
> Ubuntu 10.04.3 LTS
$ uname -rv
> 2.6.32-33-generic #71-Ubuntu SMP Wed Jul 20 17:27:30 UTC 2011[/code]
$ sudo fdisk -l -u
> Disk /dev/sda: 250.1 GB, 250059350016 bytes
> 255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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
> Disk identifier: 0x0009c48f

Its partitions are
/dev/sda1  /
/dev/sda5  swap
/dev/sda6  /home

>    Device Boot      Start         End      Blocks   Id  System
> /dev/sda1   *           1    29296875    14648437+  83  Linux
> /dev/sda2        29296876   488397167   229550146    5  Extended
> /dev/sda5        29296877    36837890     3770507   82  Linux swap / Solaris
> /dev/sda6        36837892   475808627   219485368   83  Linux
$ sudo parted /dev/sda unit s print
> Model: ATA ST9250410AS (scsi)
> Disk /dev/sda: 488397168s
> Sector size (logical/physical): 512B/512B
> Partition Table: msdos
>
> Number  Start      End         Size        Type      File system     Flags
>  1      1s         29296875s   29296875s   primary   ext3            boot
>  2      29296876s  488397167s  459100292s  extended
>  5      29296877s  36837890s   7541014s    logical   linux-swap(v1)
>  6      36837892s  475808627s  438970736s  logical   ext3

The swap partition is too small (hibernation often fails), and the root
partition could use more free space, so I attempted to perform the
following actions in a GParted 0.9.0-7 (latest stable) liveCD:

1 Move /dev/sda6 [home] to the right and shrink it.
  This should produce unallocated space between /dev/sda5 and /dev/sda6.

2 Move /dev/sda5 [swap] to the right and grow it.
  This should consume most of the unallocated space, placing the
  remainder at the beginning of /dev/sda5, which is at the beginning of /dev/sda2.

3 Move /dev/sda2 [extended] to the right and shrink it.
  This should produce unallocated space between /dev/sda1 and /dev/sda2.

4 Grow /dev/sda1 [root].
  This should consume the unallocated space between /dev/sda1 and /dev/sda2.

Unfortunately step 1 failed with the error (in GParted)

> check file system on /dev/sda6 for errors and (if possible) fix them  00:00:01    ( ERROR )
> e2fsck -f -y -v /dev/sda6
> The filesystem size (according to the superblock) is 54871597 blocks
> The physical size of the device is 54871342 blocks
> Either the superblock or the partition table is likely to be corrupt!
> Abort? yes
> e2fsck 1.42-WIP (02-Jul-2011)[/code]

The physical size=54871342 looks correct, so I'm guessing GParted
correctly resized the partition, but then was unable to write the
superblock. Unfortunately, neither can I. While mounted (i.e. in lucid),
for the helluvit, I tried

me at it:~$ sudo resize2fs -f /dev/sda6
> resize2fs 1.41.11 (14-Mar-2010)
> Filesystem at /dev/sda6 is mounted on /home; on-line resizing required
> On-line shrinking from 54871597 to 54871342 not supported.

So I rebooted the liveCD and ran

user at debian:~$ sudo resize2fs -f /dev/sda6
> resize2fs 1.42-WIP (02-Jul-2011)
> Resizing the filesystem on /dev/sda6 to 54871342 (4k) blocks.
> resize2fs: Attempt to read block from filesystem resulted in short read while trying to resize /dev/sda6
> Please run 'e2fsck -fy /dev/sda6' to fix the filesystem
> after the aborted resize operation.
user at debian:~$ sudo e2fsck -fy /dev/sda6
> e2fsck 1.42-WIP (02-Jul-2011)
> The filesystem size (according to the superblock) is 54871597 blocks
> The physical size of the device is 54871342 blocks
> Either the superblock or the partition table is likely to be corrupt!
> Abort? yes

So `resize2fs` and `e2fsck` are not playing well together. How to fix
the superblock?

TIA, Tom Roche <Tom_Roche at pobox.com>


More information about the Trilug-ontopic mailing list