Jump to content

Changing Linux partition size


Paul Goelz
 Share

Recommended Posts

OK, second question for the day.....

 

I put Mandriva on a 40GB drive that is hdb on my machine. I was initially thinking of installing Xandros again and maybe others so I made the Mandriva partition about 5GB and left the rest uncommitted. I'm liking Mandriva enough to consider increasing the size of the Mandriva partition and not attempt any further installs.

 

Can I change the size of the Mandriva partition via Mandriva? I know there is a partition manager but I am not sure what happens if you use to to change the size of the partition containing Mandriva while Manmdriva is running. If not, what about Partition Magic under Windows? My HD is formatted as ext3 so PM can see it and manipulate it.

 

If I use something external to Mandriva, do I have to reconfigure anything afterwards? Windows doesn't care if the partition it is on gets bigger or smaller but I'm not sure about Linux..... I don't want to kill my installation.

 

The same question applies if I move everything to another HD..... do I have to do anything other than boot from CD1 and put the boot image on the MBR of the new drive? Or is that not necessary since I use BootMagic (dual boot with XP) and BootMagic can find the boot information on /boot? Or will THAT be screwed up if I move everything to a different HD?

 

Paul

Link to comment
Share on other sites

You can resize from within Mandriva, IIRC, it just does it on reboot. You could also use PM or even get a GParted LiveCD. As long as the partition doesn't change name (i.e. /dev/hda1 or whatever it is) Mandriva shouldn't even hiccup.

Link to comment
Share on other sites

Also, the beginning of the partition cannot be moved, you can only resize it from the end. Moving the beginning of the partition, and you'll lose all your data.

 

You can move data about from one partition to another and even have name changes, but it requires editing the boot loader and /etc/fstab files so that it knows where to read the new locations from. I've done this many times myself - and even when I needed to use space before an existing partition, I created one before it, then copied the data to it, deleted the old one and then extended the new one over the place where the old partition used to be (if that makes sense :P)

 

That's the only way you can do it to utilise space before an existing partition. Would be easier if you could resize from the left, but unfortunately, can only be done from the right without losing data.

 

For example, let's say I have /dev/hdb and on this disk I have 3 partitions:

 

/ = 40GB
/home = 80GB

 

OK, now I realised later that I made / too big, and so resized it to 10GB. This leaves a gap of 30GB which I cannot allocate to /home, because it's before it, and not after. So I create a partition in between and as long as the data on /home is no more than 30GB I can move all this to the new partition, update the boot loader, and /etc/fstab, and boot the system from the new disk. Then I delete the old /home of 80GB, and then extend the new home from 30GB to 110GB. Neat :)

 

If you have more data than what is able to fit, then copy to other machines over ftp/ssh and then copy back later. Although, not possible for system-related partitions that *have* to exist before the system can boot.

Link to comment
Share on other sites

Wow, that was fast!

 

OK, when I feel brave I'll try re-sizing within Mandriva. Linux looks to be a lot neater about adding programs without adding bloat, so it may be a while before I really need to expand. For now all my big stuff (like MP3s) are on an NTFS partition on my Windows drive and Mandriva can see them just fine.

 

I do have a copy of Acronis so I can make a backup image in case it all goes pear shaped. I haven't tried the backup options in Mandriva just yet..... maybe I should?

 

Paul

Link to comment
Share on other sites

Remember if acronis can't read Linux partitions, it will do a sector copy and backup exactly the same size as your hard disk. So, if Linux is using 80GB on the disk, the image will be 80GB too.

 

If it's a Linux version of acronis it should be OK.

Link to comment
Share on other sites

Acronis Disk Director is very good if you have it. Excellent linux support and great flexibility in resizing partitions. It can handle ext2, ext3 and reiserfs. You can perform the operations on linux partitions from within windows or boot the cd version and do it that way.

I've found it to be the most reliable partitioning tool for dealing with both linux and windows partitions, especially where both exist on the same hard drive. Even so, resizing partitions is the riskiest operation for any partitioning tool so always back up first.

Edited by pmpatrick
Link to comment
Share on other sites

Is there any chance of losing data if I resize from the right and there is data at the top end of the partition? Or doesn't Linux store data as randomly as Windows does?

 

