馬哥教育網絡班21期+第七周課程練習

1、創建一個10G分區,并格式為ext4文件系統;

   (1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;

   (2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳;

~]# fdisk  /dev/sda
      p:查看分區列表
      n:創建10G的邏輯分區
      w:保存并寫入磁盤
~]#  partx -a /dev/sda   連續執行兩遍
~]#  mke2fs -t ext4 -b 2048 -m 2 -L "MYDATA"  /dev/sda5
~]#  mkdir -p /data/mydata
~]# mount -o noatime, noexec,acl /dev/sda5 /data/mydata

2、創建一個大小為1G的swap分區,并創建好文件系統,并啟用之;

 ~]# fdisk /dev/sda

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
First cylinder (4175-15665, default 4175): 
Using default value 4175
Last cylinder, +cylinders or +size{K,M,G} (4175-15665, default 15665): +1G
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 82
Changed system type of partition 6 to 82 (Linux swap / Solaris)
Command (m for help): w
~]# partx -a /dev/sda
~]# partx -a /dev/sda
LKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
[root@magelinux ~]# mkswap /dev/sda6
Setting up swapspace version 1, size = 1060252 KiB
no label, UUID=d8e98437-9162-460f-a2ed-03ce35c86fc9
~]# swapon /dev/sda6

3、寫一個腳本

   (1)、獲取并列出當前系統上的所有磁盤設備;

   (2)、顯示每個磁盤設備上每個分區相關的空間使用信息;

#!/bin/bash
#
fdisk -l | grep -o "^/dev/[[:alnum:]]\{3,\}"
df -hl

4、總結RAID的各個級別及其組合方式和性能的不同;

RAID0:需要2塊或者2塊以上的盤組合

可用空間:N*min(S1,S2,…)

讀寫性能都會提升,無冗余功能

無容錯能力。

一個盤壞,所有數據都會丟失

最求最大容量和速度,安全性最低

RAID1:需要2塊或者2塊以上的盤組合

可用空間:1*min(S1,S2,…)

硬盤數量越多,其讀取速度就越大,但它的寫的速度有稍微的降低。

有冗余功能,最大容錯:n-1

但無論有多少個盤,其容量僅為一個盤。

最求最大安全性

RAID5:需要最少3塊硬盤

可用空間:(N-1)*min(S1,S2,…)

有冗余功能,最大容錯:1

最求最大容量,最小預算。

RAID6:需要最少4塊硬盤

可用空間:(N-2)*min(S1,S2,…)

有冗余功能,最大容錯:2

相比RAID5較安全

RAID10:需要最少4塊硬盤。

可用空間:n/2*min(S1,S2,…)

有冗余功能:最大容錯:n/2

安全性高,集合了RAID0與RAID1的優點

5、創建一個大小為10G的RAID1,要求有一個空閑盤,而且CHUNK大小為128k;

[root@magelinux tmp]# fdisk /dev/sda

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
First cylinder (4307-15665, default 4307): 
Using default value 4307
Last cylinder, +cylinders or +size{K,M,G} (4307-15665, default 15665): +10G

Command (m for help): n
First cylinder (5613-15665, default 5613): 
Using default value 5613
Last cylinder, +cylinders or +size{K,M,G} (5613-15665, default 15665): +10G

Command (m for help): n
First cylinder (6919-15665, default 6919): 
Using default value 6919
Last cylinder, +cylinders or +size{K,M,G} (6919-15665, default 15665): +10G

Command (m for help): t
Partition number (1-8): 7
Hex code (type L to list codes): fd
Changed system type of partition 7 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): fd
Changed system type of partition 8 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-9): 9
Hex code (type L to list codes): fd
Changed system type of partition 9 to fd (Linux raid autodetect)

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

[root@magelinux tmp]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8
[root@magelinux tmp]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8
BLKPG: Device or resource busy
error adding partition 9

root@magelinux dev]# mdadm -C /dev/md0 -a yes -n 2 -l 1 -x 1 -c 128 /dev/sda{7,8,9}
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
[root@magelinux dev]# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sda9[2](S) sda8[1] sda7[0]
      10482176 blocks super 1.2 [2/2] [UU]
      [>....................]  resync =  3.2% (335872/10482176) finish=4.5min speed=37319K/sec

