How To Resize ext3 Partitions Without Losing Data - Page 2
3 Enlarging An ext3 PartitionIn this example we have a /dev/sda1 partition with about 6GB of size, and right behind that partition we have about 4GB of unused space. We want to add those 4GB of unused spave to our /dev/sda1 partition (this doesn't work of these 4GB don't come right behind our /dev/sda1 partition, but are elsewhere on the hard disk!). First, we collect some details again about our current partitioning: df Filesystem 1K-blocks Used Available Use% Mounted on df -B 4k Filesystem 4K-blocks Used Available Use% Mounted on df -h Filesystem Size Used Avail Use% Mounted on fdisk -l
fdisk -s /dev/sda1 6337611 Then we shut down the system and boot into our Knoppix Live-CD (or your rescue system) (if the partition you want to resize doesn't hold any system files, you can do everything from the original system; the steps are the same, just omit booting into Knoppix/your rescue system). shutdown -r now After Knoppix has booted, open a terminal and become root by running su /dev/sda1 should be unmounted by default, but you can run umount /dev/sda1 to go sure. Then run fsck -n /dev/sda1 fsck 1.38 (30-Jun-2005) Next we remove the journal from /dev/sda1, thus turning it into an ext2 partition: tune2fs -O ^has_journal /dev/sda1 The output looks like this: tune2fs 1.38 (30-Jun-2005) Now we use fdisk to delete our current /dev/sda1 partition and create a bigger one (don't be afraid, no data will be lost): fdisk /dev/sda (Yes, it's /dev/sda, not /dev/sda1.) The number of cylinders for this disk is set to 1305. Type m to get a list of all commands: Command (m for help): m Let's print out the partition table: Command (m for help): p Now we delete partition no. 1 (/dev/sda1): Command (m for help): d Next we create a new /dev/sda1 partition. It was a primary partition before, so we choose p again, and again it is our partition no. 1: Command (m for help): n Now we must specify the first and the last cylinder of our new /dev/sda1 partition. We know the first cylinder, can can take it from the fdisk -l output before: First cylinder (1-1305, default 1): 1 Now fdisk tells us the highest possible cylinder of our new partition (1247 in this example), so we simply enter this number: Last cylinder or +size or +sizeM or +sizeK (1-1247, default 1247): 1247 Let's print out our new partition table: Command (m for help): p Our original /dev/sda1 had the bootable flag (see the fdisk -l output from the beginning of this chapter), so we must add it to our new /dev/sda1 again: Command (m for help): a Now let's write our new partition table and exit fdisk: Command (m for help): w Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. Now we reboot the system, and again we boot into our Knoppix system (rescue system; original system if resized partition doesn't hold system files): shutdown -r now Become root again (on Knoppix run su ) Then run e2fsck -f /dev/sda1 Now we must resize the file system in our /dev/sda1 partition. If we don't specify a size for the resize2fs command, it will assume the biggest possible size so we don't have to calculate. So we run resize2fs /dev/sda1 The output looks like this: resize2fs 1.38 (30-Jun-2005) Next we run fsck -n /dev/sda1 fsck 1.38 (30-Jun-2005) and create the journal on /dev/sda1, thus turning it into an ext3 partition again: tune2fs -j /dev/sda1 tune2fs 1.38 (30-Jun-2005) Now we are done. Shut down the system and boot into the original system: shutdown -r now If everything goes well, the original system will boot up, and no data has been lost. Now we can gather some details about our new partitioning and compare them with the information we collected at the beginning of this chapter: df Filesystem 1K-blocks Used Available Use% Mounted on df -B 4k Filesystem 4K-blocks Used Available Use% Mounted on df -h Filesystem Size Used Avail Use% Mounted on fdisk -l
fdisk -s /dev/sda1 10016496
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Recent comments
1 day 44 min ago
1 day 2 hours ago
1 day 3 hours ago
1 day 8 hours ago
1 day 15 hours ago
1 day 16 hours ago
1 day 21 hours ago
1 day 23 hours ago
2 days 3 hours ago
2 days 8 hours ago