05 Linux operating system and file system management 07 LVM

1. The host increases 80G SCSI interface hard disk

2. 20G primary partition dividing each of the three

[root@localhost ~]# fdisk /dev/sdd

Welcome to the fdisk (util-linux 2.23.2).

 

Change will stay in memory until you decide to write the changes to disk.

Please think twice before using the write command.

 

Device does not contain a recognized partition table

Use disk identifier 0x09c65b35 create a new DOS disk label.

 

Command (input m to get help): n-

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): p

Partition number (1-4, default 1):

Starting sector (2048-167772159 defaults to 2048):

We will use the default value 2048

Last sector, sector + or + size {K, M, G} (2048-167772159, default 167 772 159): + 20G

Partition 1 is set to Linux type, size to 20 GiB

 

Command (input m to get help): n-

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): p

Partition number (2-4, default 2):

Starting sector (41945088-167772159 defaults to 41945088):

We will use the default value 41,945,088

Last sector, sector + or + size {K, M, G} (41945088-167772159, default 167 772 159): + 20G

Zone 2 is set to Linux type, size to 20 GiB

 

Command (input m to get help): n-

Partition type:

   p   primary (2 primary, 0 extended, 2 free)

   e   extended

Select (default p): p

Partition number (3,4, 3 by default):

Starting sector (83888128-167772159 defaults to 83888128):

We will use the default value 83,888,128

Last sector, sector + or + size {K, M, G} (83888128-167772159, default 167 772 159): + 20G

Linux partition 3 is set to the type, size to 20 GiB

 

Command (input m to get help): P

 

Disk /dev/sdd:85.9 GB, 85899345920 bytes, sectors 167 772 160

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical / physical): 512 byte / 512 byte

I / O Size (minimal / optimal): 512 byte / 512 byte

Disk Label Type: dos

Disk identifier: 0x09c65b35

 

   设备 Boot      Start         End      Blocks   Id  System

/dev/sdd1            2048    41945087    20971520   83  Linux

/dev/sdd2        41945088    83888127    20971520   83  Linux

/dev/sdd3        83888128   125831167    20971520   83  Linux

 

Command (input m to get help): W

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

3. Converting the three primary partitions of the physical volume (pvcreate), physical volume scanning system

 [root@localhost ~]# pvscan

  PV /dev/sda2   VG centos   lvm2 [39.51 GiB / 44.00 MiB free]

  Total: 1 [39.51 GiB] / in use: 1 [39.51 GiB] / in no VG: 0 [0   ]

[root@localhost ~]# pvcreate /dev/sdd[123]

  Physical volume "/dev/sdd1" successfully created

  Physical volume "/dev/sdd2" successfully created

  Physical volume "/dev/sdd3" successfully created

[root@localhost ~]# pvscan

  PV /dev/sda2   VG centos   lvm2 [39.51 GiB / 44.00 MiB free]

  PV /dev/sdd1               lvm2 [20.00 GiB]

  PV /dev/sdd2               lvm2 [20.00 GiB]

  PV /dev/sdd3               lvm2 [20.00 GiB]

  Total: 4 [99.51 GiB] / in use: 1 [39.51 GiB] / in no VG: 3 [60.00 GiB]

4. Two physical volumes to create a volume group, the name for myvg, view the volume group size

[root@localhost ~]# vgcreate myvg /dev/sdd[123]

  Volume group "myvg" successfully created

[root@localhost ~]# vgdisplay myvg

  --- Volume group ---

  VG Name               myvg

  System ID            

  format lvm2

  Metadata Areas        3

  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                3

  Act PV                3

  VG Size               59.99 GiB

  PE Size               4.00 MiB

  Total IN 15357

  Alloc PE / Size       0 / 0  

  Free  PE / Size       15357 / 59.99 GiB

  VG UUID               hguI1k-W8op-JGRZ-S5S6-hrb1-B88F-WCHVop

  

 

5. Create a logical volume mylv, size 30G

[root@localhost ~]# lvcreate -L 30G -n mylv myvg

  Logical volume "mylv" created.

6. The logical format to xfs file system, and mount it on / data directory, create a file test

[root@localhost ~]# mkfs -t xfs /dev/myvg/mylv

meta-data = / dev / myvg / mylv help = 256 agcount = 4, agsize = 1966080 blks

         =                       sectsz=512   attr=2, projid32bit=1

         Crc = 0 = 0 = finobt

data     =                       bsize=4096   blocks=7864320, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=0

