Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Resizing disk partitions

  1. #1
    Join Date
    Jun 2008
    Location
    Delta Quadrant
    Posts
    1,383

    Default Resizing disk partitions

    Trying to resize ext3 filesystem /home from 8GB to 4GB.
    Less than 1GB of data on it.

    Started out by going into init 1 and
    unmounting the filesystem.

    Next tried using parted, but it flames out with filesystem
    has unknown flags. So moved on to using

    # e2fsck -f /dev/hda2
    # resize2fs -p /dev/hda2 4G

    This ran a nifty little process and then ended saying all was well.

    Restarted the box and booted into runlevel 5.
    Pull up the partitions table using the YaST partitioner
    tool....old partition aizes still there, no size change.
    Go into shell, df -v, old sizes still in place.

    So what exactly did the system think it was doing when I was at
    runlevel 1?? It seems to have done nothing.

  2. #2
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    25,781
    Blog Entries
    30

    Default Re: Resizing disk partitions

    Quote Originally Posted by GofBorg View Post
    Trying to resize ext3 filesystem /home from 8GB to 4GB.
    I was a bit curious as to your views on this resizing, now that some time has gone by.

    I'm thinking of changing around the partitions on the family Dell Studio 1537 laptop today. I plan to downsizing a loglical /dev/sda7 (131 GB) ext3 to 100 GB, and then create a /dev/sda8 of 31GB which my wife will be able to use to install winXP. There is already Vista on a primary /dev/sda3, so the speculation is that will work.

    While I plan to do a re-install of openSUSE-11.1 (so as to have a clean KDE-4.3 as opposed to its older KDE-3.5.10) and reformat the / and /home (which is backed up), I was thinking it might be fun to play around first, and see if I could resize the /home without losing data (and then reformat it per my plan). The idea being I might learn something at no risk.

    Instead of run level 1, I plan to do this from a live CD. ...

    So to resize, am I correct that all you did was
    Code:
     # e2fsck -f /dev/hda2
    # resize2fs -p /dev/hda2 4G
    There are some guides on resizing ext3, but they all assume a 2.4.x kernel and an older version of resize2fs, and hence they convert the ext3 to an ext2 prior to the resize. From what I have read that conversion to ext2 should not be necessary. Those guides:

    Which has me thinking I could simply from the liveCD:
    • e2fsck -f /dev/sda7
    • use “resize2fs /dev/sda7 100G” to resize the file system.
    • use fdisk to resize the partition: delete the old partition (purportedly no data will be lost ). There is guidance on using fdisk here, for doing that: How To Resize ext3 Partitions Without Losing Data | HowtoForge - Linux Howtos and Tutorials Create a new one of the desired size (which is tricky and caution needed - again see the two URLs above that describe how). Save changes.
    • use “resize2fs /dev/sda7” (no size this time) to resize the file system to the maximum available.


    ... I have not decided yet if I will try this ... It boils down to how much time I have to play on this today. Its really a matter of time spent learning something, as opposed to data loss concerns (as I plan to wipe the /sda7 partition anyway).

  3. #3
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    25,781
    Blog Entries
    30

    Default Re: Resizing disk partitions

    Quote Originally Posted by oldcpu View Post
    There are some guides on resizing ext3, but they all assume a 2.4.x kernel and an older version of resize2fs, and hence they convert the ext3 to an ext2 prior to the resize. From what I have read that conversion to ext2 should not be necessary.
    That is to say not necessary on a 2.6.27 kernel with the latest resize2fs.

  4. #4
    Join Date
    Oct 2008
    Location
    Birmingham. AL
    Posts
    839

    Default Re: Resizing disk partitions

    Quote Originally Posted by oldcpu View Post
    I'm thinking of changing around the partitions on the family Dell Studio 1537 laptop today ...
    Instead of run level 1, I plan to do this from a live CD. ...
    The only way to go, in my opinion. Download Parted Magic, boot onto the CD, and use Parted in that.

    I wonder if the version of Parted that came with 11.1 was old, or had bugs? I've had trouble with it as well. But the version on the Parted Magic CD flies like a bird.

  5. #5
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    25,781
    Blog Entries
    30

    Default Re: Resizing disk partitions

    Quote Originally Posted by oldcpu View Post
    I'm thinking of changing around the partitions on the family Dell Studio 1537 laptop today........... I have not decided yet if I will try this ... It boils down to how much time I have to play on this today. Its really a matter of time spent learning something, as opposed to data loss concerns (as I plan to wipe the /sda7 partition anyway).
    The wife just got up, and after some discussion we both 'nix'd the idea for now. ... ie we are not going to downsize openSUSE-11.1 nor install WinXP yet.

    The reason being winXP on Virtual Box is working ok again (after having some tlc applied to it) and we are leaving on a vacation in less than 2 weeks, and we don't want to risk my messing things up now. ... So this is another task shelved until after we return from vacation.

  6. #6
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    25,781
    Blog Entries
    30

    Default Re: Resizing disk partitions

    Quote Originally Posted by smpoole7 View Post
    The only way to go, in my opinion. Download Parted Magic, boot onto the CD, and use Parted in that..
    I have both gparted live CD and Parted Magic. I assume, though, one still needs to run e2fsck, resize2fs (twice), and fdisk to resize (as opposed to using the program gparted). The concern with using gparted is it would lose data.

  7. #7
    Join Date
    May 2009
    Location
    EU
    Posts
    1,009

    Default Re: Resizing disk partitions

    This interests me too. I'm about to reduce my XP partition right down to the minimum and then increase my /home partion slightly and create a new partition remaining space to install 11.2 test releases on to.

    I'm torn between just biting the bullet and backing up the data, resizing everything and then doing a clean install of 11.1; or trying to resize the partions and hopefully keeping everything in tact.
    IBM Thinkpad X60s | Intel L2400 | Intel 945GM | 3GB | openSUSE 12.3 | KDE4.10.1
    ASUS M3N78 | AMD 64x2 5400+ | nvidia 8200+ | 2GB | openSUSE 12.3 | KDE4.10.1
    Acer Aspire Revo R3610 | Atom 330 | nvidia ION | 2GB | openSUSE 12.3 | KDE4.10.1

  8. #8
    Will Honea NNTP User

    Default Re: Resizing disk partitions

    suse tpx60s wrote:

    >
    > This interests me too. I'm about to reduce my XP partition right down to
    > the minimum and then increase my /home partion slightly and create a new
    > partition remaining space to install 11.2 test releases on to.
    >
    > I'm torn between just biting the bullet and backing up the data,
    > resizing everything and then doing a clean install of 11.1; or trying to
    > resize the partions and hopefully keeping everything in tact.


    Resizing XP can get to be a real PITA. Some tips from some long discussions
    over the last couple of years:

    1. From XP, turn off the off the swap file ("virtual memory") then boot to
    safe mode and delete the swap file. Remember to turn the swap file back on
    after you get the partition resized.

    2. From XP, defrag until you get as many of the files to the front as
    possible. Running on a mounted partition, about the best you will achieve
    is about 50% of the original size - no matter how much free space there
    is - because of open system files that M$ puts at the center of the disk.

    The best result I've been able to get is to mount the disk in another
    machine and defrag/compress it from another copy of XP so that there are no
    open files, period. Then resize before you return the disk to the boot
    position.

    Any way you go, XP and its' brethren are tedious to reduce if you want to
    reduce the partition beyond 50-60% of the original (initial creation) size.

    Also be aware of a potential trap here. In the typical case, the XP
    partition is the first primary on the disk and any free space will be
    before the existing Linux partitions. You can only extend partitions from
    the end, not the beginning, of an existing partition so unless you free up
    enough space to create a new partition big enough to hold a copy of one of
    your existing partitions - or at least all the data on it - you have no
    good way to actually use the freed space. And then there is the problem of
    grub - unless you move your / partition to the newly created partition you
    boot fails because the partition map changes and grub gets lost.

    Have fun ;-)

    --
    Will Honea

  9. #9
    Join Date
    May 2009
    Location
    EU
    Posts
    1,009

    Default Re: Resizing disk partitions

    Thanks for the tips. So if you can only extend a partition from the end, is it possible for me to move all the partitions to fill the empty space created by shrinking the XP partition, effectively moving the free space to the end of the disk?

    Every way I look at this makes me think I'll just be better off saving my Linux data and doing a factory restore from the recovery partition, shrink the partition and reinstall the few apps I need in XP; then partition the rest of the disk for a fresh 11.1 and 11.2 install. I just don't have the time for that at the moment.
    IBM Thinkpad X60s | Intel L2400 | Intel 945GM | 3GB | openSUSE 12.3 | KDE4.10.1
    ASUS M3N78 | AMD 64x2 5400+ | nvidia 8200+ | 2GB | openSUSE 12.3 | KDE4.10.1
    Acer Aspire Revo R3610 | Atom 330 | nvidia ION | 2GB | openSUSE 12.3 | KDE4.10.1

  10. #10
    Will Honea NNTP User

    Default Re: Resizing disk partitions

    suse tpx60s wrote:

    >
    > Thanks for the tips. So if you can only extend a partition from the end,
    > is it possible for me to move all the partitions to fill the empty space
    > created by shrinking the XP partition, effectively moving the free space
    > to the end of the disk?
    >
    > Every way I look at this makes me think I'll just be better off saving
    > my Linux data and doing a factory restore from the recovery partition,
    > shrink the partition and reinstall the few apps I need in XP; then
    > partition the rest of the disk for a fresh 11.1 and 11.2 install. I just
    > don't have the time for that at the moment.


    You can play musical chairs any way you want and with a little planning
    things could work out pretty simply. Here's an example.

    Let's say you machine came with XP, no recovery (maintenance) partition, so
    XP has the whole disk. For illustration purposes, let's assume a 100GB
    drive. You boot XP and then shut down. You boot your favorite partition
    editor tool and you shrink XP as far as it will go. Best you will do at
    this point is free something under 50GB because XP has put files at the
    midpoint of the drive - 50GB out. Now, XP will run fine with 10GB or a
    little less but you can't get there from here. You only have less than
    50GB free for Linux. If you had planned ahead and shrunk the XP partition
    before you ever booted it, you might get it down close the 10 GB or so
    range but you didn't because that's what you want to do now.

    OK, you put Linux on 3 (sda2 as /, sda3 as /home, sda4 as swap. XP is on
    sda1) new partitions that fill the rest of the disk and they are all
    primaries - you're SOL because you just filled all 4 MBR partition table
    entries so you can't create any more. OK, let's put all 3 Linux partitions
    into and extended partition and logical partitions; Linux uses sda5, 6, and
    7. Now you have some play room. There are some other quirks due to MBR
    partition table order and such but that's just going to confuse matters and
    shouldn't cause a problem. FYI, with just a single Win partition, I
    allocate two more primaries and and extended partition just to insure an
    order in the table I'm sure will work for any OS but that's not really
    relvant to the problem.

    OK, you manage to shrink XP to 10GB. That leaves you with a free space hole
    between XP and your first Linux partition of some 40GB. Figure out how
    much room you have to have to hold you root partition - use df. Allow a
    comfortable fudge factor and allocate a PRIMARY partition at the head of
    the free space. Note that this becomes sda2 and this is not the final
    size - you'll expand it later. If your original root partition was sda2,
    it will shift to being sda3, so it WILL NOT BOOT unless /home was on a
    logical partition (sda5 or higher)! Use a live cd and copy the entire
    original root partition to the new sda2. If the original root partition
    was sda2, you're home free - it will start to boot (but it won't complete
    since you have an extra partiton between / and /home right now unless /home
    was on sda5+). If the original / partiton was sda2 and is now sda3, you
    can delete sda3 and probably boot very happily. Assuming / was originally
    on a primary partition as sda2, deleting it after the copy will leave you
    with another hole. Repeat the process of creating a new partition but make
    it just a little larger than the data size in your /home. Copy /home
    contents to this, free the original /home and you have an even bigger free
    space. Delete and recreate /swap at the head of this and every thing is
    free to the end of the disk. Play with the mapping you want in that free
    space and repeat the process above to finally get things where you want
    them in the sizes desired. Draw lots of pictures of the drive map and that
    should be fairly straight forward. If all you Linux partitions were on an
    extended partition, things get sticky. Just remember that the partition
    assignment (sda1,1,3,etc.) is affect by any partitions you create or delete
    and you should be OK. Also bear in mind that XP will be very unhappy if
    you move it to any partition that does not start where the original started
    or if you try to add a partition ahead of it.

    If you elect to re-install XP and do it from recovery disks you should know
    that most of these recoveries recreate the original disk map and will
    overwrite anything you have added. Of all the ones I've messed with, only
    IBM/Lenovo was nice enough to restore to whatever drive C you provide and
    don't mess with existing partitioning - the rest just seem to grab the
    whole disk.

    If you decide to press on, email me directly and I'll try and help you as I
    can - the email address here is valid.

    I think that backing up your /home and starting over might be simpler. The
    only time I do the image copy thing is when re-configuring a system running
    lot's of added apps that install in the / patriron (/opt, /user, etc) and
    would have to be re-installed and tweeked.

    --
    Will Honea

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •