Jump to content

partition splitting / resizing


jethro
 Share

Recommended Posts

Hi everybody,

 

I have some unformatted space on my harddrive (sda5) and I want to distribute it between to partitions (sda6 and sda8). I want to add half of the /sda5 to my /sda6 en the other half to my /sda8. How can I go about doing this?

 

This is how things look now:

 

Greetings,

Jethro

post-1634-1148322903_thumb.jpg

Link to comment
Share on other sites

Here is a post I did a while ago when I was resizing stuff:

 

https://mandrivausers.org/index.php?act=ST&f=9&t=30346

 

You have to be very careful, and whilst this should work, I can't be held responsible for ANY data loss. So make sure you have copies of all your data, and be prepared to do a clean install of Linux if it all goes wrong. However, it shouldn't do.

 

This is doable, but ext3 partitions are a pain to resize. First you have to convert them to ext2, and then resize, and then convert back. Last time I did this with ext3 I lost everything. Therefore, I suggest you make sure you still have your copy of all your data that was in your /home partition. Then, I want you to delete everything within your user directory, all your files that are your documents, mp3's, etc, etc, but leave the directory structure so that you still have /home/username/Documents, Video, Pictures, etc, etc, basically all the stuff Mandriva put there.

 

This is because your /dev/sda8 is 22GB and we have about 6GB of data in here, which would make things difficult for when we allocate 4GB of the 8GB free space to each partition. What I've worked out is:

 

/dev/sda5 = 8GB (spare)

/dev/sda6 = 6GB (current root)

/dev/sda7 = 1GB (swap)

/dev/sda8 = 22GB (home)

 

since ext3 is a pain, we're going to create your new partitions with reiserfs. I find it much better anyway. So this is what we do. Boot from your Mandriva One CD and type "live rescue" to get you to a menu, and exit to the command prompt. Now:

 

mkdir /mnt/oldroot
mkdir /mnt/newroot
mkreiserfs /dev/sda5
mount /dev/sda5 /mnt/newroot
mount /dev/sda6 /mnt/oldroot

 

that's the partitions ready and mounted, now we need to copy the filesystem across. Make sure you type this EXACTLY how I have below:

 

