Jump to content


Photo
- - - - -

Resizing linux partition


  • Please log in to reply
12 replies to this topic

#1 bardolph

bardolph

    DDP Fan club member

  • Members
  • 50 posts
  • Gender:Male

Posted 12 December 2010 - 06:23 PM

I run ubuntu from a 400G hdd which the linux partition is 35G and the rest another NTFS partition - since 10G will still be ok for ubuntu I would like to resize the linux partition and assign 20G to the NTFS partition - how can I do that without reinstalling ubuntu?

#2 phaedrus

phaedrus

    Gibson Hacker

  • Members
  • 90 posts
  • Gender:Male

Posted 13 December 2010 - 02:57 AM

I run ubuntu from a 400G hdd which the linux partition is 35G and the rest another NTFS partition - since 10G will still be ok for ubuntu I would like to resize the linux partition and assign 20G to the NTFS partition - how can I do that without reinstalling ubuntu?

I think ubuntu uses ext3 for its fs, although it depends on what you chose at install time possibly. Do a "mount" first and see what is in use on it of course.
http://www.howtoforg...ext3_partitions

Shrink the ext3 partition, then grow the ntfs one to suit. FIPS, partd, partition magic etc for that.

#3 bardolph

bardolph

    DDP Fan club member

  • Members
  • 50 posts
  • Gender:Male

Posted 13 December 2010 - 10:35 PM

damn with this tutorial i feel i have 99% chance to screw any of these steps :blink:
thanks anyway

#4 phaedrus

phaedrus

    Gibson Hacker

  • Members
  • 90 posts
  • Gender:Male

Posted 14 December 2010 - 03:23 AM

Go through the steps in the tutorial, make sure you understand what its trying to do and why, look up the commands and read their man pages.
Then follow it, it might be daunting changing filesystem types and resizing them on the fly but there will potentially be situations in your future that knowing your way around these tools will prove of great use, and slipping beneath the hood and learning a bunch along the way is what linux is about. If you have a second drive of >40G or can borrow one, make a clone of it first with driveimage or acronis or any of the other drive cloners, and you have your safety blanket in place too. And make sure you backup any especially important data in a 3rd place (usb key etc) before starting.

You'll still feel sick the moment you delete the partition away though. Less so if you have a clone as a safety net...
  • bardolph likes this

#5 bardolph

bardolph

    DDP Fan club member

  • Members
  • 50 posts
  • Gender:Male

Posted 15 December 2010 - 02:22 PM

I don't worry if I screw the NTFS partition as it is secondary hdd - I am concerned about the linux partition - is there a way to back up as we do in windows with acronis etc?

#6 phaedrus

phaedrus

    Gibson Hacker

  • Members
  • 90 posts
  • Gender:Male

Posted 16 December 2010 - 06:34 AM

You can DD the whole partition off to another device with a single command. Or take a tar with the -p flag set to preserve attributes. The trick is to do this while booted from a usb key or live cd so the filesystem doesnt change while your doing it.

dd if=/dev/sda_drive_partition_i_want_to_save of=/dev/sdb_new_partition conv=noerror,sync

The noerror flag tells it to not halt on errors since I am usually replacing something thats making odd noises. Note that sdb is not on the same physical drive/interface as sda...

You can even copy accross the network in realtime using ssh :-
dd if=/dev/sdb_drive_partition_i_want_to_save | ssh user@remotebackuphost "dd of=/home/user/partition_backup_of_original_machine.image"


When I run out of space on my server, I buy a bigger drive for it since capacity is coming down in price all the time, dd the (encrypted) partitions over to the new drive and grow them, then I shelve the old drive somewhere physically else safe as a good known restore backup . When I do it the next time, I take the oldest spare drive and use it somewhere else once the main drive has been replaced safely once more. Beats the crap out of finding your backup tape has stretched when your in a jam...
I have a sd card setup with hackmii and other bits to do wii homebrews, and I keep a DD image of that and just drop it on a card as usually friends bum the one I use on the day...

And being linux theres ALWAYS more than one way to do it , and of course theres a gui way and its a bit more efficient as it only backs up space in use. But cmd line dd is much more elegant once you have learned it, in the same way as vi is still a great editor because *everything* has it installed default. Partimage on the sysresccd is the tool of choice for this and comes wrapped round with a bootable cd as above.

sysrecord with partimage installed

#7 phaedrus

phaedrus

    Gibson Hacker

  • Members
  • 90 posts
  • Gender:Male

Posted 16 December 2010 - 06:39 AM

While your at it take a backup of the partition table so you can restore partitions easy, and that way if windows ever kills the mbr etc you have a backup...
Backup mbr :-
dd if=/dev/sdX of=/tmp/sda-mbr_backup.bin bs=512 count=1


Backup partition table

sfdisk -d /dev/sda > partition.txt

You can cat the partition table and see the contents or replace it using sfdisk :-

sfdisk /dev/sdb < partition.txt

Dontcha love unix redirection ;)

#8 xllxjustinxllx

xllxjustinxllx

    Will I break 10 posts?

  • Members
  • 8 posts
  • Gender:Male

Posted 28 December 2010 - 10:55 PM

I love the DD command but in this situation, i would get a linux live cd like ubuntu that has gparted installed.

boot live cd, open gparted, resize however you want and click apply. Its that easy and no worries of messing up MBR
  • bardolph and d3xt3r like this

#9 bardolph

bardolph

    DDP Fan club member

  • Members
  • 50 posts
  • Gender:Male

Posted 01 January 2011 - 04:32 PM

I love the DD command but in this situation, i would get a linux live cd like ubuntu that has gparted installed.

boot live cd, open gparted, resize however you want and click apply. Its that easy and no worries of messing up MBR



that seems much easier - i tried running gparted inside ubuntu but wouldn't allow anything in my linux partition... you guys sure i can resize without problem with gparted from live cd?

#10 eldiablo

eldiablo

    DDP Fan club member

  • Members
  • 52 posts

Posted 01 January 2011 - 07:48 PM

I have used GParted Live to resize partitions many times without issue.

http://gparted.sourc....net/livecd.php

#11 emwav

emwav

    DDP Fan club member

  • Members
  • 42 posts
  • Location:NC

Posted 05 January 2011 - 01:28 PM


I love the DD command but in this situation, i would get a linux live cd like ubuntu that has gparted installed.

boot live cd, open gparted, resize however you want and click apply. Its that easy and no worries of messing up MBR



that seems much easier - i tried running gparted inside ubuntu but wouldn't allow anything in my linux partition... you guys sure i can resize without problem with gparted from live cd?


That depends on how your partitions are laid out.

Run fdisk -l (sudo fdisk -l if you are not logged in as root) and post the output.

And as always -- backup backup backup. If you trashed your hard drive and had to reformat would you be able to retrieve your data?

#12 d3xt3r

d3xt3r

    SCRiPT KiDDie

  • Members
  • 20 posts
  • Gender:Male

Posted 15 January 2011 - 08:45 AM

I love the DD command but in this situation, i would get a linux live cd like ubuntu that has gparted installed.

boot live cd, open gparted, resize however you want and click apply. Its that easy and no worries of messing up MBR






Using the Live CD ..to resize is better , and working with GParted is easier too.

#13 bardolph

bardolph

    DDP Fan club member

  • Members
  • 50 posts
  • Gender:Male

Posted 02 February 2011 - 11:43 AM



I love the DD command but in this situation, i would get a linux live cd like ubuntu that has gparted installed.

boot live cd, open gparted, resize however you want and click apply. Its that easy and no worries of messing up MBR



that seems much easier - i tried running gparted inside ubuntu but wouldn't allow anything in my linux partition... you guys sure i can resize without problem with gparted from live cd?


That depends on how your partitions are laid out.

Run fdisk -l (sudo fdisk -l if you are not logged in as root) and post the output.

And as always -- backup backup backup. If you trashed your hard drive and had to reformat would you be able to retrieve your data?



hey i just made a back up partition with clonezilla - that iso is great !




BinRev is hosted by the great people at Lunarpages!