Topic: [SOLVED] Error shrinking Ext2 partition
Hi all,
I have to report that I have been bitten by a gparted bug which looks rather like this one... http://gparted-forum.surf4.info/viewtopic.php?id=13777 As requested there, I've created this new post.
I was trying to shrink an ext2 partition to make room for a new linux install. Having previously read about this bug, I downloaded and used the latest version as a live CD (I think it was 0.6.5-something), since later versions were recommended in that thread.
Unfortunately, at the end of shrinking the partition, gparted bombed out. I would have liked to have saved the .htm error report but at the time, I couldn't recall how to mount a USB stick to which to save to and I had no other PC with which to access the web. I'm going to file a feature request for either automounting USB disks or providing instructions on the desktop/save dialogue of how to mount a save disk.
The error when gparted failed was basically that the superblock did not match. I got the same error when I tried to boot the system. At this point it doesnt seem that gparted is much use as it just says the partition is unreadable.
Most of this thread and the solutions seem to be for NTFS partitions, which I don't have. Soupcans solution doesn't help me as I can't boot the system to read the dmesg file (and of course it scrolls too fast to read).
I assume there must be some other way of checking the partitioning table and determining the magic numbers.
I can actually see the files on the hard disk using an Ubuntu 10.04.1 live CD, so I'm hoping I just need to fix the partition table or superblock.
I'm assuming/hoping that I just need to rewrite the partition table. Any ideas on if this is the best course and, if so, how to calculate the new size to use?
I don't know if this will help or not but I had backed up the partition table before using gparted. I've listed that output at the bottom. That seems to confirm that gparted got as far as shrinking the partition.
If I can work out the exact steps to take I'll write a mini-howto guide. One thing that I was wondering about, even if you can get the output of dmesg, is how to convert from the dmesg block count to the sfdisk sector size. Do you always multiply by 8 or would that change with sector/block size or filesystem type (ext2/3/4)?
(sfdisk -l says the drive is 1024 bytes per block while fdisk and parted say its 512 bytes per sector - that would give 2 sectors per block, not 8 ???? I'm confused ! )
Thanks very much,
Vic
-------------------------------------------------------
The output from sudo fdisk -l -u on /dev/sda is
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 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: 0x000033f4
Device Boot Start End Blocks Id System
/dev/sda1 * 1 41371647 20685823+ 83 Linux
/dev/sda2 153174766 156301487 1563361 5 Extended
/dev/sda5 153174767 156301487 1563360+ 83 Linux
-------------------------------------------------------
sudo parted /dev/sda unit s print gives
Model: ATA HTS541080G9AT00 (scsi)
Disk /dev/sda: 156301488s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1s 41371647s 41371647s primary ext3 boot
2 153174766s 156301487s 3126722s extended
5 153174767s 156301487s 3126721s logical linux-swap(v1)
-------------------------------------------------------
sudo sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors
/dev/sda1 : start= 1, size= 41371647, Id=83, bootable
/dev/sda2 : start=153174766, size= 3126722, Id= 5
/dev/sda3 : start= 0, size= 0, Id= 0
/dev/sda4 : start= 0, size= 0, Id= 0
/dev/sda5 : start=153174767, size= 3126721, Id=83
and using -l, sfdisk gives
Disk /dev/sda: 9729 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 2575- 2576- 20685823+ 83 Linux
/dev/sda2 9534+ 9729- 195- 1563361 5 Extended
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
/dev/sda5 9534+ 9729- 195- 1563360+ 83 Linux
-------------------------------------------------------
*** The following is how the disk WAS BEFORE GPARTED was run ***
sudo fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 9535 76587382+ 83 Linux
/dev/hda2 9535 9730 1563361 5 Extended
/dev/hda5 9535 9730 1563360+ 83 Linux
sfdisk -l
Disk /dev/hda: 9729 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/hda1 * 0+ 9534- 9535- 76587382+ 83 Linux
/dev/hda2 9534+ 9729- 195- 1563361 5 Extended
/dev/hda3 0 - 0 0 0 Empty
/dev/hda4 0 - 0 0 0 Empty
/dev/hda5 9534+ 9729- 195- 1563360+ 83 Linux
-------------------------------------------------------