LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Resize partition with parted (https://www.linuxquestions.org/questions/linux-general-1/resize-partition-with-parted-850177/)

ShadowReaper 12-14-2010 10:27 AM

Resize partition with parted
 
Hello,

I have a partition, which is 32GB and is mounted to / of the archlinux distribution.

I want to create another partition, I need about 5GB and I want to take them from this partition.

If I use parted to resize the partition will I lose any files?

Thank you

ozanbaba 12-14-2010 10:41 AM

Now resizing the partitions without losing data is possible, But you have to move carefully.

First shrink your filesystem. check man resize2fs for ext2/3/4 and man resize_reiserfs. they are pretty simple to use but live resize may not be supported on your system, though

Code:

fsck -f $PARTITION
resize2fs -p $PARTITION 27G

First run fsck and then resize2fs to 27G

after that use parted to resize partition with size 27G. Thick here is that new partition's starting point must be same as old partition. Take a note if you need to. If in doubt, post your commands before running here first.

ShadowReaper 12-14-2010 10:48 AM

Are you sure it's fsck -f? I read the man page and I cannot find a -f argument

ozanbaba 12-14-2010 10:51 AM

-f forces to check clean file systems and it's actually option of what fsck runs for actual file system checking.

ShadowReaper 12-14-2010 11:49 AM

Ok, i have done fsck and resize2fs.
Now what should i do with parted?
This is the partition table, number 2 is the partition to be resized:
Code:

Number  Start  End    Size    Type    File system  Flags
 1      32.3kB  273GB  273GB  primary  ntfs
 2      273GB  308GB  35.2GB  primary  ext3        boot
 3      308GB  312GB  3989MB  primary  linux-swap
 4      312GB  320GB  8317MB  primary  ext3


ozanbaba 12-14-2010 12:39 PM

Code:

(parted) print
Note the non-human readable start number for Number 2

Code:

(parted) resize 2 $NUM2 $NEWEND
Important point is that start number must be same as before.
Before jumping to running the commnads, read help resize for figuring out right numbers.


All times are GMT -5. The time now is 05:37 PM.