2

I'm automating a process to upgrade my ext3 filesystem to ext4. Following the instructions from here I'm able to successfully migrate my filesystem. I've scripted the vast majority of the work, and it's working pretty nicely.

However, the final step in the migration is running fsck on the unmounted partition. The issue is that I'm trying to migrate the root partition, which can't be unmounted during normal operations. So to run fsck, I need to boot into recovery mode, enter the root password, and run fsck that way.

Is it possible to configure CentOS to automatically run fsck on boot into recovery?

Chris Henry
  • 1,512
  • 3
  • 15
  • 15
  • I just read the instructions you referenced - this looks awful. I think that upgrade procedure is weird - there has to be a better way to do it. A simple "needs check" will not work according to the procedure... – Nils Jan 06 '12 at 21:15
  • Agreed, those instructions are forked, why isn't that guy just doing an rsync from one partition to the other. The part about creating a new initrd might be viable though, since the original might not include the ext4 driver. – Tim Jan 06 '12 at 21:39
  • @Tim I'm attempting to upgrade the root partition, as opposed to creating a new one. Is there an easier way to get an ext4 partition? – Chris Henry Jan 06 '12 at 22:11
  • Not that I know of, but I certainly feel more comfortable with a clean partition opposed to an upgraded one. – Tim Jan 06 '12 at 23:07
  • 1
    @Tim right. Especially if I were starting off a soft-raid-device - like in the instructions. I would break the mirror into two degraded mirrors, make a clean ext4, `rsync -aHS`, modify grub, boot it and reattach the other side. – Nils Jan 07 '12 at 20:19
  • @Nils What is a soft-raid device? One thing to keep in mind here is that I'm on a Rackspace cloud server, and I have no control over disk configuration. – Chris Henry Jan 09 '12 at 15:42

1 Answers1

1

Why running an automatic fsck on system start won't work? fsck -pvfDC0 isn't doing anything special, just optimising the directories (the -D option) -- that's only part of ext4 file system. Extents is what makes it ext4. Just make it do fsck and reboot:

touch /forcefsck
shutdown -r now

Ext4 driver can read ext2, ext3 and ext4 file system, it's all the same for it. So yes, making sure your system is can boot from ext4 is important, having pure ext4 fs isn't.

That being said, I'd still go for creating a new partition as ext4 and copying data over -- it will be faster (access to partition, not the migration) and safer.

Hubert Kario
  • 6,351
  • 6
  • 33
  • 65