感谢支持
我们一直在努力

CentOS 5.4无痛之ext3升ext4

一台文件存储服务器单目录下子目录已经突破31998数限制,造成无法继续创建子目录,服务器系统环境为CentOS5.4 内核版本为2.6.18。解决方案只能是升级到ext4文件系统,首先到https://ext4.wiki.kernel.org/index.php/Ext4_Howto查了一下资料,文中的第一句便是“Ext4 was released as a functionally complete and stable filesystem in Linux 2.6.28”。难道只能升级内核一条路了吗?当然不是:)呵呵,下面总结本人实施/www分区从ext3升级至ext4步骤供大家参考。


一、升级前状态


[root@USER-SERVER ~]# df
Filesystem           1K-blocks      Used Available 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


无任何信息返回,说明/dev/sda5的ext4特征没有激活


[root@USER-SERVER ~]# tune2fs -l /dev/sda5 | grep extent
[root@USER-SERVER ~]#


安装所需包
源码安装:


wget http://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/e2fsprogs-1.41.14.tar.gz
tar zxvf e2fsprogs-1.41.14.tar.gz; cd e2fsprogs-1.41.14
./configure
make;make install


二、制作引导镜像
查找并加载相应的模块,如只需ext4支持,可将–with=ext3去掉


[root@USER-SERVER boot]# mv /boot/initrd-`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 module 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:v00008086d00002680sv000017AAsd00006B7Cbc01sc01i8f: 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:v00008086d00002680sv000017AAsd00006B7Cbc01sc01i8f: 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/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-164.15.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/ehci-hcd.ko’ [elf64-x86-64] 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/ohci-hcd.ko’ [elf64-x86-64] 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/uhci-hcd.ko’ [elf64-x86-64] 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/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
Adding 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


重启
[root@USER-SERVER ~]# reboot


三、格式转换
[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 e2fsck on the filesystem.


四、修改转换文件系统错误并挂载
[root@USER-SERVER ~]# e2fsck -fDC0 /dev/sda5 -y
[root@USER-SERVER ~]# mount -t ext4 /dev/sda5 /www


五、修改文件系统信息(重要!否则重启后会还原为ext3)

LABEL=/www              /www                    ext3    defaults        1 2
修改为
LABEL=/www              /www                    ext4    defaults        1 2
[root@USER-SERVER ~]# vi /etc/fstab


root@USER-SERVER ~]# vi /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/www              /www                    ext4    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0


六、升级后状态
ext4的特征全激活了:)
#[root@USER-SERVER ~]# tune2fs -l /dev/sda5 | grep extent


Filesystem features:      has_journal resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize


[root@USER-SERVER ~]# df -T


Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda2     ext3    20315844   2310764  16956440  12% /
/dev/sda1     ext3      194442     20563    163840  12% /boot
tmpfs        tmpfs     1029672         0   1029672   0% /dev/shm
/dev/sda5     ext4   129863460    192192 122968152   1% /www

赞(0) 打赏
转载请注明出处:服务器评测 » CentOS 5.4无痛之ext3升ext4
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