Saturday, May 28, 2011

Add a partion with linux

How to add a partition with linux??
If your linux OS has very low space and also you have extra/free space in your HDD which you can add with linux just follow the simple steps:
$ su
Password:
# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x15c415c3

Device Boot Start End Blocks Id System
/dev/sda1 * 1 5100 40959734+ 7 HPFS/NTFS
/dev/sda2 5100 10199 40960000 7 HPFS/NTFS
/dev/sda3 10199 15298 40960000 83 Linux (going to format this partition since this partition contains other files which I want to delete)
/dev/sda4 * 15299 18944 29284352 83 Linux
/dev/sda5 18944 19458 4122624 82 Linux swap / Solaris

# mkfs.ext3 /dev/sda3
mke2fs 1.41.10 (10-Feb-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2564096 inodes, 10240000 blocks
512000 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
313 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624

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

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

# vi /etc/fstab
append this line (make your modifications as your needs)
/dev/sda3 /disk1 ext3 defaults 1 2

here:
/dev/sda3 is your formatted partition
/disk1 is your directory name like /opt, /home, /usr
ext3 is your partition type, check above that /dev/sda3 is formatted to ext3 format

Note: for more info check man pages for fdisk, mkfs.ext3 and fstab

No comments:

Post a Comment