LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-26-2006, 04:12 AM   #1
nikov3
LQ Newbie
 
Registered: Jun 2006
Posts: 2

Rep: Reputation: 0
How to resize filesystem (image file)? how to truncate the image?


I have one image file that have linux ext2 fs and it is 20gb I want to resize it at 10gb
everybody tell me to create new image that is 10gb and to copy from 20gb image to 10gb but when I copy all and I boot fedora it tell me that fs have some new futures to get new e2fsck

How I can resize image other way I hear that I can user resize2fs but when I resize it image size is still 20gb I have to truncate it how to do that ?
 
Old 06-26-2006, 10:13 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
You can use the program parted (partition editor) to resize a partition. I don't know that it is safe to resize a partition you are currently using. But you can download (either floppy or CD) versions that have their own OS they boot into, so the partition you are modifying is not in use. Some live CDs, such as KNOPPIX also contain parted, and perhaps a graphical interface for it. There is always some danger in doing this sort of operation, so it is best if you have things backed up first.

Quote:
Originally Posted by nikov3
but when I copy all and I boot fedora it tell me that fs have some new futures to get new e2fsck
I don't understand what you mean. If this is still relevant to you, perhaps you could post the exact error message.
 
Old 06-26-2006, 11:42 AM   #3
nikov3
LQ Newbie
 
Registered: Jun 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by blackhole54
You can use the program parted (partition editor) to resize a partition. I don't know that it is safe to resize a partition you are currently using. But you can download (either floppy or CD) versions that have their own OS they boot into, so the partition you are modifying is not in use. Some live CDs, such as KNOPPIX also contain parted, and perhaps a graphical interface for it. There is always some danger in doing this sort of operation, so it is best if you have things backed up first.



I don't understand what you mean. If this is still relevant to you, perhaps you could post the exact error message.

I have uml and fedora is in one image file that is ext2 I need to resize it
 
Old 06-26-2006, 09:03 PM   #4
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by nikov3
I have uml and fedora is in one image file that is ext2 I need to resize it
I am not sure what "uml" is. You can resize your fedora partition using parted, but as I explained in my last post, you need to do so while fedora is not running. You can get a live CD or bootable floppy to do that. And it would be a good idea to back things up first, just in case something bad happens.

What I didn't understand was the error message you got when you tried to boot after copying fedora.
 
Old 06-27-2006, 04:02 AM   #5
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
parted will not be of any help.... parted can resize a partition, not an image file.

When you say (in your first post) you tried to copy from one image file (the 20Gb one) to an other (the 10 Gb one), can you state exactly how you did this ? I see two alternative to acheive your goal. The first one is the fastest one but easy to screw-up. The second is a little longuer but almost errorprone.

--- 1 ---
Now that you have resized your file system with resize2fs, if you know exactly the block size on your image file and the number of blocks used by the remaining file system, just copy those blocks to a new image file (replace <bs>, <fsBlocks> by corresponding values).
Code:
dd if=/path/to/currentImg of=/path/to/newImg bs=<bs> count=<fsBlocks>
Once this is done, you can check your new image file
Code:
e2fsck /path/to/newImg
--- 2 ---
Copy the entire content from one fs to another

Create an empty 10Gb image file:
Code:
dd if=/dev/zero of=/path/to/newImgFile bs=1k count=10485760
Create an ext3 filesystem on the image:
Code:
mke2fs -j /path/to/newImgFile
When you get the warning about the file not being a block special file, just answer yes to proceed.

Mount the current image file and the new one
Code:
mount -o loop /path/to/currentImgFile /path/to/currentMntPoint
mount -o loop /path/to/newImgFile /path/to/newMntPoint
Copy all the content of the current filesystem to the new one preserving permissions
Code:
cd /path/to/currentMntPoint
tar cf - . | tar xfp - -C /path/to/newMntPoint
You can (as in solution 1) check your new image filesystem. DO NOT FORGET TO UNMOUNT FIRST.
Code:
umount /path/to/newMntPoint
e2fsck /path/to/newImgFile
-----
Good luck

Last edited by zeitounator; 06-27-2006 at 04:19 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Resize HDD image thesystem Linux - General 1 10-02-2005 04:28 PM
image resize oldstinkyfish Linux - Software 4 12-16-2004 07:00 AM
Resize Image using ImageMagick mddolloff Linux - Software 1 11-20-2004 06:07 PM
How can I attach a compressed file to /dev/loop0 (for filesystem image recovery)? rjlee Linux - General 0 09-26-2004 05:11 PM
Resize image mikeshn Linux - General 5 11-15-2003 12:43 PM


All times are GMT -5. The time now is 08:10 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration