LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 01-10-2010, 08:51 PM   #1
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
Format external hdd as ext4 without losing data?


I have a 300 external usb drive which I have got when using windows and so is using a fat32 filesystem. I have since moved to linux only and am mounting the drive as vfat however I think I may as well convert it to ext4 if possible for (amongst others) performance and security reasons. The problem is I don't have a separate drive which would hold the 250gb of data temporarily whilst I changed the filesystem of the drive so I am hoping there is a way to format as ext4 whilst retaining the files?
I know partition magic on windows allowed you to change between filesystems whilst keeping the data but does anything similar (and free! ) exist for linux?

Thanks
 
Old 01-11-2010, 12:36 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

I know you can move from Fat32 to NTFS easily in Windows. In Linux you can have the same from ext3 to ext4 as far as I know (maybe even to other Linux native types). But I seriously doubt that you'll be able to reformat your fat32 to ext4 without losing your data. As far as I know the only way is to copy the data to another location, format the drive and copy the files to the new filesystem. Since you don't have that possibility I don't think you have another option than to stay with fat32.

I hope someone will contradict me and give you a solution.

Kind regards,

Eric
 
Old 01-11-2010, 12:45 AM   #3
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Interesting situation. I believe EricTra is correct on both: I know of no way to "reformat while retaining the data", but you *can* use tune2fs to 'upgrade' from a lesser Ext Linux filesystem, to a newer one.

As for the free version of Partition Magic, that would be "Gparted".

My suggestion for you (which I admit is not pretty), is to shrink the FAT partition as small as you can (to the upper limit of the data on it) using gparted, then in the empty space created on the disk, make a new Ext partition, and move as much data as you can, onto the new partition.
Then delete that data from the FAT partition, and shrink it again..
Then, move the new partition down again into the NEW new space, and stretch it again... See where this is going?

REPEAT: Not pretty. And also, before undertaking such an endeavor, it's always wise to make a backup of all your data before proceeding. Err-- wait now lol. Kidding.

Disclaimer: This is not pretty. Use at own risk!

Sasha
 
Old 01-11-2010, 05:30 AM   #4
DragonSlayer48DX
Registered User
 
Registered: Dec 2006
Posts: 1,454
Blog Entries: 1

Rep: Reputation: 75
Do you have a CD or DVD burner? If so, why not just backup your data, format the HDD, then restore from the backup(s)?

Hope this helps.

Last edited by DragonSlayer48DX; 01-11-2010 at 05:33 AM.
 
Old 01-11-2010, 06:18 AM   #5
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
Hi,
Thatnks for the replies - it was not what I was hoping for, but what I was expecting. My issue is the drive is only 300GB and I'm using over 200GB already. I'm not too keen on doing something which might risk me losing everything!
I thought about backing up to DVD but there's a lot of data and it would also take forever arranging which folders are to go on which disc.

What I might do is wait until someone I know is in the market for a new drive, ask if I ca borrow it before they even use it and then copy everything over, wipe mine and re-format and then copy back over.

With it being FAT, will it suffer from fragmentation problems? I could plug it into my work laptop I guess (running windows) and defrag it now and again, but ultimately I'd rather just get it over to a proper filesystem!

Cheers
 
Old 01-11-2010, 06:44 AM   #6
DragonSlayer48DX
Registered User
 
Registered: Dec 2006
Posts: 1,454
Blog Entries: 1

Rep: Reputation: 75
Quote:
Originally Posted by devnull10 View Post
With it being FAT, will it suffer from fragmentation problems?
Possibly... It depends mostly on how much you manipulate the data. i.e. spreadsheets and databases that are updated frequently could become quite fragmented. However, I'd be concerned with using a Windows defragmenter with Linux files; MS has always warned against using older versions on newer Windows files. If someone else knows better, feel free to correct me, but for now I'd say don't do it.

Cheers
 
Old 01-11-2010, 07:04 AM   #7
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
It's mainly an archive, ie, files written to once, and the maybe accessed but not over-written, replaced, deleted etc.
'd still of course rather move over to a better filesystem - it might be a "project for the future" though!
 
Old 01-11-2010, 07:39 AM   #8
DragonSlayer48DX
Registered User
 
Registered: Dec 2006
Posts: 1,454
Blog Entries: 1

Rep: Reputation: 75
That'd be worth the trouble. The biggest flaw in the FAT32 FS (and why MS moved away from it) was the waste of drive space. The smallest allocatable block was 32k, so effectively and realistically, a 1k file used 32k of space, a 33k file used 64k of space, etc., etc., etc. Depending on how many files you have and their actual sizes, you may regain a substantial amount of free space on the drive by switching.

Cheers
 
Old 01-11-2010, 08:11 AM   #9
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

I'll step in with my

First, move the drive to a M$ based system and do the de-fragmentation since that would be the easiest and safest method.

Then do a backup to the media of choice before you do anything.

If you have the space on your resident OS you could create a smaller backup partition. Then use your parted LiveCD to shrink the FAT filesystem partition since you have about 50GB available. Then create a new 'ext' formatted partition on that space. Then on the M$ drive that you could move a portion of files over to the new ext formatted partition. After that move temporarily another portion of files to the previous created space on the Host filesystem. Once this is done go ahead an shrink the FAT again to extend or create another partition for the ext filesystem on the M$ drive. Repeat the operation until you have the drive converted. Note you will need to have the means to tag what is moved. Not pretty but doable.

You could 'tar' or 'zip' the files for a successful move but then you would be sure to test the archive.

 
Old 01-11-2010, 11:50 AM   #10
Eric Elliott
Member
 
Registered: May 2002
Location: Big Thicket, TX, USA
Distribution: MXLinux sans systemd
Posts: 93

Rep: Reputation: 16
Devnull,
Please compare cost of lost data to cost of having a separate archive. I have paid that cost more than twice. I hope you avoid the data loss troubles I have caused me.
 
Old 01-17-2010, 05:34 PM   #11
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
Surely having a separate archive is better than having the data stored on your os drive? Wouldn't there be less chance of anything going wrong with a drive which is accessed only now and again vs one which is in constant use by other areas of the os?

I have managed to free up some space on my primary hdd so I am in the process of copying everything across. Once I have verified that everything has come across ok I'm going to switch to ext4 and then copy back across. Wish me luck!!
 
Old 01-17-2010, 06:30 PM   #12
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Something to look into is the system rescue cd. It has a tool called fsarchiver that will image a disk, backing up only used bits, it will compress the archive, and it can then restore the data back to a file system different from what the data came from. The cd also has tools like gparted to partition the drive etc. It's really pretty slick, the only downside I see in your case is the amount of data... I'm not sure just how far 250GB can be compressed.

I personally like to have an ntfs archive, just in case I might need a full windows installation at some point, the data is still available without too many hoops to jump through. I generally only mount that disk manually when I want to backup, thus making it a little safer from myself mostly.
 
Old 01-18-2010, 05:39 AM   #13
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
All done successfully. Gained a couple of GB in the process too (not due to lost files before you ask - I made sure I checked thoroughly! )
 
Old 01-18-2010, 05:47 AM   #14
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
so devnull10, what exactly did you do? Did you do like post 11 says, and just copy everything out, reformat, and copy everything back?
Nice @ gaining a few Gib -- good stuff!
 
Old 01-18-2010, 07:31 AM   #15
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
I have my hdd on my machine partioned and mounted against /opt /var /home etc. So I deleted some old stuff and created some folders spread out across these partitions so the total amount would be enough to hold the stuff on the external drive.
I then just copied everything across into those folders (cp command). Then I did a bit of trickery with the shell to basically list all files in the folders and on the drive, sort uniq and do a comparison between old an new. - all ok!
Then I just fdisk'ed the drive and created a new partition of type 82 and used mkfs.ext4 to set it up. Edited my fstab file to be ext4 rather than vfat. Copied everything back across, checked the file list again and then did a recursive update of permissions (they were all 777) to be 755.
All good!
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change partition format without losing data smeezekitty Linux - General 23 10-17-2009 12:31 PM
Format external HDD for linux? closeyetfar Linux - Newbie 2 08-25-2008 08:28 PM
How To Format External HDD GNewbie Ubuntu 13 04-18-2008 10:53 AM
How to partition my HDD without losing any data? deepumnit Debian 4 03-28-2008 03:05 PM
How to format external hdd with open suse 10 rahilrai SUSE / openSUSE 3 03-18-2006 04:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:24 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