I installed Ubuntu 12.10, and I don't know why, I have an ext2 partition.
- How can I convert this
ext2
file system to anext4
? - Will I lose all my data?
Follow the instructions detailed in this post: Convert ext2/3 to ext4
mount
to show what partitions are mounted where. You can also run sudo parted list
to print a list of partitions.
A lot has changed in ext4 since the article linked to in the accepted answer was written. There are a lot more ext4 features that can be enabled now. To convert an ext2 filesystem to a full-featured ext4 (at the time of this writing), The command is:
tune2fs -O extents,uninit_bg,dir_index,has_journal,flex_bg,huge_file,extra_isize,dir_nlink,uninit_bg /dev/EXT2DEVICE
There really isn't a set "ext2", "ext3", or "ext4" any more. There is a whole spectrum of features. To see the features enabled for your extX filesystem, use the command:
dumpe2fs -h /dev/DEVICE
The core set of features for ext2 are: ext_attr,resize_inode,filetype,sparse_super,large_file. Generally, ext3 is considered to be ext2 plus a journal. And ext4 is basically ext3 plus any combination of the rest of the available features. In the future they may name it ext5, 6 or 7. Really it's all one filesystem family with a variable set of features.
To find out what the most current set of extWHATEVER features are at the time you read this, the best thing you can do is just create a small filesystem and look at its feature list. For ext4 it is:
dd if=/dev/zero of=ext4test bs=1M count=256
mkfs.ext4 ext4test
dumpe2fs -h ext4test
Look at the line that says "Filesystem features:" and it will tell you what features have been included on that filesystem. At the time of this writing it is:
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Once you do that, you can create your own method for updating your extX to the extLATEST. Do a dumpe2fs on the filesystem you want to upgrade and compare the features on it to the features on your test ext filesystem. For any or all of the features that are missing on the old filesystem you:
tune2fs -O <comma-delimited list of missing features>
Once you are done adding the features, force a filesystem check with:
e2fsck -f /dev/DEVICE
And you have just now ensured your extX is now the extLATEST with all the available features.
The short version for the impatient:
dev=/dev/sdXn # <-- Adjust this
then
umount $dev && tune2fs -O extents,uninit_bg,dir_index,has_journal $dev && e2fsck -v -pf $dev
If you cannot unmount because it's your system partition, then of course you will need to first boot from another system like a Live CD.
And no, you will not lose data. Unless something very weird happens, in which case you will have to reach to your backup. (You do have backups, of course. Right?)
run "sudo update-initramfs -u -k all" , to avoid fsck.ext4 not found bootting error .
As an alternative, you can enable some of the features of ext4 by running the following command, and rebooting:
sudo tune2fs -O has_journal,uninit_bg,extents /dev/sda1