*****************************************************************************
* Description: Knowledge of mounting disk with file system on Linux platform
* Compatiablity: RDBMS 11g, 12c
* Date: 05:45 PM EST, 06/01/2017
*****************************************************************************
Step 1 - First find the disk:
|
|__ $ dmesg | grep SCSI
SCSI subsystem initialized
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
sd 1:0:1:0: [sdb] Attached SCSI disk
sd 0:0:0:0: [sda] Attached SCSI disk
sd 3:0:0:0: [sdc] Attached SCSI disk
Step 2 - Partition the disk, make it a primary disk on partition 1, and create the partition:
|
|__ o. In some of Linux flavor, the disk name might be /dev/xvda or /dev/xvd* instead of sda.
|
|__ $ sudo fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1a79c16f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
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): n
Command action
e extended
p primary partition (1-4)
Select (default p): p
Partition number (1-4): 1
First cylinder (1-1305, default 1): Enter
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): Enter
Using default value 1305
Partition 1 of type Linux and of size 50 GiB is set
Command (m for help): p
Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x1a79c16f
Device Boot Start End Blocks Id System
/dev/sdc1 1 1305 10482381 83 Linux
Partition 1 does not start on physical sector boundary.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Step 3 - write a file system to the partition, specifying your filesystem type and the device name:
|
|__ $ sudo mkfs -t ext4 /dev/sdc1
[sudo] password for micore:
mke2fs 1.43-WIP (20-Jun-2013)
/dev/sdc1 alignment is offset by 512 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Step 4 - create a directory to mount the file system:
|
|__ $ sudo mkdir /data
Step 5 - mount the directory:
|
|__ $ sudo mount /dev/sdc1 /data
Step 6 - To ensure the drive is remounted automatically after a reboot it must be added to the /etc/fstab file.
| UUID (Universally Unique IDentifier) is used in /etc/fstab to refer to the drive rather than just the device name.
| If the OS detects a disk error during boot, using the UUID avoids the incorrect disk being mounted to a given location.
| Remaining data disks would then be assigned those same device IDs. To find the UUID of the new drive:
|
|__ $ sudo -i blkid
/dev/sda1: UUID="d1f02642-b6db-4238-b961-9ae23d28d6aa" TYPE="ext4"
/dev/sda2: UUID="b27ff591-4fd9-4b83-a110-8bddf652c0ac" TYPE="ext4"
/dev/sdb1: UUID="44969a92-1000-4447-9899-e4b064e55137" TYPE="ext4"
/dev/sdc1: UUID="c6c30b15-f73b-4a22-bc35-0d01985be76f" TYPE="ext4"
Step 7 - Recommend backing up the file system table in advanced:
|
|__ $ sudo cp /etc/fstab /etc/fstab.bkp
Step 8 - Add the following line to the end of the /etc/fstab file:
|
|__ $ sudo vi /etc/fstab
>> UUID=c6c30b15-f73b-4a22-bc35-0d01985be76f /data ext4 defaults,nofail 1 2
Reference:
|
|__ https://docs.microsoft.com/en-us/azure/virtual-machines/linux/add-disk?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json
Your Comments