Friday 29 May 2020

Add disk on VM Virtualbox


Scenario:

  • We have to add disk in our linux OS machine, So we have added 10 GB in VM disk.

Output:

Create disk on vm with extension .vdi

screenshot Image below:

  • Check entry on disk by typing command fdisk -l, we have already added 10GB so we will make raw partiton on disk /dev/sde.
    srv2:~ # fdisk -l
    Disk /dev/sda: 70 GiB, 75161927680 bytes, 146800640 sectors
    Disk model: VBOX HARDDISK
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x0002eccd

    Device     Boot   Start       End   Sectors Size Id Type
    /dev/sda1          2048   4208639   4206592   2G 82 Linux swap / Solaris
    /dev/sda2  *    4208640 136314879 132106240  63G 83 Linux


    Disk /dev/sdc: 12 GiB, 12884901888 bytes, 25165824 sectors
    Disk model: VBOX HARDDISK
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x05e2106e

    Device     Boot Start      End  Sectors Size Id Type
    /dev/sdc1        2048 25165823 25163776  12G 83 Linux


    Disk /dev/sdd: 12 GiB, 12884901888 bytes, 25165824 sectors
    Disk model: VBOX HARDDISK
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x4dab0ef3

    Device     Boot Start      End  Sectors Size Id Type
    /dev/sdd1        2048 25165823 25163776  12G 83 Linux


    Disk /dev/sde: 10 GiB, 10737418240 bytes, 20971520 sectors
    Disk model: VBOX HARDDISK
    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/sdb: 12 GiB, 12884901888 bytes, 25165824 sectors
    Disk model: VBOX HARDDISK
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xb2c61e16

    Device     Boot Start      End  Sectors Size Id Type
    /dev/sdb1        2048 25165823 25163776  12G 83 Linux

  • Create new Partition on /dev/sde
          srv2:~ # fdisk /dev/sde

    Welcome to fdisk (util-linux 2.33.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.
    Created a new DOS disklabel with disk identifier 0xe090b3b3.

    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-20971519, default 2048):
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519):

    Created a new partition 1 of type 'Linux' and of size 10 GiB.

    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.

  • srv2:/ # mkfs.ext4 /dev/sde1

mke2fs 1.43.8 (1-Jan-2018)
Creating filesystem with 2621184 4k blocks and 655360 inodes
Filesystem UUID: 7d329044-9dcd-4974-a412-4cadeeab94d9
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

srv2:/ #
  • Mount Disk /u02
srv2:/ # mount /dev/sde1 /u02
srv2:/ #
  • Add entry in /etc/fstab
vi /etc/fstab
/dev/sde1 /u02 ext4 defaults     0   0

  • Check the status 
srv2:~ # df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        2.8G     0  2.8G   0% /dev
tmpfs           2.8G  635M  2.2G  23% /dev/shm
t
/dev/sde1       9.8G  4.7G  4.7G  51% /u02
srv2:~ #

No comments:

Post a Comment