Linux partition ext3 lossless conversion to ext4 format

Source: Internet
Author: User
The number of subdirectories in a single directory of a file storage server has exceeded the limit of 31998. As a result, the subdirectory cannot be created. The system environment of the server is CentOS5.4 and the kernel version is 2.6.18. The solution can only be to upgrade to the ext4 file system. First, go to https: ext4.wiki. kernel. orgindex. phpExt4_Howto and check the information.

The number of subdirectories in a single directory of a file storage server has exceeded the limit of 31998. As a result, the subdirectory cannot be created. The system environment of the server is CentOS5.4 and the kernel version is 2.6.18. The solution can only be upgradedExT4 file system, first to https://ext4.wiki.kernel.org/index.Php/Ext4_Howto checked the information. The first sentence in this article is "Ext4 was releasEdAs a fuNcTionally complete and stableFileSystem in Linux 2.6.28 ". Is there only one way to upgrade the kernel? Of course not :) Haha, The following summarizes the steps for upgrading the/www partition from ext3 to ext4 for your reference.

I. status before Upgrade



[Root @ USER-SERVER ~] # Df
Filesystem 1K-blocks U SedAvailable Use % Mounted on
/Dev/sda2 20315844 2342008 16925196 13%/
/Dev/sda5 129863460 192192 122968152 1%/www
/Dev/sda1 194442 17798 166605 10%/boot
Tmpfs 1029680 0 1029680 0%/dev/shm

No information is returned, indicating that the ext4 feature of/dev/sda5 is not activated.



[Root @ USER-SERVER ~] # Tune2fs-l/dev/sda5 | GrepExtent
[Root @ USER-SERVER ~] #

Install required packages
Source code installation:


Wget http :// Ftp.Kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/e2fsprogs-1.41.12.tar.gz
Tar zxvf e2fsprogs-1.41.12.tar.gz; CdE2fsprogs-1.41.12
./Configure
Make; make install

RPM installation:



Yum-y install e2fsprogs

Ii. Create a boot image
Find and load the corresponding module. If you only need ext4 support, you can remove -- with = ext3.



