Jump to content
Sign in to follow this  
ianw1974

tune2fs and inodes

Recommended Posts

Currently, in tune2fs - the tool for enabling journaling on ext2 partitions and various other stuff has a feature that should work, but it doesn't seem to - at least in my case.

 

Last night, I thought it would be a great idea to change my inode size from 128 to 256 on my /home partition. I didn't take a backup, because I thought since tune2fs could enable journaling OK, it should be able to modify inode sizes. So I did:

 

tune2fs -I /dev/sda3

 

being my /home partition. Now, this ran and ran and ran, for a few hours, and it was still going. I only have a 110GB partition so this shouldn't in theory have taken too long. Anyway, later on, either the CTRL-C I pressed cancelled it, or it simply finished as the response wasn't immediate. My system still have 128 inode value set, and figured that it had been trying to change it and hadn't actually done anything.

 

My system seemed fine, all my files were there, and I rebooted and everything was normal. That was until later today, whilst doing some heavy disk read/writes that my whole system hung. I had no keyboard response, and so issued the ALT-SYSRQ sequence to in as much as safe as possible restart my machine - ALT-SYSRQ RSEIUB - which it did fine.

 

The problem was, that /home wouldn't come online because of a problem, and I couldn't enter the password to go into maintenance mode - so I rebooted with a LiveCD. On checking the system, it said it had problems with inodes, and asked if I wanted to repair. So, I said yes to everything.

 

Then, after mounting /home to check all was OK, I noticed everything was gone! :o

 

To my shock, I thought I'd just lost over 80GB of data. I then downloaded a recovery CD, which in all honesty didn't do much as it would only recover partitions deleted from a disk - which can also get your data back. I had my partitions, I just didn't have the data.

 

I then mounted /home again, and checked in the Lost&Found folder and saw a load of folders with #nnnnnnn - where nnnnn was a number. On checking inside these, I could see all my data, so I just moved them back to their previous locations. Then, after doing:

 

tune2fs -j /dev/sda3

 

to enabling journaling and thus have ext3 again instead of just ext2, I could now boot my system normally, and I had all my data!

 

So, whilst I was lucky, don't do as I do. Get a backup first before trying something so stupid as changing your inode size - which, I should have realised before doing this that there was a likelihood of a major problem! Like, data-loss.

 

For the life of me, I cannot see why this option exists to change the inode. Either it's there for the future (ext4), or I should have left my system for a day or two for it to finish changing the inode size. Either way, I won't be doing it again. The most simplest way to change it is:

 

1. Copy off all data to another machine.

2. Format the partition and specify the inode size you want.

3. Copy data back to partition.

 

Well, it was a nice lesson, and the outcome wasn't as bad as it should have been :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...