12

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 an ext4?
  • Will I lose all my data?

5 Answers 5

5

Follow the instructions detailed in this post: Convert ext2/3 to ext4

6
  • Will I lose all my data? How do I know if my boot partition is SEPARATE? Should I do the Step 3 or not?
    – Lucio
    Nov 2, 2012 at 19:21
  • 3
    You won't lose you're data, unless you do something incorrectly. If you're worried about data loss, you should always back it up somewhere else first. You can use mount to show what partitions are mounted where. You can also run sudo parted list to print a list of partitions.
    – dobey
    Nov 2, 2012 at 20:14
  • The command sudo parted list doesn't work, but sudo parted -l does.
    – Lucio
    Jan 13, 2013 at 22:23
  • Note that this only enables some of the features of ext4. Some can not be enabled without reformatting.
    – psusi
    Aug 26, 2013 at 2:21
  • 2
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – jrg
    Jun 15, 2017 at 17:11
4

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.

1
  • 1
    small typo: s/tunee2fs/tune2fs/
    – josch
    Feb 24, 2022 at 21:11
2

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?)

0

run "sudo update-initramfs -u -k all" , to avoid fsck.ext4 not found bootting error .

New contributor
John is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-2
  • Reformat the drive
  • Yes

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
3
  • 1
    The partition may not be /dev/sda1 ... ? Nov 2, 2012 at 18:39
  • @user30275, obviously....
    – psusi
    Nov 2, 2012 at 18:56
  • 1
    to psusi - in which case you should have pointed this out to the OP Nov 3, 2012 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .