LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 02-24-2004, 06:02 PM   #1
loudhoward
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Rep: Reputation: 0
The amazing shrinking partition


I am running Redhat 9 - kernel 2.4.20-8. I have a 40G drive which is partioned thus:

/dev/hda1 /boot 80M
/dev/hda2 / 10G
/dev/hda4 /var 28G
/dev/hda3 swap 512M


My issue is this. I copied the data on a previous partition of 2.7G to the new root using the following command when the 40G was mounted in an external case and known as /dev/sda and the small hard drive was /dev/hda:

dd if=/dev/hda2 of=/dev/sda2

This resulted in the data being duplicated but had a nasty side effect. When I mount /dev/hda2 (10G) it shows up with df -h as being 2.7G. I checked that the partition table wasn't screwed up using cfdisk and it is still identified as a 10G partition. Does anyone know who to reclaim this space and have a tip for what command to use next time I want to do something similar?

Thanks
 
Old 02-24-2004, 07:17 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,579

Rep: Reputation: 187Reputation: 187
"Does anyone know who to reclaim this space"

You will have to format the partition which will also wipe out your data in that partition. Use one of the mkfs commands to format the partition, depending on the file system type.

"have a tip for what command to use next time I want to do something similar?"

mount each of the partitions on a directory and then use the cp command to copy the contents of one directory to the other directory.


___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 02-24-2004, 07:51 PM   #3
arnold
Member
 
Registered: Dec 2002
Posts: 226

Rep: Reputation: 30
try
umount /dev/hda2
fsck -f /dev/hda2
 
Old 02-24-2004, 07:56 PM   #4
mhiggins
Member
 
Registered: Feb 2004
Posts: 140

Rep: Reputation: 15
You may be able to get away with using resizee2fs or parted.
 
Old 02-24-2004, 08:04 PM   #5
arnold
Member
 
Registered: Dec 2002
Posts: 226

Rep: Reputation: 30
if that does not work, try this - some what nervewracking. I use fdisk. For illustration, my hda:

Disk /dev/hda: 255 heads, 63 sectors, 4998 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 530 4257193+ c Win95 FAT32 (LBA)
/dev/hda2 531 1060 4257225 c Win95 FAT32 (LBA)
/dev/hda3 1061 1590 4257225 83 Linux
/dev/hda4 1591 4998 27374760 5 Extended
/dev/hda5 1591 2591 8040501 83 Linux

you can "repartition" hda2 if the "End" is not 1 less than Start of hda3 (or end of disk) or if # Blocks is too low. Just be sure that the partitions do not overlap and that they start at the same sector as shown in Start. Then fsck. This should not clobber any data.
 
Old 02-24-2004, 08:26 PM   #6
loudhoward
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thumbs up

Thank you all so far for your insightful answers.

Steve
I agree that it looks like I will have to start from scratch with that partition. Last night when after I did the dd the box started having issues with quite a few files and when I fsck'ed it had heaps of inodes and what not that it fixed. This resulted quite a bit of the data being non-existent after the repair. At that point I started doing as you suggested (using cp instead) sans remaking the filesystem. The size discrepency only occurred to me when I was copying /usr and it said that it ran out of space. It was about 1:30am and I had to get this system back online at least for the day (runs our in house ticketing system) because I didn't have a machine to use as a backup for this one so I just shifted a few things around to get the thing up.


Arnold
I will fsck -f this evening (I have done regular fsck which show up fine).
The blocks and everything else line up correctly.

Thankyou all for your responses.
 
Old 02-25-2004, 10:29 AM   #7
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,579

Rep: Reputation: 187Reputation: 187
When you use cp to copy large file trees you have to be careful of ownership and permissions. cp has a tendency to make everything root, root. So take a look at the cp parameters in man cp to avoid this problem.


___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 02-25-2004, 04:50 PM   #8
loudhoward
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Haha Thanks Steve but I learned that the hard way before this little saga. The first time that I copied files over the new hard drive and logged in the user that I logged in as couldn't browse its own directories or run any apps because everything was owned by root.

Being a sysadmin rocks.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shrinking an LVM partition Sabre_X Linux - Software 6 10-01-2005 12:13 AM
Shrinking an extended partition lobo78 Linux - General 1 12-02-2004 12:59 PM
amazing shrinking text Jay-eye Linux - Newbie 15 02-04-2004 04:40 PM
Shrinking Linux Partition w/ Partition Magic jrdioko Linux - Newbie 11 12-21-2003 04:46 PM
partition or shrinking? M@tt Linux - Newbie 2 11-12-2001 10:35 AM


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