Does Linux care where the data is, as long as A) it can see it and B) the boot loader refers to the correct start point? In other words, if I use PartitionMagic to move the entire partition somewhere else or even add a partition before the Linux partition, then boot from the CD and fix lilo, am I good to go? Does this apply to the swap space as well?

 

Thanks,

Paul

Link to comment
Share on other sites

Is there any chance of losing data if I resize from the right and there is data at the top end of the partition? Or doesn't Linux store data as randomly as Windows does?
technically, there's always a chance of that. but linux is much better at keeping it's data well organized (I once did an rm -rf on an entire partition, and fixed it in an hour - no lost data) than windows is known to be - i.e., you don't even have to defragment. So while there is a chance, it's much less so than with Windows.

 

Does Linux care where the data is, as long as A) it can see it and B) the boot loader refers to the correct start point?
It has to have the right starting sector (knows where the partition is), has to be able to read it and it needs a valid journal - if you use a journalized filesystem, which you should.
In other words, if I use PartitionMagic to move the entire partition somewhere else or even add a partition before the Linux partition, then boot from the CD and fix lilo, am I good to go? Does this apply to the swap space as well?
You'll need to fix both LILO and fstab (/etc/fstab - it holds the mount points of all the devices), this is best done from a livecd and will require some knowledge of /etc/fstab and lilo.conf - you could easily ask here any questions you may have, and we'd be able to help you out.
Link to comment
Share on other sites

my two cents -

 

I've done many moves/resizes with both mandriva using diskdrake and from the command line and I've done many resizes with PM 8.0 pro. I'd choose diskdrake hands down over PM. This is one good reason to use ext3 as your format for your operating system. PM has screwed my data only once or twice whereas I've yet to wipeout using diskdrake (or linux command line tools).

Link to comment
Share on other sites

Always had problems trying to resize ext3 partitions. You have to convert them to ext2 first by removing the journaling, and even after this it didn't want to resize.

 

Reiserfs is by far the best for resizing, at least in my experience.

Link to comment
Share on other sites

Thanks guys. Last night I decided to give it a go and discovered that I can't change the size of the Linux partition while running Linux. At least not in DiskDrake. It wants to unmount it first and it says it can't do that. I am not surprized. I tried it from the command line as well. I even tried booting from the install disk and working from the command line there, but I wasn't able to mount the partition. Not sure why but I suspect it had to do with where the kernal was runnign when booted from the install CD?

 

So I decided to risk it and let PM do the job. Worked fine. I don't think I will ever have to move it.... the swapspace is first, then the Linux partition. All free space is to the right.

 

So did I miss anyting.... was DiskDrake supposed to be able to resize the active partition?

 

Paul

Link to comment
Share on other sites

Nope, you can't resize an active partition. You could have used partitioning tools from the bootable CD or even live CD's like gparted to resize. But, they cannot be mounted. Otherwise, you might end up with data loss if this was possible - in fact I'm sure of it.

 

Unmounted is safer for it, that's why when using Partition Magic, it does a lot of it when you reboot, before the file systems are active.

Link to comment
Share on other sites

I'll have a look and see if I can find parted from the install cd. If the linux partition can't be mounted, parted has to be on the install CD, right? I forget whether I saw it or not.

 

I figured DiskDrake might be able to store the desired resize action and then resize on the next boot like PM does.

Link to comment
Share on other sites

If it's a Linux version of acronis it should be OK.

 

The Acronis bootCD is actually a minimal Linux liveCD, which loads a heavily modded 2.6.X kernel and a customized gui. And yes, it does recognize ext2/3, ReiserFS 3.X, XFS, JFS, FAT32, NTFS perfectly well, as well as most network cards and protocols, and can image to local drives, USB drives, network shares. It's limitations are the ones of the included Linux kernel- the software changelog may, or may not give you an idea if your hardware is supported.

Link to comment
Share on other sites

According to this:

 

http://www.acronis.com/homecomputing/produ...q/file-systems/

 

Acronis Disk Director does not support xfs or jfs. That's for v10.0; I have v9.0 which has the same filesystem support. I also believe the enterprise imaging software from acronis does support xfs and jfs but not the home version(True Image 10.0).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...