cp -R /mnt/oldroot/* /mnt/newroot/

 

The R has to be uppercase and not lowercase, else it will fail. To make sure it's worked do:

 

ls -l /mnt/newroot

 

and if you can see directories such as bin, var, usr, etc, and so on we've copied it all across. You can also use the:

 

df -h

 

to verify disk space taken up in /dev/sda6 versus /dev/sda5. It should be more or less the same. Now, unmount the partitions:

 

umount /mnt/oldroot /mnt/newroot

 

and time for the partition removal and resizing of /dev/sda5.

 

fdisk -l /dev/sda

 

make sure you can see the information correctly. /dev/sda6 should be partition 4 or something like this. You need to know this number, since we need to delete this partition. We also need to delete and readd partition /dev/sda5 so we can resize it. Currently it's 8GB but you want to add 4GB to this to make it 12GB.

 

fdisk /dev/sda
d
4 (or whatever number corresponded from above)
n (new partition)
e (extended partition)
select default start sector by pressing enter
+10000M (to allocate 12GB of space and press enter)
x (for advanced functions)
f (fix partition order)

 

if you press "p" you can view the partitions listed. /dev/sda5 should now be 12GB. To save the partitions, press "w" and it will exit fdisk. Now, do:

 

resize_reiserfs /dev/sda5

 

that will make sure it goes from 8GB to 10GB automatically as it uses all available space. Now, we need to go back into fdisk, and create another extended partition so that we can move the small amount of data from /dev/sda8 to /dev/sda6. But first, we have to delete the swap and move it so that we can allocate the full space to /home. So:

 

fdisk -l /dev/sda

 

and make sure you know the partition number for /dev/sda7 which is swap. This is probably 4 if I'm guessing correctly, but MAKE SURE.

 

fdisk /dev/sda
d
4 (assuming /dev/sda7 was partition 4)
n
e
press enter for default start sector
+1024M (type this to get 1GB of space allocated to swap)
t (to toggle partition type)
82 (for swap)
n
e
press enter for default start sector
press enter for default end sector
x (advanced functions)
f (fix partition order just in case)
w

 

this should now have created the /dev/sda6 as swap and /dev/sda7 as our new home and most likely of about 4GB since this is the remaining space we have left for the time being. Now, we need to create the filesystem on it, and then copy the data across similar to before:

 

mkswap /dev/sda6
mkreiserfs /dev/sda7
mkdir /mnt/oldhome
mkdir /mnt/newhome
mount /dev/sda7 /mnt/newhome
mount /dev/sda8 /mnt/oldhome

 

similar to before. Now the copy command:

 

cp -R /mnt/oldhome/* /mnt/newhome/

 

again make sure it's typed exactly. Once finished, you can verify it copied correctly with:

 

ls -l /mnt/newhome

 

now, the next bit:

 

umount /mnt/oldhome /mnt/newhome

 

to unmount partitions. Now to remove the /dev/sda8 and extend to use the rest of the disk:

 

fdisk -l /dev/sda

 

to get the partition list. Make sure you note the partition number, I'm guessing it is 6. So:

 

fdisk /dev/sda
d
6 (assuming this is the number for /dev/sda8)
d
5
n
e
press enter for default start
press enter for default end
w

 

and then when this is done:

 

resize_reiserfs /dev/sda7

 

and you now have completely allocated your disk how you want it. As I said before you have to be very careful what you do, so make sure when you delete a partition it is the correct one. That way, you won't lose any data.

 

Your system won't boot just yet, so:

 

mount /dev/sda5 /mnt/newroot
chroot /mnt/newroot /bin/bash
source /etc/profile

 

edit /etc/fstab so that your / mount point is now /dev/sda5 instead of /dev/sda6 and instead of saying ext3, change this to "reiserfs". Do the same for /dev/sda8 and change this to /dev/sda7. Change swap from /dev/sda7 to /dev/sda6, and then reboot and you should be back up and running. Here is a sample of my /etc/fstab, so you can see my reiserfs entries and make sure yours look mostly the same for the parameters.

 

# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/hda1 /mnt/windows ntfs umask=0,nls=iso8859-15,ro 0 0
/dev/hda2 / reiserfs notail,noatime 1 1
none /proc proc defaults 0 0
/dev/hda3 swap swap defaults 0 0

 

I only have one partition /dev/hda2 with the reiserfs stuff, so make yours similar to this. /dev/sda7 for your home partition should read "1 2" at the end.

Link to comment
Share on other sites

Alright, I understand the steps, thanks for the clear explanation. I think it looks a bit complicated. Perhaps it is easier to just create a new drive on the spare space I have now and start using that spare space for downloads or something. This at least gives me more space on my home drive.

Link to comment
Share on other sites

In all honesty, if you've recently installed, I would just do a clean install and start again. This is easier if new to Linux in case anything should go wrong when repartioning. Later when more comfortable, you could always try this and see how you get on.

 

You can boot the disk and choose custom partitioning. You can then set the partitions how you want, allocate 10GB to /, 1GB to swap and the rest to /home. The steps outline that it can be done without having to completely reinstall from scratch. It's not overly complicated, just quite a lot of steps to achieve your goal.

Link to comment
Share on other sites

Alright I understand. It is an install from a few months back and it took me quite some time to make it as it is now, so I do not want to reinstall. Perhaps I will try make FAT32 drive on the spare space so I can use it in Linux but also in Windows, this might be convenient. If I do that the drive numbers might change again, so I might have to edit lilo.conf again.

Link to comment
Share on other sites

Possibly yes. They are likely to change since the partitions would require to be in order from beginning to end of the disk. FAT32 is good for sharing between systems, unfortunately you will need to defrag it once a month or so since it will get badly fragmented. And don't go too large with it, I think the limit is around 30GB from various postings I've seen about FAT32 limits. But I've not used FAT32 for ages now, since I used Windows 9x environments, so I've never tested this myself to find out for sure.

 

If you wanted to repartition as originally posted, you have the info anyhow that would help you do this from start to finish.

 

And viewing my link to my previous post, you can see how I did it for my systems.

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...