LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-14-2012, 01:38 PM   #1
chicagocoyote
LQ Newbie
 
Registered: May 2009
Location: Chicago
Distribution: CentOS, Fedora
Posts: 27

Rep: Reputation: 0
Need to reformat ext3 to ext4


Due to the issues listed in my post
"useradd and ext4 issue", I need to reformat
a ext3 partition to ext4. I have multiple backups.


Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 203096536 51573880 141036232 27% /u1


What is the best way to do this? Something like:

umount /u1
/sbin/mkfs.ext4 /dev/sda5
/sbin/e2label /dev/sda5 u1


though once I execute the above, do I still need to
edit /etc/fstab and /etc/mtab, and if so, how?
====

I tried gparted (Genome Partition Editor) which I assume
would take care of all the /etc/ files automatically,
but received the message:

= "An error occurred while applying the operations"
=
= Format /dev/sda5 as ext4 00:00:02 ( ERROR )
=
= calibrate /dev/sda5 00:00:00 ( SUCCESS )
=
= path: /dev/sda5
= start: 275,723,658
= end: 695,180,744
= size: 419,457,087 (200.01 GiB)
= set partition type on /dev/sda5 00:00:01 ( SUCCESS )
=
= new partition type: ext4
= create new ext4 file system 00:00:01 ( ERROR )
=
= mkfs.ext4 -j -O extent -L "" /dev/sda5
=
= mke2fs 1.42.3 (14-May-2012)
= /dev/sda5 is apparently in use by the system; will not make a
= filesystem here!


Though I don't understand how the filesystem is still in use
as it was unmounted.


Thank you for your help;
 
Old 07-14-2012, 03:27 PM   #2
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Quote:
Originally Posted by chicagocoyote View Post
What is the best way to do this? Something like:
Code:
   umount /u1
   /sbin/mkfs.ext4  /dev/sda5
   /sbin/e2label   /dev/sda5  u1
though once I execute the above, do I still need to
edit /etc/fstab and /etc/mtab, and if so, how?
Your commands look fine. Don't worry about /etc/mtab (see the man page for mount to understand why). The file /etc/fstab is a text file - all you should need to do is edit the /dev/sda5 or LABEL=u1 entry, with your favourite text editor, to specify ext4 rather than ext3 as the filesystem.
 
Old 07-14-2012, 09:33 PM   #3
chicagocoyote
LQ Newbie
 
Registered: May 2009
Location: Chicago
Distribution: CentOS, Fedora
Posts: 27

Original Poster
Rep: Reputation: 0
> Your commands look fine. Don't worry about /etc/mtab (see the man page for
> mount to understand why). The file /etc/fstab is a text file - all you should
> need to do is edit the /dev/sda5 or LABEL=u1 entry, with your favourite text
> editor, to specify ext4 rather than ext3 as the filesystem.

Thanks. Actually, when I execute "/sbin/mkfs.ext4 /dev/sda5"
(after unmounting /dev/sda5), I get the message:

/dev/sda5 is apparently in use by the system; will not make
a filesystem here!


What is the issue here?

Do I need to boot off the live CD in order to format a
partition, rather than boot off the OS on the actually
hard disk?

Thanks again;
 
Old 07-14-2012, 09:53 PM   #4
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Request for info

The error means that the unmount of /u1 didn't complete or /dev/sda5 is not the partition being mounted on /u1. Are you sure sda5 is correct?

Within code blocks, so it gets properly formatted, can you post the outputs of 'mount' and your /etc/fstab file?
 
1 members found this post helpful.
Old 07-14-2012, 10:06 PM   #5
chicagocoyote
LQ Newbie
 
Registered: May 2009
Location: Chicago
Distribution: CentOS, Fedora
Posts: 27

Original Poster
Rep: Reputation: 0
> The error means that the unmount of /u1 didn't complete or /dev/sda5 is not the
> partition being mounted on /u1. Are you sure sda5 is correct?

Yes, here is the output of "df":

Code:
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs          98953540  6095604  91867468   7% /
/dev/sda3       98953540  6095604  91867468   7% /
/dev/sda1        5220716   269912   4688948   6% /boot
/dev/sda5      203096536 51573880 141036232  27% /u1
/dev/sda6      203096536 14710508 177899604   8% /u2
/dev/sda7      203084576 43868332 148730624  23% /u3
/dev/sda8      203096536 10779144 181830968   6% /u4
devtmpfs         1014540        0   1014540   0% /dev
tmpfs            1025436      100   1025336   1% /dev/shm
tmpfs            1025436     1296   1024140   1% /run
tmpfs            1025436        0   1025436   0% /sys/fs/cgroup
tmpfs            1025436        0   1025436   0% /media
> Within code blocks, so it gets properly formatted, can you post
> the outputs of 'mount'

