Adding an additional disk to Linux Machine:
In one of my Oracle RAC practical, I got shortage of disk space in my Linux machine so I have decided to add one more disk of 40GB to my Linux VM.
My this post will show you , what are the steps I have adopted to add and mount, additional 40GB Hardisk to my Linux VM .
First of all I have added additional 40 GB Disk to my VM,and started the Linux VM.
Thereafter we have to Check that, how many disks are present ,I have did this using the fdisk command.
[root@PawanASM ~]# fdisk -l | grep ‘^Disk’
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sda: 85.8 GB, 85899345920 bytes
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
As I have just added a new disk to my Linux VM therefore that disk “sdb” will show as ” Disk /dev/sdb doesn’t contain a valid partition table ” because its entry is not present in linux partition table so we have to partition the disk /dev/sdb by using fdisk command.
[root@PawASM ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): print
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
To create a new partition, issue the command “n” and then select “p” for primary and 1-4 depending on which partition on the drive this is (first, second, third, or fourth):
n (creates a new partition)
p (creates a primary partition)
1 (the number 1 denotes the partition will be /dev/sdb1)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-5221, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-5221, default 5221): 5221
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@PawASM ~]# fdisk -l | grep ‘^Disk’
Disk /dev/sda: 85.8 GB, 85899345920 bytes
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
[root@PawASM ~]# fdisk -l
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3929 31455270 83 Linux
/dev/sda3 3930 4694 6144862+ 83 Linux
/dev/sda4 4695 10443 46178842+ 5 Extended
/dev/sda5 4695 5216 4192933+ 82 Linux swap / Solaris
/dev/sda6 5217 5703 3911796 83 Linux
/dev/sda7 5704 6190 3911796 83 Linux
/dev/sda8 6191 6677 3911796 83 Linux
/dev/sda9 6678 7164 3911796 83 Linux
/dev/sda10 7165 7651 3911796 83 Linux
/dev/sda11 7652 8138 3911796 83 Linux
/dev/sda12 8139 8625 3911796 83 Linux
/dev/sda13 8626 9112 3911796 83 Linux
/dev/sda14 9113 9599 3911796 83 Linux
/dev/sda15 9600 10086 3911796 83 Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 5221 41937651 83 Linux
[root@PawASM ~]# partx -a /dev/sdb
“OR”
[root@PawASM ~]# partprobe
- Format the new disk using mkfs.ext3 command:
To format Linux partition, using ext3 file system on the new disk, issue the following command:
[root@PawASM ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
5242880 inodes, 10484412 blocks
524220 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
16384 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 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@PawASM ~]# fdisk -l
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3929 31455270 83 Linux
/dev/sda3 3930 4694 6144862+ 83 Linux
/dev/sda4 4695 10443 46178842+ 5 Extended
/dev/sda5 4695 5216 4192933+ 82 Linux swap / Solaris
/dev/sda6 5217 5703 3911796 83 Linux
/dev/sda7 5704 6190 3911796 83 Linux
/dev/sda8 6191 6677 3911796 83 Linux
/dev/sda9 6678 7164 3911796 83 Linux
/dev/sda10 7165 7651 3911796 83 Linux
/dev/sda11 7652 8138 3911796 83 Linux
/dev/sda12 8139 8625 3911796 83 Linux
/dev/sda13 8626 9112 3911796 83 Linux
/dev/sda14 9113 9599 3911796 83 Linux
/dev/sda15 9600 10086 3911796 83 Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 5221 41937651 83 Linux
- Mount the new disk using the mount command:
First, you’ll need to create a mount point. We’ll use /u02. This is where we’ll mount /dev/sdb1. Enter the following commands:
[root@PawASM ~]# ll /
[root@PawASM ~]# mkdir /u02
total 178
drwxr-xr-x 2 root root 4096 Jan 18 02:12 bin
drwxr-xr-x 4 root root 1024 Jan 18 19:15 boot
drwxr-xr-x 13 root root 4640 Jan 29 23:51 dev
drwxr-xr-x 137 root root 12288 Jan 29 23:41 etc
drwxr-xr-x 3 root root 4096 Jan 18 18:05 home
drwxr-xr-x 11 root root 4096 Jan 18 02:10 lib
drwxr-xr-x 8 root root 12288 Jan 18 02:11 lib64
drwx------ 2 root root 16384 Jan 17 23:07 lost+found
drwxr-xr-x 3 root root 4096 Jan 29 23:41 media
drwxr-xr-x 2 root root 0 Jan 29 23:37 misc
drwxr-xr-x 3 root root 4096 Jan 18 02:55 mnt
drwxr-xr-x 2 root root 0 Jan 29 23:37 net
drwxr-xr-x 4 root root 4096 Jan 18 19:14 opt
dr-xr-xr-x 236 root root 0 Jan 29 23:36 proc
drwxr-x--- 16 root root 4096 Jan 29 23:41 root
drwxr-xr-x 2 root root 12288 Jan 18 19:15 sbin
drwxr-xr-x 2 root root 4096 Jan 17 23:07 selinux
drwxr-xr-x 2 root root 4096 Oct 1 2009 srv
drwxr-xr-x 11 root root 0 Jan 29 23:36 sys
drwxr-xr-x 3 root root 4096 Jan 17 23:38 tftpboot
drwxrwxrwt 22 root root 4096 Jan 29 23:41 tmp
drwxrwxrwx 3 oracle oinstall 4096 Jan 18 18:08 u01
drwxr-xr-x 2 root root 4096 Jan 30 00:34 u02
drwxr-xr-x 15 root root 4096 Jan 17 23:16 usr
drwxr-xr-x 28 root root 4096 Jan 18 00:06 var
[root@PawASM ~]# mount /dev/sdb1 /u02
[root@PawASM ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 30G 23G 4.9G 83% /
/dev/sda3 5.7G 143M 5.3G 3% /tmp
/dev/sda1 99M 15M 80M 16% /boot
tmpfs 1.8G 1.1G 703M 61% /dev/shm
/dev/sr0 3.6G 3.6G 0 100% /media/SAI-OS-5U7_64bit
/dev/sdb1 40G 177M 38G 1% /u02
Edit /etc/fstab so the new drive will automatically mount to /u02 on reboot
[root@PawASM ~]# vi /etc/fstab
/dev/sdb1 /u02 ext3 defaults 1 1
[root@PawASM ~]# mount -a
“OR”
[root@PawASM ~]# init 6
[root@PawASM ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 30G 23G 4.9G 83% /
/dev/sda3 5.7G 143M 5.3G 3% /tmp
/dev/sda1 99M 15M 80M 16% /boot
/dev/sdb1 40G 177M 38G 1% /u02
tmpfs 1.8G 0 1.8G 0% /dev/shm
/dev/sr0 3.6G 3.6G 0 100% /media/SAI-OS-5U7_64bit
If Linux file system mounted in Read only mode for repair then it will not allow you to edit /etc/fstab or any other file. So we need to mount linux file system in read write mode by using command.
Thank you for reading… This is Airy…Enjoy 🙂