log      =internal log           bsize=4096   blocks=3840, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost ~]# mkdir /data

[root@localhost ~]# mount /dev/myvg/mylv /data

[root@localhost ~]# cd /data

[root@localhost data]# touch 1.txt

[root@localhost data]# vim 1.txt

[root@localhost data]# cd

[root@localhost ~]# ls -l /data

The total amount of 4

-rw-r--r--. 1 root root 4 8月   1 19:59 1.txt

[root@localhost ~]# df -Th

File system type available capacity has been used with a mount point%

/dev/mapper/centos-root xfs        38G  6.4G   32G   18% /

devtmpfs                devtmpfs  481M     0  481M    0% /dev

tmpfs                   tmpfs     490M  140K  490M    1% /dev/shm

tmpfs                   tmpfs     490M  7.0M  483M    2% /run

tmpfs                   tmpfs     490M     0  490M    0% /sys/fs/cgroup

/dev/sda1               xfs       497M  107M  391M   22% /boot

/dev/sdb3               vfat      5.0G  4.0K  5.0G    1% /data3

/ Dev / sdb1 ext4 4.8G 20M 4.6G 1% / data1

/dev/sdb2               xfs       5.0G   33M  5.0G    1% /data2

/dev/sr0                iso9660   4.1G  4.1G     0  100% /run/media/root/CentOS 7 x86_64

/dev/mapper/myvg-mylv   xfs        30G   33M   30G    1% /data

7. Logical Volume increased to 35G

[root@localhost ~]# lvextend -L +5G /dev/myvg/mylv

  Size of logical volume myvg/mylv changed from 30.00 GiB (7680 extents) to 35.00 GiB (8960 extents).

  Logical volume mylv successfully resized

8. Edit / etc / fstab file to mount logical volumes, disk quotas and support options

[root@localhost ~]# vim /etc/fstab

/dev/myvg/mylv        /data        xfs     auto,usrquota,grpquota     0 0

9. Create a disk quota, crushlinux user / data directory under the file size of the soft limit is 80M, the hard limit for the 100M,

crushlinux the user / data directory soft limit the number of files to 80, 100 to hard limit.

[root@localhost ~]# quotacheck -avug

quotacheck: Skipping /dev/mapper/myvg-mylv [/data]

quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.

[root@localhost ~]# edquota -u crushlinux

Disk quotas for user crushlinux (uid 8889):

  Filesystem                   blocks       soft       hard     inodes     soft     hard

    / Dev / folders / myvg-mylv 0 81920 102400 0 80 100

[root@localhost ~]# quota -uvs crushlinux

Disk quotas for user crushlinux (uid 8889):

     Filesystem   space   quota   limit   grace   files   quota   limit   grace

/ Dev / folders / myvg-mylv

                     0K  81920K    100M               0      80     100       

10. Command using the touch dd tested at / data directory

[crushlinux@localhost root]$ touch /data/abc{1..102}

touch: Unable to create "/ data / abc101": out of disk quota

touch: Unable to create "/ data / abc102": out of disk quota

[crushlinux@localhost data]$ cd

[crushlinux@localhost ~]$ dd if=/dev/zero of=/data/bigfile bs=1M count=105

dd: write "/ data / bigfile" Error: Out of disk quota

Recording the reading of 101 + 0

Write a record 100 + 0

104857600 bytes (105 MB) have been copied, 0.417397 seconds, 251 MB / sec

11. View usage quotas: a user's perspective

[root@localhost ~]# quota -uvs crushlinux

Disk quotas for user crushlinux (uid 8889):

     Filesystem   space   quota   limit   grace   files   quota   limit   grace

/ Dev / folders / myvg-mylv

                     0K  81920K    100M             100*     80     100   6days

12. View usage quotas: file system perspective

[root@localhost ~]# repquota -auvs

*** Report for user quotas on device /dev/mapper/myvg-mylv

Block grace time: 7days; Inode grace time: 7days

                        Space limits                File limits

User            used    soft    hard  grace    used  soft  hard  grace

----------------------------------------------------------------------

root      --      8K      0K      0K              4     0     0      

crushlinux -+      0K  81920K    100M            100    80   100  6days

 

*** Status for user quotas on device /dev/mapper/myvg-mylv

Accounting: ON; Enforcement: ON

Inode: #131 (2 blocks, 2 extents)

Guess you like

Origin www.cnblogs.com/liyurui/p/11289715.html