Code:
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=1014540k,nr_inodes=253635,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
/dev/sda3 on / type ext4 (rw,relatime,seclabel,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /media type tmpfs (rw,nosuid,nodev,noexec,relatime,seclabel,mode=755)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sda8 on /u4 type ext3 (rw,relatime,seclabel,data=ordered)
/dev/sda6 on /u2 type ext3 (rw,relatime,seclabel,data=ordered)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel,data=ordered)
/dev/sda7 on /u3 type ext3 (rw,relatime,seclabel,data=ordered)
gvfs-fuse-daemon on /run/user/generic/gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda5 on /u1 type ext3 (rw,relatime,seclabel,data=ordered)
> and your /etc/fstab file?

Code:
#
# /etc/fstab
# Created by anaconda on Fri Jul 13 15:42:02 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=b171f170-086f-4b5d-b5ac-f132a6c6bed9 /             ext4    defaults        1 1
UUID=d0b422d3-48ce-4989-9b3e-bc4262b989d1 /boot         ext4    defaults        1 2
UUID=d3374b32-0a42-4d9e-859d-2ce24166e4e6 /u1           ext3    defaults        1 2
UUID=f88caee0-6516-4171-a1c9-551f18613e35 /u2           ext3    defaults        1 2
UUID=4032c16b-9709-4bc7-945d-71882572e3e8 /u3           ext3    defaults        1 2
UUID=4eb59a23-453a-4bc1-9ee2-41f853f593e1 /u4           ext3    defaults        1 2
UUID=76b37a42-2c6b-40fa-9126-80c9841998e3 swap          swap    defaults        0 0
Thank you very much for taking a look.
 
Old 07-14-2012, 10:16 PM   #6
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Thanks.

So /dev/sda5 is still mounted. Maybe a process has open files on /u1 preventing it from being unmounted. You can check with fuser:

Code:
fuser -vm /u1
Anything listed represent processes that need to be stopped before it can be unmounted.

You don't happen to have an Oracle database running at the moment do you?
 
1 members found this post helpful.
Old 07-14-2012, 10:32 PM   #7
chicagocoyote
LQ Newbie
 
Registered: May 2009
Location: Chicago
Distribution: CentOS, Fedora
Posts: 27

Original Poster
Rep: Reputation: 0
Oh, those outputs were all with /u1 mounted again. When I execute
"umount /u1", here is the output of "df":
Code:
Filesystem     1K-blocks     Used Available Use% Mounted on
rootfs          98953540  8336020  89627052   9% /
devtmpfs         1014540        0   1014540   0% /dev
/dev/sda1        5220716   269912   4688948   6% /boot
/dev/sda3       98953540  8336020  89627052   9% /
/dev/sda6      203096536 14710508 177899604   8% /u2
/dev/sda7      203084576 43868332 148730624  23% /u3
/dev/sda8      203096536 65735480 126874632  35% /u4
tmpfs            1025436       96   1025340   1% /dev/shm
tmpfs            1025436     1736   1023700   1% /run
tmpfs            1025436        0   1025436   0% /sys/fs/cgroup
tmpfs            1025436        0   1025436   0% /media
and "mount":
Code:
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=1014540k,nr_inodes=253635,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
/dev/sda3 on / type ext4 (rw,relatime,seclabel,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /media type tmpfs (rw,nosuid,nodev,noexec,relatime,seclabel,mode=755)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sda8 on /u4 type ext3 (rw,relatime,seclabel,data=ordered)
/dev/sda6 on /u2 type ext3 (rw,relatime,seclabel,data=ordered)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel,data=ordered)
/dev/sda7 on /u3 type ext3 (rw,relatime,seclabel,data=ordered)
gvfs-fuse-daemon on /run/user/generic/gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
yet still, "/sbin/mkfs.ext4 /dev/sda5" yields the message:

Code:
dev/sda5 is apparently in use by the system; will not make a filesystem here!
The output of "fuser -vm /u1" is 158 lines long. Would you
like to see it?

No, I am not running an Oracle database.

Thanks again.
 
Old 07-15-2012, 06:35 AM   #8
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
The output of the fuser command would only be useful if it was executed after unmounting /u1.

I am thinking that there will be more success by trying the mkfs in single user mode or from a LiveCD. It would help ensure that nothing is using /dev/sda5.
 
Old 07-15-2012, 02:04 PM   #9
chicagocoyote
LQ Newbie
 
Registered: May 2009
Location: Chicago
Distribution: CentOS, Fedora
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by whizzit View Post
The output of the fuser command would only be useful if it was executed after unmounting /u1.
Actually, those 158 lines of output from "fuser -vm /u1"
were with /u1 unmounted. /u1 was no longer in the output
of "df" or "mount".