[Root @ USER-SERVER boot] # Mv/Boot/ini TrD -' Uname-R'. img/boot/initrd-'uname-R'. img. old
[Root @ USER-SERVER boot] # Mkinitrd-V -- with = ext4 -- with = ext3/boot/initrd-'uname-R'. img 'uname-R'
Creating initramfs
Looking for deps of mo DuLe ehci-hcd
Looking for deps of module ohci-hcd
Looking for deps of module uhci-hcd
Looking for deps of module ext3: jbd
Looking for deps of module jbd
Found root device sda2 for LABEL =/
Looking for driver for device sda2
Looking for deps of module pci: v20178086d20172680sv10917aasd20176b7cbc01sc01i8f: scsi_mod libata ata_piix
Looking for deps of module scsi_mod
Looking for deps of module sd_mod: scsi_mod
Looking for deps of module libata: scsi_mod
Looking for deps of module ata_piix: scsi_mod libata
Looking for driver for device sda3
Looking for deps of module pci: v20178086d20172680sv10917aasd20176b7cbc01sc01i8f: scsi_mod libata ata_piix
Looking for deps of module usb-storage: scsi_mod
Looking for deps of module IdE-disk
Looking for deps of module dm-mem-cache
Looking for deps of module dm-region_hash: dm-mod dm-log
Looking for deps of module dm-mod
Looking for deps of module dm-log: dm-mod
Looking for deps of module dm-message
Looking for deps of module dm-raid45: dm-message dm-mod dm-mem-cache dm-log dm-region_hash
Looking for deps of module ext4: crc16 jbd2
Looking for deps of module crc16
Looking for deps of module jbd2
Using modules: /lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/host/ehci-hcd.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/host/ohci-hcd.ko/lib/modules /2.6.18-164.15.1.el5/kernel/drivers/usb/host/uhci-hcd.ko/lib/modules/2.6.18-164.15.1.el5/kernel/fs/jbd. ko/lib/modules/2.6.18-164.15.1.el5/kernel/fs/ext3/ext3.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/scsi/scsi_mod.ko/lib/modules/2.6.18- 164.15.1.el5/kernel/drivers/scsi/sd_mod.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/ata/libata. ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/ata/ata_piix.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/storage/usb-storage.ko/lib/modules/ 2.6.18-164.15.1.el5/kernel/drivers/md/dm-mem-cache.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-mod.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/ md/dm-log.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-region_hash.ko/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-message.ko/lib/modules/ 2.6.18-164.15.1.el5/kernel/drivers/md/dm-raid45.ko/lib/modules/2.6.18-164.15.1.el5/kernel/lib/crc16.ko/lib/modules/2.6.18-1615.1.el5/kernel/fs/jbd2/ jbd2.ko/lib/modules/2.6.18-164.15.1.el5/kernel/fs/ext4/ext4.ko
/Sbin/nash->/tmp/initrd. qO3680/bin/nash
/Sbin/ Insmod. StatIc->/tmp/initrd. qO3680/bin/insmod
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/host/RD' [ehci-hcd.ko] to '/tmp/initrd. qO3680/lib/ehci-hcd.ko '[elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/host/RD' [ohci-hcd.ko] to '/tmp/initrd. qO3680/lib/ohci-hcd.ko '[elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/host/RD' [uhci-hcd.ko] to '/tmp/initrd. qO3680/lib/uhci-hcd.ko '[elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/fs/jbd. ko '[elf64-x86-64] to'/tmp/initrd. qO3680/lib/jbd. ko '[elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/fs/ext3/ext3.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/ext3.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/scsi/scsi_mod.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/scsi_mod.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/scsi/sd_mod.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/sd_mod.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/ata/libata. ko '[elf64-x86-64] to'/tmp/initrd. qO3680/lib/libata. ko '[elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/ata/ata_piix.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/ata_piix.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/usb/storage/usb-storage.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/usb-storage.ko '[elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-mem-cache.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/dm-mem-cache.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-mod.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/dm-mod.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-log.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/dm-log.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-region_hash.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/dm-region_hash.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-message.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/dm-message.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/drivers/md/dm-raid45.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/dm-raid45.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/lib/crc16.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/crc16.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/fs/jbd2/jbd2.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/jbd2.ko' [elf64-x86-64]
Copy from '/lib/modules/2.6.18-164.15.1.el5/kernel/fs/ext4/ext4.ko' [elf64-x86-64] to '/tmp/initrd. qO3680/lib/ext4.ko' [elf64-x86-64]
/Sbin/dmraid. static->/tmp/initrd. qO3680/bin/dmraid
/Sbin/kpartx. static->/tmp/initrd. qO3680/bin/kpartx
A DdIng module ehci-hcd
Adding module ohci-hcd
Adding module uhci-hcd
Adding module jbd
Adding module ext3
Adding module scsi_mod
Adding module sd_mod
Adding module libata
Adding module ata_piix
Adding module usb-storage
Adding module dm-mem-cache
Adding module dm-mod
Adding module dm-log
Adding module dm-region_hash
Adding module dm-message
Adding module dm-raid45
Adding module crc16
Adding module jbd2
Adding module ext4

Restart
[Root @ USER-SERVER ~] # Reboot

Iii. Format Conversion
[Root @ USER-SERVER ~] #Umount/Dev/sda5
[Root @ USER-SERVER ~] # Tune2fs-O has_journal, extents, huge_file, flex_bg, uninit_bg, dir_nlink, extra_isize/dev/sda5



Tune2fs 1.41.12 (17-May-2010)
Please run e2 FsckOn the filesystem.

4. Modify the conversion file system error and mount it
[Root @ USER-SERVER ~] #E2fsck-FDC0/dev/sda5-y
[Root @ USER-SERVER ~] # Mount-t ext4/dev/sda5/www

5. Modify the file system information (important! Otherwise, it will be restored to ext3 after restart)
Set
LABEL =/www ext3 defaults 1 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.