how to DEcrease disk size

Place to discuss Fedora and/or Red Hat
User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

how to DEcrease disk size

Post by Basher52 » Fri Apr 15, 2011 3:44 pm

I'm still, sorry, on F12 and sure need to upgrade.
Way back when I first had a bad disk on the "system" disk that one was 80G, I only had a 200G lying around.
Next time that happened my other 200G wasn't "big" enough it said, so I put a 500G in there.
Now it seems I got more bad blocks etc but I need to lower the size 'cos I don't want to put a 1Tb HDD in there.

My question from all of this is, how do I decrease the image so I can put it all on a smaller HDD?
Used space on the system disk's partitions is about 30G, so an 80G disk should be sufficient.

Can anyone tell me how to do this?

What I can think of is that I need to "move" all data to the "beginning" of the HDD, then make an image it but not the entire disk, just the data.
I've tried that with no luck since the image seem to get as big as the HDD, hence why I always needed to increase the HDD all the time.

Please help :)

//TIA B52

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: how to DEcrease disk size

Post by Void Main » Sun Apr 17, 2011 4:11 pm

Although you "can" shrink your partition that's not how I would do it. I would put the 2nd drive in, format it and copy all the data over at the file level (rsync would be good for that). You don't want the file system that you are copying to be active so if it's got your root file system on it you would want to boot from either rescue mode or a Live CD to do the copy from. You'll want to check over your fstab file on the new drive to make sure all the device references are correct for the new drive after copying.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Mon Apr 18, 2011 12:27 pm

Don't I need to reinstall grub on the new disk after that?
cos just copying files won't make the disk bootable, will it?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: how to DEcrease disk size

Post by Void Main » Mon Apr 18, 2011 2:25 pm

I assume you have a separate /boot partition that you are copying over as well? You want to keep /boot in a relatively small partition (~100-250MB)at the beginning of the drive. You can create the /boot partition first and copy your data over with rsync but yes the first time you boot with the new drive and the old one removed you'll have to boot from alternate media, mount your file systems and chroot onto the new drive and run the "grub-install <device>".

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Tue Apr 19, 2011 10:21 am

ok, as I assumed then :)
thx

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Tue Apr 19, 2011 12:48 pm

Another question doing this... Isn't there a way to like "refresh" the udev lists of devices?
I added the disk but I had to reboot to get it up in the /dev list.
Been googling this too and they all say:

Code: Select all

udevadm trigger
but that won't work.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: how to DEcrease disk size

Post by Void Main » Tue Apr 19, 2011 4:59 pm

What kind of drive are you hooking up? I guess you can hot plug a SATA drive but I've never done it. I would shut the system down before even plugging in a SATA drive but that's me. USB is the only thing I would be comfortable hot plugging on low end hardware and USB devices should be detected just fine.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Wed Apr 20, 2011 2:24 pm

It's a SATA yes. Usually does that with drives in winblows and that seems to work so I figured... ah well, I'll try more later.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Wed Apr 20, 2011 2:55 pm

Using rsync for the /boot I get this:

Code: Select all

skipping non-regular file "grub/menu.lst"
skipping non-regular file "grub/menu.lst.rpmsave"
seems they are symlinks but these should be copied too, right?
Can't seem to find the proper switch for it to be copied though :(

UPDATE:
Just found it, just using

Code: Select all

--links
UPDATE2:

I'll just use

Code: Select all

rsync -ar --exclude='yada' / .
First I thought that the archive would like pack them all to a backup file or something, but when I tried it, it seemed to work :)

instead of using:

Code: Select all

rsync -prlt --exclude='yada' / .
that still seemed to have problems with some stuff.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: how to DEcrease disk size

Post by Void Main » Thu Apr 21, 2011 6:30 am

Yes, I always use -av.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Thu Apr 21, 2011 1:01 pm

well if I used 'v' do they sum up the possible errors/warnings at the end?
because it's lots of files and I can't see that long back in the SSH session, just 9999 lines

UPDATE:

Code: Select all

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]
I'm gonna redo this so I can see what files it is.

UPDATE2:
Seems there's lots of "files" not getting copied but since they all are under /sys, like /sys/devices and such I figure that is OK... right?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: how to DEcrease disk size

Post by Void Main » Thu Apr 21, 2011 2:56 pm

Basher52 wrote:well if I used 'v' do they sum up the possible errors/warnings at the end?
because it's lots of files and I can't see that long back in the SSH session, just 9999 lines

UPDATE:

Code: Select all

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]
I'm gonna redo this so I can see what files it is.

UPDATE2:
Seems there's lots of "files" not getting copied but since they all are under /sys, like /sys/devices and such I figure that is OK... right?
You don't want to copy /sys /proc and all those other file systems. You need to make sure it stays on your root file system which is why I would do it from rescue mode or something similar and mount the partition that you want to copy somewhere other than "/". OR just add the "-x" rsync switch so it doesn't try to copy files outside of the intended file system. You should have 0 errors if you do it right. Redirect the output to a file and open it with an editor if you want to look back on the rsync output.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Thu Apr 21, 2011 3:16 pm

Since I use the same machine as my gateway I can't just shut it down so I'll have to do it online, I'll try the -x thingy :)
thx

/sys & /proc I figured was system files but I had to ask just to be sure.
so these files don't exist when in rescue mode? if so THAT I didn't know, I just figured they were in use by the system.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: how to DEcrease disk size

Post by Basher52 » Fri Apr 22, 2011 2:09 pm

Don't seem to be able to install grub again.
First it said that it's already installed, so I 'rpm -e' it.
Next it won't be installed cos it's trying to get the files through internet, but I got my own repo on the server just for this cos.
A pal long time ago showed me how to set it up thus all files are rsynced to my server and all installes/updates are taken from that.
Trying to use the NIC just starts the NetworkManager and that doesn't work it seems. And I know that if that is in use something is always making the network not to work.

Can I install grub from the F12 CD I got when in rescue mode?
If yes, then how can I do that.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: how to DEcrease disk size

Post by Void Main » Fri Apr 22, 2011 2:25 pm

You weren't trying to install grub to your boot sector using rpm commands were you? The grub package being installed is not the same as installing grub to your boot sector. Sounds like you already had the grub package installed but you use the "grub-install" command as I mentiond before to install grub to your boot sector.

Post Reply