Saturday, January 07, 2006

Adding a Ext3 Partition to a Running Linux

Here I will discuss how to add a ext3 partition on a already running Linux without disturbing its present Partitions.

Let me tell you my scenario :

I had 40 GB Hard Disk .

I had 2 partions in Mandrake Linux on my Laptop.

/ ------------------------ 5.8 GB

/home ----------------- 3.1 GB

and a Free Disk Space of around 30 GB left Unused.

Now I want to add the Free Space of 30 Gb to be used for other purposes on Mandrake Linux .

Here's What I do :

Step 1 ----- Create a Logical partition

Step 2 ----- Add a file system to that partition

Step 3 ---- Create a directory and mount that newly created partition

Step 4 --- Add to /etc/fstab

Step 1 - Create a Logical Partition using cfdisk


Here the table shows 30 GB Space Unused

I Select Free Space > New > Logical > Size it Shows 29578.11 (MB)

I modify it to 10000.11(MB)

Since I need to add only 10 GB of additional space for now.

Now it Asks

Add Partition at the beginning of free space , I select Beginning.

Now I have this,

Name ------Flags ----Part Type----- FS Type -----[Label]---- Size (MB)
hda1 -------Boot----- Primary ------Linux ext3------------------ 6308.79
hda5 -------------------Logical -------Linux swap------------------- 830.76
hda6 -------------------Logical------- Linux ext3------------------ 3290.12
hda7 -------------- Logical -------Linux ---------------10001.95
--------------------------Pri/Log --------Free Space ---------------19576.17

The partition is created as hda7 but the File System is not defined,

Step 2 ----- Add a file system to that partition

Now to create a File System ext3 on hda7 I do,

[root@mybox sriram]# mkfs -t ext3 /dev/hda7
mke2fs 1.34 (25-Jul-2003)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3613792 inodes, 7221209 blocks
361060 blocks (5.00%) reserved for the super user
First data block=0
221 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@mybox sriram]#

This has created the file system but upon running
the command : df -ah - It wont show you hda7

This is because it is not Mounted.

Step 3 ---- Create a directory and mount that newly created partition

Now I create a directory ram under root and mount /dev/hda7 under it.

#mkdir /ram

#mount -t ext3 /dev/hda7 /ram

Now you give the command --- df -ah

Now this will list the partition /dev/hda7

Step 4 --- Add to /etc/fstab

Finally you need to add the Mount to /etc/fstab

I added

/dev/hda7 -----/ram-----ext3-------noatime----1----2

The digits "1 2" refer to whether the mount point should be backed up when the dump command is used and disk integrity checks using fsck. The "1" states that it should be backed up when the dump command is issued (0=no). The "2" refers to the order in which "fsck" should check the mount points. The digit "1" identifies the root ("/") of the filesystem. All others should be "2". (0=no check)

Now reboot and see if its auto mounted the partition /dev/hda7

Check man pages for the following commands

Add label to hard drive: e2label /dev/hdb EXTRA_DRIVE
Note: Labels support up to 16 characters.

Manipulate/configure the partition table.

Manipulate/configure the partition table.

Curses based disk partition table manipulator.

Build Linux file system. (Actually a front-end to various file system builders for various file system types.)

Create a Linux second extended file system

Adjust file system parameters on a second extended filesystem. Convert ext2 to ext3, add volume label (-L), ...

Mount a file system.

Configuration file for mounting filesystems.

No comments: