shrink ext3 filesystem using e2fsprogs and fdisk
I have a 500GB((131072000*4096)/1024^3) ext3 filesystem:
root@debian:~#dumpe2fs /dev/sda9 | egrep "Block count|Block size"
dumpe2fs 1.41.12 (17-May-2010)
Block count:              131072000
Block size:               4096
root@debian:~#
..on a 904GB((1953523711-56924160)*512)/(1024^3) partition(sda9):
root@debian:~#fdisk -cul /dev/sda
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0x00062a0f
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      684031      340992   83  Linux
/dev/sda2          686078  1953523711   976418817    5  Extended
/dev/sda5          686080    18262015     8787968   83  Linux
/dev/sda6        18264064    24121343     2928640   83  Linux
/dev/sda7        24123392    56141823    16009216   82  Linux swap / Solaris
/dev/sda8        56143872    56922111      389120   83  Linux
/dev/sda9        56924160  1953523711   948299776   83  Linux
root@debian:~#
At the moment everything works, but if I shrink the size of the
/dev/sda9 partition from the beginning of the partition like this(sda9
is now 693GB which is more than enough to hold the 500GB file system):
root@debian:~#fdisk -cul /dev/sda
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0x00062a0f
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      684031      340992   83  Linux
/dev/sda2          686078  1953523711   976418817    5  Extended
/dev/sda5          686080    18262015     8787968   83  Linux
/dev/sda6        18264064    24121343     2928640   83  Linux
/dev/sda7        24123392    56141823    16009216   82  Linux swap / Solaris
/dev/sda8        56143872    56922111      389120   83  Linux
/dev/sda9       500000000  1953523711   726761856   83  Linux
root@debian:~#
..then file system is broken:
root@debian:~#dumpe2fs /dev/sda9
dumpe2fs 1.41.12 (17-May-2010)
dumpe2fs: Bad magic number in super-block while trying to open /dev/sda9
Couldn't find valid filesystem superblock.
root@debian:~#
Is it possible to make partition smaller starting from the beginning?
If yes, do I need to somehow start file system from the end of the
partition?
regards,
martin
Reply to: