Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I currently have a 600gb disk, with Ubuntu installed, 600gb of which is given to the Ubuntu OS:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       592G   16G  547G   3% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           777M  944K  776M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.9G  3.8M  1.9G   1% /run/shm

Is it safe to unmount /dev/sda1 to shrink it to say, 300gb will I simply be able to remount it afterwards, or is it going to break everything and just die? Using Gparted?
If not then, how does it work in Windows Disk Manager, there I am able to resize mounted disks?

share|improve this question
    
In the future, you might look into using LVM. It's very useful when you have a ton of disk space. You still wouldn't be able to shrink, but you could create a new volume, copy the data over, and the reboot into then new volume and delete the old one. –  Patrick Jul 27 '12 at 21:02

3 Answers 3

up vote 9 down vote accepted

If you are using /dev/sda1 as your current system root, you will be unable to unmount it, and doing so would prevent you from running parted from it anyway.

resize2fs is able to enlarge ext3/4 filesystems while mounted on newer kernels, but not shrink them.

Your best bet is probably to use the gparted live CD or gparted included with System Rescue CD. These will let you boot Linux on a CD and then resize your hard drive's partition without mounting it.

If this is not an option, you will need to have a separate Linux installation on another partition or device that you can boot for resizing; or go through the long painful process of backing up, re-creating the partition from scratch, and restoring the backup.

share|improve this answer
    
Ah, awesome :D I still have the installation disk somewhere –  King Jul 27 '12 at 16:35
    
Parted Magic CD is also a good live CD with the gparted front end. –  Tim Jul 27 '12 at 16:41
    
@mrb will those CD tools let you shrink a filesystem? I wasn't aware of any tool that could shrink a filesystem without copying the data elsewhere, rebuilding the filesystem, and then copying data back. –  Patrick Jul 27 '12 at 21:00
    
@Patrick, Yes, they (parted, resize2fs) let you shrink. They find file data currently beyond the desired resize point, move it to before the resize point, update structures, set the new fs size, and set the new partition size (except resize2fs, for which you manually update partition boundaries). It can be time-consuming if there's a lot of data beyond the desired resize point. –  mrb Jul 27 '12 at 22:36
    
Well, I used gparted ( booted from ubuntu install CD ), resized the partition from 600gb to 100gb, then installed windows on the new 500gb partition, only issue was i had to reenter Ubuntu to the boot manager for dual booting,working great :D –  King Aug 1 '12 at 18:58

The honest answer to your question is: no, it is not safe.

Data loss is a very real possibility when resizing partitions of any type.

Is it a certainty? By no means. I have resized many partitions in my lifetime; it's a slightly lengthy, but generally trouble-free process.

However, it is not 100% safe, and you should always be sure to have an up-to-date backup before attempting a resize operation on any partition. This is even more important when you're dealing with the root partition.

share|improve this answer
2  
This is kind of silly. Of course there's a risk; by this definition it's also unsafe to ever turn the hard drive on, because it might fail. He means "is there more of a risk as compared to resizing a different partition" –  Michael Mrozek Jul 27 '12 at 17:16

Yes.

1.Backup important files(it's working but sometimes things can go wrong)

2.Boot LiveCD

3.Run Gparted (if not included in LiveCD then apt-get install gparted)

4.Resize partition and click Apply

5.Boot from hard disk

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.