现在的位置: 首页 > IT运维 > 正文

Linux升级EXT4文件系统

2010年08月09日 IT运维 ⁄ 共 6775字 暂无评论 ⁄ 被围观 715+

一、安装所需包

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

二、制作引导镜像

查找并加载相应的模块,如只需ext4支持,可将--with=ext3去掉

[root@myserv ~]# mv /boot/initrd-’uname -r’.img /boot/initrd-’uname -r’.img.old
[root@myserv ~]# 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

#重启
reboot

三、格式转换

umount  /dev/sda5
tune2fs -O has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize /dev/sda5

四、修改转换文件系统错误并挂载

e2fsck -fDC0 /dev/sda5 -y
mount -t ext4 /dev/sda5 /www

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

LABEL=/www /www ext3 defaults 1 2

修改为

LABEL=/www /www ext4 defaults 1 2
vi /etc/fstab
[root@myserv ~]# 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的特征全激活了:)

#运行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

#运行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

给我留言

您必须 [ 登录 ] 才能发表留言!

×
#