Quote:
I am thinking that there will be more success by trying the mkfs in single user mode or from a LiveCD. It would help ensure that nothing is using /dev/sda5.
And that is exactly what I did. On to new problems.


My system now boots up in emergency mode:
Code:
Cannot open font file True
Welcome to emergency mode.  Use "systemctl default" or ^D to enter default mode.

Give root password for maintenance (or type Control-D to continue_

When I type root password, all partitions are available except
for /u1 though i _can_ mount /u1 with the command:
Code:
mount -t ext4 /dev/sda5 /mnt/u1_tmp
What do I do now? Is this a grub issue?

The system does not behave as though any partitions were
damaged, all are readable by me.

Thanks again !


P.S. I did edit the /etc/fstab file changing /u1 from
ext3 to ext4:
Code:
# /etc/fstab
# Created by anaconda on Fri Jul 13 15:42:02 2012
# 
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# 
UUID=b171f170-086f-4b5d-b5ac-f132a6c6bed9 /        ext4    defaults        1 1
UUID=d0b422d3-48ce-4989-9b3e-bc4262b989d1 /boot    ext4    defaults        1 2
UUID=d3374b32-0a42-4d9e-859d-2ce24166e4e6 /u1      ext4    defaults        1 2
UUID=f88caee0-6516-4171-a1c9-551f18613e35 /u2      ext3    defaults        1 2
UUID=4032c16b-9709-4bc7-945d-71882572e3e8 /u3      ext3    defaults        1 2
UUID=4eb59a23-453a-4bc1-9ee2-41f853f593e1 /u4      ext3    defaults        1 2
UUID=76b37a42-2c6b-40fa-9126-80c9841998e3 swap     swap    defaults        0 0
What is with those UUID numbers in /etc/fstab? That must be new
as I have never seen
those before.
 
Old 07-15-2012, 02:34 PM   #10
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
It's possible the UUID for that partition has now changed but can you post the output before the maintenance mode prompt (?) as there should be some error or indication of why the system entered maintenance mode. Hopefully it's just because it couldn't find the old /u1 partition.

Does the system continue to boot OK when you exit maintenance mode?

The UUIDs can be helpful in situations where disks can be removed or added to a system. sda, sdb etc can get renamed but UUIDs remain the same. Personally I prefer to use LABEL= but it doesn't really matter.

The UUID for /dev/sda5 can be obtained with blkid:

Code:
blkid -s UUID /dev/sda5
 
1 members found this post helpful.
Old 07-15-2012, 02:58 PM   #11
chicagocoyote
LQ Newbie
 
Registered: May 2009
Location: Chicago
Distribution: CentOS, Fedora
Posts: 27

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by whizzit View Post
It's possible the UUID for that partition has now
changed but can you post the output before the maintenance mode prompt (?) as
there should be some error or indication of why the system entered maintenance
mode.
The only message that was there long enough for me to read was:
"Cannot open font file True"


Quote:
Hopefully it's just because it couldn't find the old /u1 partition.

Does the system continue to boot OK when you exit maintenance mode?
It does not. The system just goes back into rescue mode.


Quote:

The UUIDs can be helpful in situations where disks can be removed or added to a
system. sda, sdb etc can get renamed but UUIDs remain the same. Personally I
prefer to use LABEL= but it doesn't really matter.

The UUID for /dev/sda5 can be obtained with blkid:

Code:
blkid -s UUID /dev/sda5
And that was the ticket. I used "blkid" to get the ID, edited
/etc/fstab with the new ID, and the system now boots fine!


Thanks !!
 
Old 07-15-2012, 03:56 PM   #12
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Good stuff!
 
Old 07-16-2012, 10:09 AM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
What the heck?!

"ext4" is simply "ext3" with journaling turned on. You don't have to reformat anything. You just turn-on journaling.
 
Old 07-16-2012, 10:11 AM   #14
whizzit
Member
 
Registered: Aug 2004
Location: UK
Distribution: Gentoo, OpenBSD, Debian, FreeBSD, RHEL, CentOS
Posts: 65

Rep: Reputation: 24
Quote:
Originally Posted by sundialsvcs View Post
What the heck?!

"ext4" is simply "ext3" with journaling turned on. You don't have to reformat anything. You just turn-on journaling.
I don't think so. Are you thinking of ext2 -> ext3 ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ext3 converted to ext4, still reported as ext3 eduperez Linux - General 3 02-08-2012 12:25 AM
What is best EXT3 or EXT4 shafey Linux - General 1 12-04-2011 02:46 AM
How to reformat ext3 partition in to fat32 or NTFS? tisina Linux - Newbie 1 08-25-2009 04:00 AM
From ext3 to ext4 rengo.Java Linux - Software 6 12-27-2008 09:58 AM
reformat file system (from ext2 to ext3) pimo Linux - General 5 03-19-2002 04:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration