| Previous | Next |
Linux - Resizing Partitions - January 2002 |
|
In January, we prepared the computer club computer
to add a second Linux distribution - Debian.
That computer contains two 20 Gb hard drives,
one loaded with Microsoft Windows software and
one loaded with Linux software.
When we installed SuSE, we used the entire 20 Gb Linux hard drive for SuSE.
But to add Debian we needed another partition -
we had unused disk space, but we needed to split a partition.
At the meeting, I did not know how to split a partition with Linux and still keep the installed software intact. Luckily, our club sysop knew how to install and use Partition Magic under Windows. Partition Magic worked, it recognized the ext2 partitions on the Linux hard drive., it defragmented the Linux files and split the partition. We checked this by rebooting to SuSE Linux; SuSE still worked. But I wondered if there was a way to split a partition using Linux software. There is a way, but it has advantages and disadvantages with respect to Windows. Here s how: There are four important Linux commands:
Here is an example of resizing a Linux partition.
First mount the filesystem and check to see how full it is
with the df (disk free) command: In this example I will split the When partitioned, the drive should be split along a cylinder boundary.
Run the fdisk program and list the partition table: This command shows that the Run the e2fsck program to clean up any broken links and
orphaned files: |
Notice that the number of blocks is listed as 751968 instead of 3007872; the software has switched from 1Kb blocks to 4Kb blocks. One advantage of the Linux software e2fsck over Windows scandisk is that it is much faster. The resize2fs command requires a target size in 4Kb blocks.
Run the resize2fs program with a target size of 526176: resize2fs has moved the files closer together and made the filesystem smaller. Now the filesystem is smaller than the partition. Again, the Linux resize2fs is faster than Windows defrag. Run fdisk, delete the partition,
create a new partition that matches the new filesystem size and
write the new partition table: Run fdisk to create a new partition from the freed up space. The filesystem is now smaller and still works. In comparison with Windows software, Linux is faster, but more difficult to use. You can also enlarge a partition into unused disk space by running fdisk and then resize2fs. Online Linux Book - There is an amazing online Linux book at rute.sourceforge.net This book can be purchased from retailers, but you can browse the entire contents online! Read it online to brush up on Linux. I also recommend Running Linux by O Reilly. |
| Previous | Next |