Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Resize ext4 part., adding free space at start of it [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
gabrielg
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2012
Posts: 134

PostPosted: Sun Dec 02, 2012 3:56 pm    Post subject: Resize ext4 part., adding free space at start of it [SOLVED] Reply with quote

So, this isn't necessarily a Gentoo question, but I'm a bit tired of reading about "free friendly software that does it for you".

I resized ext3 and ext4 partitions in the past, in the good old fashioned way, using resize2fs while the partition was mounted without problems, of course prior to changing the boundaries to the partition, and assuming the free space was at the end of the disc.

Now I'm faced with a new problem, I've got 3 partitions:
/dev/sda1 for EFI boot
/dev/sda2 ext4 (used to be a Fedora boot partition to recognize an LVM one)
/dev/sda3 ext4 (used as main partition for root and everything else)

Obviously, I "inherited" this from a Fedora install, I reformatted sda3 and installed Gentoo. Now I'd like to get rid of sda2 (I really don't need it) and expand sda3 to fill that space.

As far as I know (and researched), I can't do this as straight away as I used to do, since the free space is at the beginning of the partition. So, if I delete sda2 and sda3 and make a new sda2 that covers all the disc, I'll end up with the file system in sda2 that I want to ditch, and if I ditch it prior to repartitioning, resize2fs's man page says that it won't be able to help me.

I believe I'm left with the option of rsync'ing sda3 elsewhere, repartitioning, reformatting and rsync'ing back. But before I do this, does anybody know of a better solution? It would be nice to relocate sda3 into sda2, but I'm not sure that's the right approach.

Thanks!


Gabriel


Last edited by gabrielg on Sun Dec 02, 2012 7:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9601
Location: almost Mile High in the USA

PostPosted: Sun Dec 02, 2012 4:26 pm    Post subject: Reply with quote

Not sure if you can reboot but gparted could handle this situation. It could either move the partition in whole then resize at end, or move the beginning.

The other 'obvious'(?) way is if sda2 is big enough, copy sda3 to sda2 and nuke sda3, and treat it like a normal disk resize...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54028
Location: 56N 3W

PostPosted: Sun Dec 02, 2012 4:26 pm    Post subject: Reply with quote

gabrielg,

Partitions need not be in order on the drive. If you are really lucky, sda2 might use logical blocks that follow on from sda3.
If so, you know what you are doing, as you have done it before.

If you really really want to move sda3 forward into lower logical block numbers, I think parted can do this but as always, make a backup first.

What do you intend to use the extra space for?
Can you make a new filesystem on sda2 and move something like /home to it?

This gives you more space without moving everything around.

*NIX does not care about the physical locations of the volumes in the filesystem tree.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Sun Dec 02, 2012 4:34 pm    Post subject: Reply with quote

NeddySeagoon wrote:
make a backup first

Does'nt this wise advice give the answer to the question ?
Of course, gabrielg, whatever method you choose, you should follow NeddySeagoon's advice !

Then...

Once the backup is made... why bothering looking for another method than... repartition and... restore backup ? :?
_________________
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54028
Location: 56N 3W

PostPosted: Sun Dec 02, 2012 4:43 pm    Post subject: Reply with quote

aCOSwt,

Having a backup implies a total of two or more copies at all times.
If you make a copy, then destroy the original, you no longer have a backup as you only have a single copy again.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
gabrielg
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2012
Posts: 134

PostPosted: Sun Dec 02, 2012 7:14 pm    Post subject: Reply with quote

Thanks, everyone.
I should have pointed out that sda2 is smaller (500MB) than sda3 (499GB), and that sda3 obviously has more than sda2 in terms of used space.

I always keep backups, but not complete binaries or rsync's of the system - that is, if anything fails, I'd need to reinstall Gentoo, meaning a minimum effort involved. I'm happy with that approach for now.
I reckon the easiest and fastest way will be to rsync sda3 somewhere else, repartition and rsync back.

As for whether I could reuse sda2 as some other part of the disc, I thought about that, but this computer in particular is an HTPC-like, so I'd like everything in 1 partition. It is for personal use, so I know I won't fill it up. And if I do, ext4 has reserved space for root, so no problems there.

Thanks again.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum