Loading... <p><span style="font-size: 12px">一台文件存储服务器单目录下子目录已经突破31998数限制,造成无法继续创建子目录,服务器系统环境为CentOS5.4 内核版本为2.6.18。解决方案只能是升级到ext4文件系统,首先到</span><span style="font-size: 12px">https://ext4.wiki.kernel.org/index.php/Ext4_Howto</span><span style="font-size: 12px">查了一下资料,文中的第一句便是“Ext4 was released as a functionally complete and stable filesystem in Linux 2.6.28”。难道只能升级内核一条路了吗?当然不是:)呵呵,下面总结本人实施/www分区从ext3升级至ext4步骤供大家参考。</span></p> <h2><strong>一、升级前状态</strong></h2> <pre class="brush:python;toolbar:false">[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</pre> <p><span style="font-size: 12px">无任何信息返回,说明/dev/sda5的ext4特征没有激活</span></p> <pre class="brush:bash;toolbar:false">[root@USER-SERVER ~]# tune2fs -l /dev/sda5 | grep extent [root@USER-SERVER ~]#</pre> <p><strong>安装所需包</strong><br />源码安装:</p> <pre class="brush:python;toolbar:false">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; cd e2fsprogs-1.41.12 ./configure make;make install</pre> <p>RPM安装:</p> <pre class="brush:python;toolbar:false">yum -y install e2fsprogs</pre> <h2><strong>二、制作引导镜像</strong></h2> <p><span style="font-size: 12px">查找并加载相应的模块,如只需ext4支持,可将–with=ext3去掉</span></p> <pre class="brush:python;toolbar:false">[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</pre> <p>[root@USER-SERVER ~]# reboot</p> <h2><strong>三、格式转换</strong></h2> <p><span style="font-size: 12px">[root@USER-SERVER ~]# umount /dev/sda5<br />[root@USER-SERVER ~]# tune2fs -O has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize /dev/sda5</span></p> <pre class="brush:python;toolbar:false">tune2fs 1.41.12 (17-May-2010) Please run e2fsck on the filesystem.</pre> <h2><strong>四、修改转换文件系统错误并挂载</strong></h2> <p><span style="font-size: 12px">[root@USER-SERVER ~]# e2fsck -fDC0 /dev/sda5 -y<br />[root@USER-SERVER ~]# mount -t ext4 /dev/sda5 /www</span></p> <h2><strong>五、修改文件系统信息(重要!否则重启后会还原为ext3)</strong></h2> <p><span style="font-size: 12px">将<br />LABEL=/www /www ext3 defaults 1 2<br />修改为<br />LABEL=/www /www ext4 defaults 1 2<br />[root@USER-SERVER ~]# vi /etc/fstab</span></p> <pre class="brush:python;toolbar:false">oot@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</pre> <h2><strong>六、升级后状态</strong></h2> <p><span style="font-size: 12px">ext4的特征全激活了:)<br />#[root@USER-SERVER ~]# tune2fs -l /dev/sda5 | grep extent</span></p> <pre class="brush:python;toolbar:false">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</pre> <p><span style="font-size: 12px">[root@USER-SERVER ~]# df -T</span></p> <pre class="brush:python;toolbar:false">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</pre> <p>http://fedorasolved.org/Members/rasker/converting-an-ext3-root-partition-to-ext4-in-fedora-10<br />http://kernelnewbies.org/Ext4#head-3891522e0601162aab24c73c1f148a1e28c6a9d4</p> <p><span style="font-size: 12px">如大家有什么疑问或感兴趣的话题可以通过weibo与我交流:</span>http://t.qq.com/yorkoliu</p> 最后修改:2021 年 12 月 10 日 10 : 53 AM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 赞赏作者 支付宝微信