6、創建一個大小為4G的RAID5設備,chunk大小為256k,格式化ext4文件系統,要求可開機自動掛載至/backup目錄,而且不更新訪問時間戳,且支持acl功能;

[root@magelinux ~]# fdisk /dev/sda

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
First cylinder (8225-15665, default 8225): 
Using default value 8225
Last cylinder, +cylinders or +size{K,M,G} (8225-15665, default 15665): +2G

Command (m for help): n
First cylinder (8487-15665, default 8487): 
Using default value 8487
Last cylinder, +cylinders or +size{K,M,G} (8487-15665, default 15665): +2G

Command (m for help): n
First cylinder (8749-15665, default 8749): 
Using default value 8749
Last cylinder, +cylinders or +size{K,M,G} (8749-15665, default 15665): +2G

Command (m for help): t
Partition number (1-12): 10
Hex code (type L to list codes): fd   
Changed system type of partition 10 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-12): 11
Hex code (type L to list codes): fd
Changed system type of partition 11 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-12): 12
Hex code (type L to list codes): fd
Changed system type of partition 12 to fd (Linux raid autodetect)

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

Calling ioctl() to re-read partition table.

root@magelinux ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8
BLKPG: Device or resource busy
error adding partition 9
[root@magelinux ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8
BLKPG: Device or resource busy
error adding partition 9
BLKPG: Device or resource busy
error adding partition 10
BLKPG: Device or resource busy
error adding partition 11
BLKPG: Device or resource busy
error adding partition 12
[root@magelinux ~]# mdadm -C /dev/md1 -a yes -n 3 -c 256K -l 5 /dev/sda{10,11,12}
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.

[root@magelinux ~]# mkfs.ext4 /dev/md1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=64 blocks, Stripe width=128 blocks
262944 inodes, 1051136 blocks
52556 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1077936128
33 block groups
32768 blocks per group, 32768 fragments per group
7968 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@magelinux ~]# mkdir /backup
root@magelinux ~]# blkid
/dev/sda2: UUID="95d2365a-6617-4f22-8e37-b09710889454" TYPE="ext4" 
/dev/sda1: UUID="0272d96d-ef83-40f9-b04f-03f18a9b6761" TYPE="ext4" 
/dev/sda3: UUID="dd168e27-cbc1-46ae-8064-91ea6580d897" TYPE="swap" 
/dev/block/8:2: UUID="95d2365a-6617-4f22-8e37-b09710889454" TYPE="ext4" 
/dev/sda5: LABEL="MYDATA" UUID="ac999e9a-a3a3-4524-85d5-b84674a224b5" TYPE="ext4" 
/dev/sda6: UUID="d8e98437-9162-460f-a2ed-03ce35c86fc9" TYPE="swap" 
/dev/sda7: UUID="b0764f82-324e-56a7-01e0-46888c4d22bf" UUID_SUB="be0ba639-5fd8-69fa-3f6f-2c56f535a7c4" LABEL="magelinux:0" TYPE="linux_raid_member" 
/dev/sda8: UUID="b0764f82-324e-56a7-01e0-46888c4d22bf" UUID_SUB="f61613d7-72fe-6475-b9f0-709bee024cb6" LABEL="magelinux:0" TYPE="linux_raid_member" 
/dev/sda9: UUID="b0764f82-324e-56a7-01e0-46888c4d22bf" UUID_SUB="3652cfe2-88b6-45b8-f736-78cb3e8eae28" LABEL="magelinux:0" TYPE="linux_raid_member" 
/dev/sda10: UUID="c82749e9-1f1c-53a1-9e92-47d70dd07a53" UUID_SUB="84f87f9f-ee97-e5cb-b49c-0fe224e39f5a" LABEL="magelinux:1" TYPE="linux_raid_member" 
/dev/sda11: UUID="c82749e9-1f1c-53a1-9e92-47d70dd07a53" UUID_SUB="ecdcc6df-c4da-a167-650d-2c8046a072a1" LABEL="magelinux:1" TYPE="linux_raid_member" 
/dev/sda12: UUID="c82749e9-1f1c-53a1-9e92-47d70dd07a53" UUID_SUB="61d34300-af29-9ed0-d116-fa045fba7c0f" LABEL="magelinux:1" TYPE="linux_raid_member" 
/dev/md1: UUID="da965a4f-afc7-4375-9f47-d69910523cee" TYPE="ext4" 
[root@magelinux /]# vim /etc/fstab
UUID=da965a4f-afc7-4375-9f47-d69910523cee       /backup         ext4    defaults,acl,nodiratime         0 0

