Shrinking a Partition in Linux

I recently had the need to shrink a partition that, when originally created, consumed the whole disk. Listed below are the steps that I followed to shrink the original partition down so that I could add a new 20G partition to the end of the disk.

Use fdisk to look at the partition table of the disk and decide which partion will be shrunk and what the new number of cylinders will be.

If you want to shrink the partition by a specific amount then use the “Units = cylinders …” line from the partition information to find the size of a cylinder and then divide size you want left by the cylinder size and round up.

For example, the disk c0d1 currently has just a single large partition:

    Disk /dev/cciss/c0d1: 255 heads, 63 sectors, 8854 cylinders
    Units = cylinders of 16065 * 512 bytes

               Device Boot    Start       End    Blocks   Id  System
    /dev/cciss/c0d1p1             1      8854  71119723+  83  Linux

To shrink it down to get a 20G partition, we would compute the cylinder size as 16065*512 (8225280 bytes) and then divide 20G by that number:

(20*1024*1024*1024)/8225280 = 2610.83 = 2611 cylinders

That means partition 1 will need to be 8854-2611 = 6243 cylinders after resizing.

resize2fs uses a block size of 4K, so you’ll need to change the number of cylinders to 4K blocks. Round the number down if comes out as a fractional number.

(cylinder_size * cylinders) / 4096

In our example, cylinder size is 8225280, cylinders is 6423, so it works out to be:

(8225280*6423)/4096 = 12898186.87 = 12898186 4k blocks

Unmount the filesystem and run e2fsck on it to make sure it is cleaned up.

  • stop services that are writing to the disk
  • umount /var/spool/news
  • e2fsck -f /dev/cciss/c0d1p1

Run resize2fs on the disk to shrink the filesystem:

resize2fs -p /dev/cciss/c0d1p1 12898186

Run fdisk to then shrink underlying partition. When running fdisk, you will delete the partition then create the same partition number starting at the same cylinder, but with the size of the new cylinder count.

Remember to write the partition table to the disk (w command) before exiting.

You can then mount up newly shrunk partition and create the new partition and filesystem.

Wednesday January 14, 2004   ·   Permalink


Great List of Web Design Resources

Seems like the folks at University of Minnesota at Duluth have put together an excellent categorized list of web design resources. Check it out.

Sunday January 11, 2004   ·   Permalink


A New Year's Thunderstorm?

The weather certainly has been strange around here lately. First it was about 70 just a week before Thanksgiving when it should have been much cooler. Now I’m seeing flashes from a thunderstorm and hearing thunder. It should be just above freezing normally for a high this time of year, but it’s nearly 50 right now. Should be an interesting new year!

Thursday January 1, 2004   ·   Permalink


Soap Carving: "Polar" Bear

Polar bear soap carving More soap carving pictures. At left is a “polar” bear from a large bar of Ivory soap based upon the pattern in the Cub Scout’s Bear Handbook. It took me around 3 to 3.5 hours over two evenings. There are more pictures including one of the pattern from the handbook.

Friday December 5, 2003   ·   Permalink


Soap Carving Tools

Soap carving tools I made eight sets of soap carving tools from the Soap Carving for Children of All Ages book I picked up recently. Shown in the background is a sample relief-carved heart from a small bar of Ivory that I think we’ll be doing as a project.

(The car and truck in the background are prototypes for a small run of toys to be donated to the Western Ohio Woodworking Club annual toy drive. Other pictures and drawings will come later.)

Sunday November 30, 2003   ·   Permalink


CSS Crib Sheet

Mezzoblue has a listing of CSS notes that are very helpful:

You will no doubt come across many quirky layout issues when building a site with CSS. You’ll end up banging your head agaginst a the wall time and again. This is an attempt to make the design process easier, and provide a quick reference to check when you run into trouble.

Thanks DiveIntoMark

Thursday November 27, 2003   ·   Permalink


More Color Tools

Clagnut has collected a short list of color tools:

There are a number of really handy online colour tools coming to my notice. They all help the untrained or unreliable eye to come up with colour schemes based on complimentary and harmonious colours. And, with one exception, they all use very nifty DOM methods and valid XHTML.

Thanks DiveIntoMark

Thursday November 27, 2003   ·   Permalink


Loft Bed Photo

Loft Bed The loft bed (shown completed at left) has been slept in twice now and son #2 has said it’s wonderful.

I did build the cork board and bookcases as shown in the plans. I’ll be installing the cork board later, but the bookcases will be omitted since they overlap the desktop and take up much needed desktop space. I’ll be building a small frame (1×4 stock) as a base for the bookcases so they’ll fit snug to wall and using them that way.


Tuesday November 25, 2003   ·   Permalink


Loft Bed Has Been Assembled

Hooray! The loft bed for son #2 has been assembled and he’ll be sleeping in it tonight. I’ll have to post a photo later.

Sunday November 23, 2003   ·   Permalink


The 10 Biggest Spam Myths

Rebecca Leib has a very interesting list of the 10 biggest spam myths over at ClickZ. Particularly funny is number 8:

8. Microsoft is committed to helping end the spam epidemic.

It’s executives are certainly committed to saying they are. ...

(Thanks Techdirt)

Friday November 21, 2003   ·   Permalink


←Newer Articles Older Articles→