ext3 logical partition resizing

You probably know you can resize primary partitions by deleting them and recreating them, keeping the starting block the same but using a higher block as ending point. You can then increase the filesystem.
But what about logical partitions? A while back I had to resize an ext3 logical partition which ended at the end of the last logical partition. I learned some usefull stuff but I only made some quick scratch notes and I don't remember all details so:
Do not expect a nice tutorial here, it's more of a commented dump of my scratch notes and some vague memories.
The information in this post is not 100% accurate

I wondered if I could just drop and recreate the extended partition (and if needed, recreating all contained logical partitions, the last one being bigger of course) but nowhere I could find information about that.

I did find various places where they said parted could "handle all partition and filesystem resizing at once".
this post was quite useful, but he was more lucky then me I guess.
In the parted documentation I couldn't find any restriction other then that xattrs don't work.
But it does not support the dir_index and resize_inode features (bug ticket)
You should be able to use tune2fs to remove these options, do the resize and then put them back. But tune2fs can't put them back and I even had problems removing resize_inode (see below)
Also, I falsely assumed parted would resize the extended partition when you tell it to resize the logical partition.

see here what i did, along with comments and remarks:

  1. # what features are enabled?
  2. linux-staging:~# tune2fs -l | grep -i feature
  3. Filesystem features: resize_inode dir_index filetype sparse_super large_file [has_journal]
  4.  
  5. # remove resize_inode feature
  6. linux-staging:~# tune2fs -O ^resize_inode /dev/hda9
  7. tune2fs 1.40-WIP (14-Nov-2006)
  8. Invalid filesystem option set: ^resize_inode # HUH ?
  9.  
  10. # okay then, lets try debugfs
  11. linux-staging:~# debugfs -w -R "feature -dir_index -resize_inode" /dev/hda9
  12. debugfs 1.40-WIP (14-Nov-2006)
  13. Filesystem features: has_journal filetype sparse_super large_file
  14.  
  15. # lets do an e2fsck. It gave errors but maybe that's normal (?)
  16. # I wonder whether debugfs just unsets the option flags or actually updates the filesystem to not use these features at all (in the latter case, e2fsck should be clean)
  17. linux-staging:~# e2fsck -f /dev/hda9
  18. e2fsck 1.40-WIP (14-Nov-2006)
  19. Filesystem does not have resize_inode enabled, but s_reserved_gdt_blocks
  20. is 176; should be zero. Fix<y>? yes
  21.  
  22. Resize_inode not enabled, but the resize inode is non-zero. Clear<y>? yes
  23.  
  24. Pass 1: Checking inodes, blocks, and sizes
  25. Inode 58 has INDEX_FL flag set on filesystem without htree support.
  26. Clear HTree index<y>? yes
  27.  
  28. Pass 2: Checking directory structure
  29. Pass 3: Checking directory connectivity
  30. Pass 4: Checking reference counts
  31. Pass 5: Checking group summary information
  32. Block bitmap differences: -(5--180) -689 -(32773--32948) -(98309--98484) -(163845--164020) -(229381--229556) -(294917--295092)
  33. -(819205--819380) -(884741--884916) -(1605637--1605812) -(2654213--2654388) -(4096005--4096180) -(7962629--7962804) -(11239429--11239604)
  34. Fix<y>?
  35. Free blocks count wrong for group #0 (0, counted=177).
  36. Fix<y>? yes
  37.  
  38. # lets doublecheck the enabled features
  39. linux-staging:~# tune2fs -l /dev/hda9 | grep -i feature
  40. Filesystem features: has_journal filetype sparse_super # Hey ? where did 'large_file' go?
  41.  
  42. # do the resize of the logical partition in parted
  43.  
  44. # enable features
  45. tune2fs -O dir_index /dev/hda9
  46. debugfs -w -R "feature large_file resize_inode" /dev/hda9
  47.  
  48. # now all should be good, right? lets do an e2fsck
  49. linux-staging:~# e2fsck -f /dev/hda9
  50. e2fsck 1.40-WIP (14-Nov-2006)
  51. Resize inode not valid. Recreate<y>? yes
  52.  
  53. Pass 1: Checking inodes, blocks, and sizes
  54. Pass 2: Checking directory structure
  55. Pass 3: Checking directory connectivity
  56. Pass 3A: Optimizing directories
  57. Pass 4: Checking reference counts
  58. Pass 5: Checking group summary information
  59. Block bitmap differences: +689
  60. Fix<y>? yes
  61.  
  62.  
  63. /dev/hda9: ***** FILE SYSTEM WAS MODIFIED *****
  64. /dev/hda9: 132012/7038048 files (6.2% non-contiguous), 12076862/14368126 blocks
  65.  
  66. # I also got <strong>a lot</strong> of these errors:
  67. Assertion (block < EXT2_SUPER_BLOCKS_COUNT(fs->sb)) at ../../../../libparted/fs/ext2/ext2.h:226 in function ext2_is_data_block() failed.
  68.  
  69. # now here are some more scratch notes. I forgot exactly why and what I did, so I'm just putting them here for reference.
  70.  
  71. #in fdisk, delete logical, recreate, reboot and do online resize with resize2fs
  72. linux-staging:~# resize2fs /dev/hda9
  73. resize2fs 1.40-WIP (14-Nov-2006)
  74. Filesystem at /dev/hda9 is mounted on /home; on-line resizing required
  75. old desc_blocks = 4, new_desc_blocks = 5
  76. Performing an on-line resize of /dev/hda9 to 19872397 (4k) blocks.
  77. resize2fs: Invalid argument While trying to add group #512
  78.  
  79.  
  80. linux-staging:~# resize2fs /dev/hda9
  81. resize2fs 1.40-WIP (14-Nov-2006)
  82. Please run 'e2fsck -f /dev/hda9' first.
  83.  
  84. linux-staging:~# e2fsck -f /dev/hda9
  85. e2fsck 1.40-WIP (14-Nov-2006)
  86. Superblock last mount time is in the future. Fix<y>? yes
  87.  
  88. Pass 1: Checking inodes, blocks, and sizes
  89. Pass 2: Checking directory structure
  90. Filesystem contains large files, but lacks LARGE_FILE flag in superblock.
  91. Fix<y>? yes
  92.  
  93. Pass 3: Checking directory connectivity
  94. Pass 4: Checking reference counts
  95. Pass 5: Checking group summary information
  96.  
  97. /dev/hda9: ***** FILE SYSTEM WAS MODIFIED *****
  98. /dev/hda9: 132012/8208384 files (6.2% non-contiguous), 12113624/16777216 blocks
  99. linux-staging:~# resize2fs /dev/hda9
  100. resize2fs 1.40-WIP (14-Nov-2006)
  101. Resizing the filesystem on /dev/hda9 to 19872397 (4k) blocks.
  102. The filesystem on /dev/hda9 is now 19872397 blocks long.
  103.  
  104. linux-staging:~# mount /dev/hda9
  105.  
  106. # suprisingly, all data looked still intact.

After this experience I actually created a VM to do some testing and figured out this is the better way (no fsck errors, and goes much faster):

  • use parted only to increase the extended partition
  • drop and recreate logical partition with fdisk
  • resize2fs the logical partition

Trackback URL for this post:

http://dieter.plaetinck.be/trackback/78
Submitted by Dieter_be on Sun, 11/01/2009 - 11:17. categories [ ]

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Security question, designed to stop automated spam bots