7、寫一個腳本

   (1) 接受一個以上文件路徑作為參數;

   (2) 顯示每個文件擁有的行數;

   (3) 總結說明本次共為幾個文件統計了其行數;

#!/bin/bash
#
declare -i sum=0
if [ $# -lt 1 ];then
 echo “請您至少給出一條文件路徑”  && exit 1
fi
for i in $@;do
 if [ -f $i ];then
        echo "$i 的文件的行數是: `wc -l $i | cut -d" " -f1` "
        let sum++
 else
        echo "$i 不是正確的文件路徑"
 fi
done
  echo "本次統計的文件數為: $sum"

8、寫一個腳本

   (1) 傳遞兩個以上字符串當作用戶名;

   (2) 創建這些用戶;且密碼同用戶名;

   (3) 總結說明共創建了幾個用戶;

#!/bin/bash
#
declare -i name=0
if [ $# -lt 2 ] ;then
    echo "Please give at least two need to create a username"  && exit 5
fi
for i in $@;do
      id  $i &> /dev/null
    if [ $? -eq 0 ];then
        echo "This $i exists"  
    else
       useradd $i && echo "$i" | passwd  --stdin  $i
       let name++
    fi
done
 echo "Create user number:$name"

9、寫一個腳本,新建20個用戶,visitor1-visitor20;計算他們的ID之和;

#!/bin/bash
#
declare -i sum=0
for i in {1..20};do
     useradd visitor$i && echo "visitor$i UID is: `id -u visitor$i`"
     name=$(id -u visitor$i)
     let sum+=$name
done
   echo "the user UID sum is : $sum"

10、寫一腳本,分別統計/etc/rc.d/rc.sysinit、/etc/rc.d/init.d/functions和/etc/fstab文件中以#號開頭的行數之和,以及總的空白行數;

#!/bin/bash
#
declare -i a=0
declare -i b=0
for i in {/etc/rc.d/rc.sysinit,/etc/rc.d/init.d/functions,/etc/fstab};do
   fu=`grep "^#" $i | wc -l`
   ng=`grep "^[[:space:]]\+$" $i | wc -l`
   let a+=$fu
   let b+=$ng
done
echo "The total number of # for the beginning :$a"
echo "Total number of blank lines:$b"

11、寫一個腳本,顯示當前系統上所有默認shell為bash的用戶的用戶名、UID以及此類所有用戶的UID之和;

#!/bin/bash
#
declare -i  sum=0
user=$(grep "/bin/bash$" /etc/passwd)
for i in $user;do    
    uid=`echo $i | cut -d: -f3`
    user=`echo $i | cut -d: -f1`
    echo "$user  UID is $uid"
    let sum+=$uid
done 
echo "默認shell為bash的用戶UID之和為:$sum"

12、寫一個腳本,顯示當前系統上所有,擁有附加組的用戶的用戶名;并說明共有多少個此類用戶;

#!/bin/bash 

declare -i user=0
name=`cut -d: -f1 /etc/passwd`

for i in $name;do
    group=`id $i|cut -d" " -f3|awk -F"," '{print $2}'`
    if [ -n "$group" ];then
        echo "$i 擁有附加組"
        let user++
    fi
done
 echo "擁有附加組的用戶總數是: $user"

13、創建一個由至少兩個物理卷組成的大小為20G的卷組;要求,PE大小為8M;而在卷組中創建一個大小為5G的邏輯卷mylv1,格式化為ext4文件系統,開機自動掛載至/users目錄,支持acl;

[root@magelinux ~]# fdisk /dev/sda
Command (m for help): n  
First cylinder (2869-15665, default 2869): 
Using default value 2869
Last cylinder, +cylinders or +size{K,M,G} (2869-15665, default 15665): +10G

Command (m for help): n
First cylinder (4175-15665, default 4175): 
Using default value 4175
Last cylinder, +cylinders or +size{K,M,G} (4175-15665, default 15665): +10G

Command (m for help): t   
Partition number (1-6): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d5ced

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2614    20480000   83  Linux
/dev/sda3            2614        2869     2048000   82  Linux swap / Solaris
/dev/sda4            2869       15665   102788088+   5  Extended
/dev/sda5            2869        4174    10486599+  8e  Linux LVM
/dev/sda6            4175        5480    10490413+  8e  Linux LVM

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.
[root@magelinux ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
[root@magelinux ~]# pvcreate /dev/sda5
  Physical volume "/dev/sda5" successfully created
[root@magelinux ~]# pvcreate /dev/sda6
  Physical volume "/dev/sda6" successfully created
[root@magelinux ~]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda5       lvm2 ---  10.00g 10.00g
  /dev/sda6       lvm2 ---  10.00g 10.00g  
[root@magelinux ~]# vgcreate -s 8M myvg /dev/sda{5,6}
  Volume group "myvg" successfully created
[root@magelinux ~]# vgdisplay 
  --- Volume group ---
  VG Name               myvg
  System ID             
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               19.99 GiB
  PE Size               8.00 MiB
  Total PE              2559
  Alloc PE / Size       0 / 0   
  Free  PE / Size       2559 / 19.99 GiB
  VG UUID               NnCyy1-kevE-pul3-aGpH-GySi-GOQT-S4DABZ  
[root@magelinux ~]# lvcreate -L 5G -n mylv myvg
  Logical volume "mylv" created.
[root@magelinux ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/myvg/mylv
  LV Name                mylv
  VG Name                myvg
  LV UUID                5sVS3Y-xers-mlnv-c32W-pOnb-shBo-xLCxmD
  LV Write Access        read/write
  LV Creation host, time magelinux, 2016-08-26 23:31:39 +0800
  LV Status              available
  # open                 0
  LV Size                5.00 GiB
  Current LE             640
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0  
 [root@magelinux ~]# mkfs.ext4 /dev/myvg/mylv 
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 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

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override. 
[root@magelinux ~]# blkid
/dev/sda2: UUID="95d2365a-6617-4f22-8e37-b09710889454" TYPE="ext4" 
/dev/sda1: UUID="0272d96d-ef83-40f9-b04f-03f18a9b6761" TYPE="ext4" 
/dev/sda3: UUID="dd168e27-cbc1-46ae-8064-91ea6580d897" TYPE="swap" 
/dev/block/8:2: UUID="95d2365a-6617-4f22-8e37-b09710889454" TYPE="ext4" 
/dev/sda5: UUID="hXii7i-t1yU-k5ZA-3C6q-67iZ-2Rz0-JkZF2e" TYPE="LVM2_member" 
/dev/sda6: UUID="CLhY2q-9K77-she6-G7Mr-w4nw-9ZLv-J7ccsH" TYPE="LVM2_member" 
/dev/mapper/myvg-mylv: UUID="1e6bda45-524f-403e-9f52-5fa0d0c4f56b" TYPE="ext4" 

編輯/etc/fstab,在文末行添加此行內容                                           
  
UUID=1e6bda45-524f-403e-9f52-5fa0d0c4f56b        /users ext4    defaults,acl    0 0

14、新建用戶magedu;其家目錄為/users/magedu,而后su切換至此用戶,復制多個文件至家目錄;

[root@magelinux ~]# useradd -d /users/magedu magedu
[root@magelinux ~]# su - magedu
[magedu@magelinux ~]$ cp -ar /etc/rc.d/*  ~

15、擴展mylv1至9G,確保擴展完成后原有數據完全可用;

[root@magelinux ~]# lvextend -L +4G /dev/myvg/mylv 
  Size of logical volume myvg/mylv changed from 5.00 GiB (640 extents) to 9.00 GiB (1152 extents).
  Logical volume mylv successfully resized
[root@magelinux ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/myvg/mylv
  LV Name                mylv
  VG Name                myvg
  LV UUID                5sVS3Y-xers-mlnv-c32W-pOnb-shBo-xLCxmD
  LV Write Access        read/write
  LV Creation host, time magelinux, 2016-08-26 23:31:39 +0800
  LV Status              available
  # open                 0
  LV Size                9.00 GiB
  Current LE             1152
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  [root@magelinux ~]# resize2fs /dev/myvg/mylv 
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/myvg/mylv to 2359296 (4k) blocks.
The filesystem on /dev/myvg/mylv is now 2359296 blocks long.

16、縮減mylv1至7G,確保縮減完成后原有數據完全可用;

[root@magelinux ~]# umount /dev/myvg/mylv 
[root@magelinux ~]# e2fsck -f /dev/myvg/mylv 
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/myvg/mylv: 11/589824 files (0.0% non-contiguous), 72671/2359296 blocks
[root@magelinux ~]# resize2fs /dev/myvg/mylv 
[root@magelinux ~]# lvreduce -L 7G /dev/myvg/mylv 
  WARNING: Reducing active logical volume to 7.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce mylv? [y/n]: y
  Size of logical volume myvg/mylv changed from 9.00 GiB (1152 extents) to 7.00 GiB (896 extents).
  Logical volume mylv successfully resized
[root@magelinux ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/myvg/mylv
  LV Name                mylv
  VG Name                myvg
  LV UUID                5sVS3Y-xers-mlnv-c32W-pOnb-shBo-xLCxmD
  LV Write Access        read/write
  LV Creation host, time magelinux, 2016-08-26 23:31:39 +0800
  LV Status              available
  # open                 0
  LV Size                7.00 GiB
  Current LE             896
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  [root@magelinux ~]# mount /dev/myvg/mylv  /users

17、對mylv1創建快照,并通過備份數據;要求保留原有的屬主屬組等信息;

[root@magelinux users]# lvcreate -L 1G -n snapmylv  -p r -s /dev/myvg/mylv
[root@magelinux users]# cd /dev/myvg/
[root@magelinux myvg]# ls
mylv  snapmylv

原創文章,作者:微,如若轉載,請注明出處:http://www.www58058.com/41741

(0)
微
上一篇 2016-08-30 15:48
下一篇 2016-08-30

相關推薦

  • linux終端變量設置,文件系統,man使用說明,文件類型

    一、定義終端提示符的變量 export PS1=’\e[32m[\e[33m\u\e[31m@\e[35m\h\e[36m\t\e[34m\#\e[31m\s\e[37m\W\e[32m]\$ ‘  `]# export 是個命令      PS1指終端提示符變量    &n…

    Linux干貨 2013-06-16
  • N21第五周

    1.顯示/boot/grub2/grub.cfg中以至少一個空白字符開頭的行; ]# grep '^[[:space:]]\+' /boot/grub2/grub.cfg 2.顯示/etc/rc.d/init.d/functions文件中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行; ]#…

    Linux干貨 2016-08-15
  • Linux學習之課前環境安裝調試

    系統安裝,VNC,VMware軟件安裝

    2018-03-26
  • 關于大型網站技術演進的思考(三):存儲的瓶頸(3)

    原文出處: 夏天的森林    存儲的瓶頸寫到現在就要進入到深水區了,如果我們所做的網站已經到了做數據庫垂直拆分和水平拆分的階段,那么此時我們所面臨的技術難度的挑戰也會大大增強。 這里我們先回顧下數據庫的垂直拆分和水平拆分的定義: 垂直拆分:把一個數據庫中不同業務單元的數據分到不同的數據庫里。 水平拆分:是根據一定的規則把同一業務…

    Linux干貨 2015-03-03
  • GREP命令學習筆記

    GREP命令,全稱:Global search REgular expression and Print out the line. 是一個非常強大的文本搜索命令,與SED(stream editor,文本編輯工具)和AWK(文本分析、報告生成器)并稱文本處理三劍客。 一.GREP命令基本使用格式 grep [OPTIONS] PATTERN [FILE&#…

    Linux干貨 2016-06-22
  • centos 6.5下搭建svn服務端

    1、先配置好yum源,svn的包在系統光盤里就有 2、yum install subversion #安裝svn的服務端程序 3、mkdir -p /application/svndata #創建svn的數據存儲目錄,名字可以隨便取 4、svnserve -d -r /application/svndata/ #指定svn的數據存儲目錄,就是剛才創建的 5、…

    Linux干貨 2015-10-08

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-09-07 23:10

    作業完成的非常的棒,知識點總結到位,作業給出詳細的操作過程,加油!

欧美性久久久久