Removing a primary filesystem to create new logical filesystems

Okay, so sometimes you need a refresher on how to do something.

Let’s say, for example, that you have some filesystems that look something like this

/dev/hda1 –> /boot
/dev/hda2 –> /
/dev/hda3 –> swap
/dev/hda4 –> /logs

You’ve noticed that your / partition is filling up rather quickly as you didn’t allocate enough space to it for the OS and the user files or applications. What do you do? Add another drive?

Well, let’s also say that you have allocate 9GB to root, 2GB to swap and 20GB to logs….but you have a 120GB hard drive. You obviously have a ton of space that you aren’t using. Here’s what I’d do.

1: Copy all of the files in /logs to another PC/server
2: fdisk /dev/hda and remove hda4
3: in fdisk, create a new extended filesystem
4: reboot to recognize the new extended filesystem (/dev/hda4)
5: fdisk and create 2 logical partitions, one for /test (example) and one for your old /logs filesystem
6: reboot
7: mkfs -t ext3 (or ext2, reiser..whatever) /dev/hda5 and /dev/hda6
8: mount /dev/hda5 /test && mount /dev/hda6 /logs
9: copy your logs from your pc/server to the machine where you created the new filesystems
10: EDIT /etc/fstab so that it’ll mount after a reboot.

Just had to do this. It works.

Leave a Reply

Your email address will not be published. Required fields are marked *