In an effort to better record some of the tips I stumble upon and forget later on, heres a post on adding another mount point to linux…
1. In my case I’m using vmware, so I’ve increased the size of my disk, after a restart you can see the new disk sizing and partitions using the fdisk command
# fdisk -l
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x000546d3
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 553 4128768 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 553 2611 16534528 83 Linux
You can also list the devices using ls, this will show all the disks and partitions on each disk
# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda3
2. We’ll be adding a partition to /dev/sda so we fdisk the device as follows
# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): c
DOS Compatibility flag is not set
3. We can list the disk partitions using the p option, this gives the same output as before
Command (m for help): p
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x000546d3
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
/dev/sda2 39 553 4128768 82 Linux swap / Solaris
/dev/sda3 553 2611 16534528 83 Linux
4. Select the n option then p to create a new primary partition, following the defaults you can create a partition over the remaining disk space
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4
First cylinder (2611-7832, default 2611):
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832):
Using default value 7832
5. Listing the partitions we can now see the addition partition /dev/sda
Command (m for help): p
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x000546d3
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
/dev/sda2 39 553 4128768 82 Linux swap / Solaris
/dev/sda3 553 2611 16534528 83 Linux
/dev/sda4 2611 7832 41939020 5 Linux
6. Use the w option to save the changes then restart the system so /dev/sda4 becomes usable
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
7. After a restart /dev/sda4 should appear as a device, we can setup the filesystem on the new partition as follows (we use -L to label the filesystem as /data)
# mkfs.ext4 -L /data /dev/sda4
mke2fs 1.41.12 (17-May-2010)
Filesystem label=/data
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10484755 blocks
524237 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
320 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 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
8. Create a new directory where we’ll mount the filesystem
# mkdir /data
9. Mount the filesystem to the /data directory
mount /dev/sda4 /data
10. Verify the filesystem
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 14G 1.6G 90% /
tmpfs 3.9G 24K 3.9G 1% /dev/shm
/dev/sda1 291M 87M 189M 32% /boot
/dev/sda4 40G 176M 38G 1% /data
10. Update the /etc/fstab file to include mounting the /data filesystem at startup
# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Aug 31 06:56:26 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=c7129ee5-dd42-4fdd-86fb-97931e32fbe7 / ext4 defaults 1 1
UUID=0e26a6f0-29b8-486a-8173-31d46a69d0fc /boot ext4 defaults 1 2
UUID=4647cc11-f3ab-40d9-828d-8990d378f45e swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=/data /data ext4 defaults 1 2