-->
  • Recent Articles

    Create partition and Extend reiserfs File System in Linux LVM

    Create partition and Extend reiserfs File System in Linux LVM

    redhat
    In Linux, when adding a new disk use this to rescan the bus with the following command

    echo "- - -" > /sys/class/scsi_host/host0/scan

    In the above command the the hyphens represent controller,channel,lun, so – - – indicates all controllers, all channels and all luns should be scanned.

    In Linux, when expanding an existing disk
    For Existing disk ...which is resized.
       echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan
       echo 1 > /sys/class/scsi_device/0\:0\:1\:0/device/rescan
       echo 1 > /sys/class/scsi_device/0\:0\:2\:0/device/rescan
       echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan

    ***********************
    Add a Disk to LVM:
    ********************
    1.take the output of
    lvmdiskscan





    fdisk -l


    2. Scan the newly added disk.

    echo "- - -" > /sys/class/scsi_host/host#/scan
    3. Check the output of
    lvmdiskscan
    fdisk -l
    lsscsi
    List existing drives.


    fdisk /dev/sdb (This step is optional, If you want to use the whole disk under LVM , you can directly proceed to "pvcreate")
    Once formatted, then we need to create Physical Volume out of it.
    I've 3 partition on this disk as of now. I'll create another partition on it.


    linux-test2-Server1:~ # fdisk /dev/sdb

    Command (m for help): p

    Disk /dev/sdb: 1073 MB, 1073741824 bytes
    255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0x46faf531

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048      206847      102400   83  Linux
    /dev/sdb2          206848      411647      102400   83  Linux
    /dev/sdb3          411648      616447      102400   83  Linux

    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Selected partition 4
    First sector (616448-2097151, default 616448):
    Using default value 616448
    Last sector, +sectors or +size{K,M,G} (616448-2097151, default 2097151): +100M

    Command (m for help): p

    Disk /dev/sdb: 1073 MB, 1073741824 bytes
    255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0x46faf531

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048      206847      102400   83  Linux
    /dev/sdb2          206848      411647      102400   83  Linux
    /dev/sdb3          411648      616447      102400   83  Linux
    /dev/sdb4          616448      821247      102400   83  Linux

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


    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
    linux-test2-Server1:~ #

    Now Do a "partprobe" for updating Kernel table.

    linux-test2-Server1:~ # partprobe
    Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
    linux-test2-Server1:~ # lvmdiskscan
      /dev/server/ftp   [     252.00 MiB]
      /dev/sda1         [     548.00 MiB]
      /dev/server/home1 [      36.00 MiB]
      /dev/root         [       9.46 GiB]
      /dev/sdb1         [     100.00 MiB] LVM physical volume
      /dev/sdb2         [     100.00 MiB] LVM physical volume
      /dev/sdb3         [     100.00 MiB] LVM physical volume
      /dev/sdb4         [     100.00 MiB]
      2 disks
      3 partitions
      0 LVM physical volume whole disks
      3 LVM physical volumes
    linux-test2-Server1:~ #

    Now add the partition to LVM.

    linux-test2-Server1:~ # pvcreate /dev/sdb4
      Physical volume "/dev/sdb4" successfully created
    linux-test2-Server1:~ #

    linux-test2-Server1:~ # lvmdiskscan
      /dev/server/ftp   [     252.00 MiB]
      /dev/sda1         [     548.00 MiB]
      /dev/server/home1 [      36.00 MiB]
      /dev/root         [       9.46 GiB]
      /dev/sdb1         [     100.00 MiB] LVM physical volume
      /dev/sdb2         [     100.00 MiB] LVM physical volume
      /dev/sdb3         [     100.00 MiB] LVM physical volume
      /dev/sdb4         [     100.00 MiB] LVM physical volume
      2 disks
      2 partitions
      0 LVM physical volume whole disks
      4 LVM physical volumes

    Now extend the VG.

    linux-test2-Server1:~ # vgs
      VG     #PV #LV #SN Attr   VSize   VFree
      server   3   2   0 wz--n- 288.00m    0
    linux-test2-Server1:~ # vgextend server /dev/sdb4
      Volume group "server" successfully extended
    linux-test2-Server1:~ # vgs
      VG     #PV #LV #SN Attr   VSize   VFree
      server   4   2   0 wz--n- 384.00m 96.00m
    linux-test2-Server1:~ #

    linux-test2-Server1:~ # lvs
      LV    VG     Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
      ftp   server -wi-ao--- 252.00m
      home1 server -wi-ao---  36.00m
    linux-test2-Server1:~ #
    linux-test2-Server1:~ # lvextend -L +40M /dev/server/home1
      Extending logical volume home1 to 76.00 MiB
      Logical volume home1 successfully resized
    linux-test2-Server1:~ # lvs
      LV    VG     Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
      ftp   server -wi-ao--- 252.00m
      home1 server -wi-ao---  76.00m
    linux-test2-Server1:~ #

    Now extend the reiserfs File system.

    linux-test2-Server1:~ # umount /home1

    linux-test2-Server1:~ # resize_reiserfs /dev/server/home1
    resize_reiserfs 3.6.21 (2009 www.namesys.com)

    ReiserFS report:
    blocksize             4096
    block count           19456 (9216)
    free blocks           11232 (992)
    bitmap block count    1 (1)

    Syncing..done


    resize_reiserfs: Re sizing finished successfully.

     linux-test2-Server1:~ # mount -a
    linux-test2-Server1:~ # df -h /home1
    Filesystem                Size  Used Avail Use% Mounted on
    /dev/mapper/server-home1   76M   33M   44M  43% /home1
    linux-test2-Server1:~ #




    find the Video @ https://youtu.be/iruNUbsj0_I

    No comments