Rhcs lec#4 How to make a logical partition

[root@localhost ~]# cd
[root@localhost ~]# fdisk -l

Disk /dev/sda: 34.4 GB, 34359738368 bytes, 67108864 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: 0x0000d8d1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    67108863    33041408   8e  Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes, 16777216 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: 0x82a31376

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    10487807     5242880   8e  Linux LVM
/dev/sdb2        10487808    14682111     2097152   82  Linux swap / Solaris
/dev/sdb3        14682112    15706111      512000   83  Linux

Disk /dev/sdc: 1112 MB, 1112226816 bytes, 2172318 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/rhel-root: 31.4 GB, 31381782528 bytes, 61292544 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/rhel-swap: 2449 MB, 2449473536 bytes, 4784128 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/sdd: 4007 MB, 4007264256 bytes, 7826688 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1              32     7823359     3911664    b  W95 FAT32
[root@localhost ~]# fdisk /dev/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 0xfe6c5a00.

Command (m for help): p

Disk /dev/sdc: 1112 MB, 1112226816 bytes, 2172318 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: 0xfe6c5a00

   Device Boot      Start         End      Blocks   Id  System

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

Command (m for help): p

Disk /dev/sdc: 1112 MB, 1112226816 bytes, 2172318 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: 0xfe6c5a00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     1026047      512000   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (1026048-2172317, default 1026048): +500M
Value out of range.
First sector (1026048-2172317, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-2172317, default 2172317):
Using default value 2172317
Partition 2 of type Linux and of size 559.7 MiB is set

Command (m for help): p

Disk /dev/sdc: 1112 MB, 1112226816 bytes, 2172318 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: 0xfe6c5a00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     1026047      512000   83  Linux
/dev/sdc2         1026048     2172317      573135   83  Linux

Command (m for help): t
Partition number (1,2, default 2): 8e
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdc: 1112 MB, 1112226816 bytes, 2172318 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: 0xfe6c5a00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     1026047      512000   8e  Linux LVM
/dev/sdc2         1026048     2172317      573135   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe.
[root@localhost ~]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created
[root@localhost ~]# pvdisplay /dev/sdc1
  "/dev/sdc1" is a new physical volume of "500.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc1
  VG Name              
  PV Size               500.00 MiB
  Allocatable           NO
  PE Size               0  
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               jdFUGV-zWwC-ZasC-8Ke9-XMkg-yf8y-Tsvg43
  
[root@localhost ~]# vgcreate vg01 /dev/sdc1
  Volume group "vg01" successfully created
[root@localhost ~]# vgdisplay vg01
  --- Volume group ---
  VG Name               vg01
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               496.00 MiB
  PE Size               4.00 MiB
  Total PE              124
  Alloc PE / Size       0 / 0  
  Free  PE / Size       124 / 496.00 MiB
  VG UUID               NsHukh-w5R4-ENAP-oFDP-mXEp-UwgU-66qyy0
  
[root@localhost ~]# lvcreate -L 300M -n lv01 /dev/vg01
  Logical volume "lv01" created
[root@localhost ~]# lvdisplay /dev/vg01/lv01
  --- Logical volume ---
  LV Path                /dev/vg01/lv01
  LV Name                lv01
  VG Name                vg01
  LV UUID                FqR65N-nem0-yJc9-OtqQ-87JJ-1dAf-VHyHM6
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2016-08-27 17:43:23 +0500
  LV Status              available
  # open                 0
  LV Size                300.00 MiB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
  
[root@localhost ~]# mkfs.xfs /dev/vg01/lv01
meta-data=/dev/vg01/lv01         isize=256    agcount=4, agsize=19200 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=76800, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]# blkid /dev/vg01/lv01
/dev/vg01/lv01: UUID="460185b0-5071-4164-8ad6-3c666dba344a" TYPE="xfs"
[root@localhost ~]# mkdir /Database
[root@localhost ~]# gedit /etc/fstab
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   30G   10G   20G  35% /
devtmpfs               552M     0  552M   0% /dev
tmpfs                  561M  140K  560M   1% /dev/shm
tmpfs                  561M  7.8M  553M   2% /run
tmpfs                  561M     0  561M   0% /sys/fs/cgroup
/dev/sdb1              5.0G   33M  5.0G   1% /Ibrahim
/dev/sda1              497M  118M  379M  24% /boot
/dev/sdd1              3.8G  3.5G  246M  94% /run/media/root/KINGSTON
/dev/mapper/vg01-lv01  297M   16M  282M   6% /Database
[root@localhost ~]# vgdisplay vg01
  --- Volume group ---
  VG Name               vg01
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               496.00 MiB
  PE Size               4.00 MiB
  Total PE              124
  Alloc PE / Size       75 / 300.00 MiB
  Free  PE / Size       49 / 196.00 MiB
  VG UUID               NsHukh-w5R4-ENAP-oFDP-mXEp-UwgU-66qyy0

Comments

Popular Posts