Follow the screen shot to add a disk to VM.
Login as root user and follow the process.
[root@localhost ~]# fdisk -l
Disk /dev/sdc doesn't
contain a valid partition table
/dev/sdc is added and we need to partition it first
Login as root user and follow the process.
[root@localhost ~]# fdisk -l
Disk /dev/sda:
21.4 GB, 21474836480 bytes
255 heads, 63
sectors/track, 2610 cylinders
Units = cylinders
of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 *
1 38 305203+
83 Linux
/dev/sda2 39 2353
18595237+ 83 Linux
/dev/sda3 2354 2610
2064352+ 82 Linux swap / Solaris
Disk /dev/sdb:
21.4 GB, 21474836480 bytes
255 heads, 63
sectors/track, 2610 cylinders
Units = cylinders
of 16065 * 512 = 8225280 bytes
Device Boot Start End
Blocks Id
System
/dev/sdb1 1 2610
20964793+ 83 Linux
Disk /dev/sdc:
21.4 GB, 21474836480 bytes
255 heads, 63
sectors/track, 2610 cylinders
Units = cylinders
of 16065 * 512 = 8225280 bytes
/dev/sdc is added and we need to partition it first
/dev/sdc is added, if we add disk to a Virtual machine it must be partitioned, so that OS can detect the disk
[root@localhost dev]# fdisk /dev/sdc
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 2610.
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost
~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 2353 18595237+ 83 Linux
/dev/sda3 2354 2610 2064352+ 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 2353 18595237+ 83 Linux
/dev/sda3 2354 2610 2064352+ 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux
Create a Linux file system on the partition
so that the operating system can use it to store files and data. By using
mkfs.btrfs utility
[root@localhost
~]# mkfs. (press tab)
mkfs.btrfs
mkfs.cramfs mkfs.ext2 mkfs.ext3
mkfs.ext4 mkfs.fat mkfs.gfs2 mkfs.minix
mkfs.msdos mkfs.vfat mkfs.xfs
[root@localhost ~]# mkfs.btrfs /dev/sdb
sdb
sdb1
[root@localhost
~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes,
62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /
512 bytes
I/O size (minimum/optimal): 512 bytes / 512
bytes
Disk label type: dos
Disk identifier: 0x000b2714
Device Boot Start End Blocks
Id System
/dev/sda1
* 2048 2050047
1024000 83 Linux
/dev/sda2 2050048 41943039
19946496 8e Linux LVM
/dev/sda3 41943040 62914559
10485760 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes,
41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /
512 bytes
I/O size (minimum/optimal): 512 bytes / 512
bytes
Disk label type: dos
Disk identifier: 0x1339d503
Device Boot Start End Blocks
Id System
/dev/sdb1 2048 41943039
20970496 83 Linux
Disk /dev/mapper/ol-swap: 3145 MB,
3145728000 bytes, 6144000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /
512 bytes
I/O size (minimum/optimal): 512 bytes / 512
bytes
Disk /dev/mapper/ol-root: 25.9 GB,
25866272768 bytes, 50520064 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /
512 bytes
I/O size (minimum/optimal): 512 bytes / 512
bytes
[root@localhost
~]# mkfs.btrfs /dev/sdb1
WARNING! - Btrfs v3.12 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org
before using
Turning ON incompat feature 'extref':
increased hardlink limit per file to 65536
fs created label (null) on /dev/sdb1
nodesize 16384 leafsize 16384 sectorsize 4096 size 20.00GiB
Btrfs v3.12
We need to mount it so that it is
accessible to the RHEL system and its users. In order to do this we need to
create a mount point. A mount point is simply a directory into which the
file system will be mounted
[root@localhost
~]# mkdir /datavol
[root@localhost ~]# mount /dev/sdc
[root@localhost ~]# mount /dev/sdc1 /datavol
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 11G 5.5G 67% /
/dev/sda1 289M 16M 258M 6% /boot
tmpfs 1006M 0 1006M 0% /dev/shm
/dev/sdb1 20G 3.7G 16G 20% /data
/dev/sdc1 20G 173M 19G 1% /datavol
[root@localhost ~]# mount /dev/sdc
[root@localhost ~]# mount /dev/sdc1 /datavol
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 11G 5.5G 67% /
/dev/sda1 289M 16M 258M 6% /boot
tmpfs 1006M 0 1006M 0% /dev/shm
/dev/sdb1 20G 3.7G 16G 20% /data
/dev/sdc1 20G 173M 19G 1% /datavol
[root@localhost
~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb1 on /data type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdc1 on /datavol type ext3 (rw)
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb1 on /data type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdc1 on /datavol type ext3 (rw)
Configuring RHEL to automatically mount on
boot
Open the fstab
file and enter the details of the mounted disk
My original file
is like as follows
[root@localhost
~]# sudo vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot
ext3 defaults 1 2
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=SWAP-sda3 swap swap
defaults 0 0
We need to add disk to the end of the file as following
We need to add disk to the end of the file as following
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3
defaults 1 2
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=SWAP-sda3 swap
swap defaults 0 0
LABEL=/dev/sdc1 /data
ext3 defaults 0 2