Creating new swap and data partition disk in oracle linux on virtual box


In this article we will perform  ..

1. swap disk partition addition to virtual box Oracle linux machine 
2. data disk partition addition to virtual box Oracle linux machine 

Let's Begin  ..

1. swap disk partition addition to virtual box Oracle Linux machine 


Power off the machine and click on virtual machine setting , Go to Storage (Controller SATA) & click on middle symbol to create new disk in Hard Disk selector -->




Follow the steps ..




Selecting fixed size will pre-allocate disk space & will be time consuming ..











Start the virtual machine and login as root to add the disk into swap space ..

[root@oraclesrv dev]# fdisk -l sdb
Disk sdb: 10.7 GB, 10737418240 bytes, 20971520 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@oraclesrv dev]# mkswap -c /dev/sdb
0 bad pages
Setting up swapspace version 1, size = 10485756 KiB
no label, UUID=014eb336-d136-4800-95bb-199385b3c74e


[root@oraclesrv dev]# swapon /dev/sdb


[root@oraclesrv dev]# swapon -s
Filename      Type            Size         Used    Priority
/dev/dm-1     partition       1048572       0       -2
/dev/sdb      partition       10485756      0       -3


[root@oraclesrv dev]# free -h
      total    used        free      shared  buff/cache   available
Mem:  1.7G     299M        1.2G         11M        212M        1.3G
Swap: 10G        0B         10G
 
[root@oraclesrv dev]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Oct 31 19:10:36 2020
#
# 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
#
/dev/mapper/ol-root     /        xfs     defaults        0 0
UUID=3288197d-a12b-4735-87d6-b1c36825d665 /boot xfs defaults   0 0
/dev/mapper/ol-swap    swap       swap    defaults        0 0
/dev/sdb               swap       swap    defaults        0 0



2. data disk partition addition to virtual box Oracle linux machine 

Follow the same step as Step 1 for adding disk into virtual machine .. Follow the further steps to add disk for u01 & data as per snap 




Start the virtual machine and login as root and perform as follow ..

[root@oraclesrv dev]# ls -lrt sd*
brw-rw---- 1 root disk 8, 32 Nov  5 10:24 sdc
brw-rw---- 1 root disk 8, 16 Nov  5 10:24 sdb
brw-rw---- 1 root disk 8,  0 Nov  5 10:24 sda
brw-rw---- 1 root disk 8,  2 Nov  5 10:24 sda2
brw-rw---- 1 root disk 8,  1 Nov  5 10:24 sda1
brw-rw---- 1 root disk 8, 48 Nov  5 10:24 sdd

[root@oraclesrv dev]# fdisk -l sdc

Disk sdc: 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

[root@oraclesrv dev]# fdisk sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x012263cc.

Command (m for help): help
h: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): e
Partition number (1-4, default 1): 1
First sector (2048-62914559, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559):
Using default value 62914559
Partition 1 of type Extended and of size 30 GiB is set


Command (m for help): p

Disk sdc: 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: 0x012263cc

Device Boot      Start         End      Blocks   Id  System
  sdc1            2048    62914559    31456256    5  Extended


[root@oraclesrv dev]# fdisk -l sdc

Disk sdc: 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

[root@oraclesrv dev]# mkfs -t ext3 /dev/sdc
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdc is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1966080 inodes, 7864320 blocks
393216 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
240 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

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


[root@oraclesrv dev]# e2label /dev/sdc /u01

[root@oraclesrv /]# chown -R oracle:oinstall /u01

[root@oraclesrv dev]# mount /dev/sdc /u01


[root@oraclesrv u01]# df -h /u01
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc         30G   45M   28G   1% /u01


Repeat the steps for data partition ..
 

[root@oraclesrv dev]# fdisk -l sdd

Disk sdd: 53.7 GB, 53687091200 bytes, 104857600 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@oraclesrv u01]# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xfcaca61d.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): e
Partition number (1-4, default 1): 2
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Partition 2 of type Extended and of size 50 GiB is set


[root@oraclesrv u01]# fdisk -l /dev/sdd

Disk /dev/sdd: 53.7 GB, 53687091200 bytes, 104857600 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@oraclesrv u01]# mkfs -t ext3 /dev/sdd
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdd is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107200 blocks
655360 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 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, 11239424

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


[root@oraclesrv /]# e2label /dev/sdd /data

[root@oraclesrv /]# mkdir /data

[root@oraclesrv /]# chown -R oracle:oinstall /data

[root@oraclesrv /]# mount /dev/sdd /data



[root@oraclesrv u01]# df -h /data
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdd         50G   52M   47G   1% /data


[root@oraclesrv u01]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Oct 31 19:10:36 2020
#
# 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
#
/dev/mapper/ol-root     /       xfs     defaults        0 0
UUID=3288197d-a12b-4735-87d6-b1c36825d665 /boot xfs  defaults    0 0
/dev/mapper/ol-swap     swap      swap    defaults        0 0
/dev/sdb                swap      swap    defaults        0 0
LABEL=/u01              u01       ext3    defaults        1 2
LABEL=/data             data      ext3    defaults        1 2



That's it !



No comments:

Post a Comment