記一次創建LVM的日誌記錄

来源:http://www.cnblogs.com/drgcaosheng/archive/2016/09/13/5867455.html
-Advertisement-
Play Games

先上一張鳥哥LVM的圖.感覺這張最清楚了. 這裡到此就結束的.整合一下相關的一些步驟: ...


先上一張鳥哥LVM的圖.感覺這張最清楚了.

 

#以下以Xshell的日誌記錄系統直接記錄.上面添加了一些個人理解的註釋 
[BEGIN] 2016/9/13 9:22:24
#先查看下硬碟的情況.
[root@iZ23h637rtdZ ~]# fdisk -l

Disk /dev/vda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x00078f9c

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        7833    62912512   83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       65270   524281243+  8e  Linux LVM
#上面這裡顯示已經有LVM.但是為了方便演示. 下麵先將這個刪除掉了
[root@iZ23h637rtdZ ~]# fdisk /dev/vdb

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): p

Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       65270   524281243+  8e  Linux LVM

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-65270, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270): 
Using default value 65270

Command (m for help): p

Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       65270   524281243+  83  Linux
#此處使用t來修改格式.由於是需要LVM.所以需要改為8e的格式.
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       65270   524281243+  8e  Linux LVM

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@iZ23h637rtdZ ~]# partprobe 
Warning: WARNING: the kernel failed to re-read the partition table on /dev/vda (Device or resource busy).  
As a result, it may not reflect all of your changes until after reboot. [root@iZ23h637rtdZ ~]# fdisk -l Disk /dev/vda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 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: 0x00078f9c Device Boot Start End Blocks Id System /dev/vda1 * 1 7833 62912512 83 Linux Disk /dev/vdb: 536.9 GB, 536870912000 bytes 255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb Device Boot Start End Blocks Id System /dev/vdb1 1 65270 524281243+ 8e Linux LVM [root@iZ23h637rtdZ ~]# pvscan No matching physical volumes found #先建pv.後面接具體的劃分的路徑. [root@iZ23h637rtdZ ~]# pvcreate /dev/vdb1 Physical volume "/dev/vdb1" successfully created [root@iZ23h637rtdZ ~]# pvscan PV /dev/vdb1 lvm2 [499.99 GiB] Total: 1 [499.99 GiB] / in use: 0 [0 ] / in no VG: 1 [499.99 GiB] [root@iZ23h637rtdZ ~]# pvdisplay "/dev/vdb1" is a new physical volume of "499.99 GiB" --- NEW Physical volume --- PV Name /dev/vdb1 VG Name PV Size 499.99 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID GOeBQF-iCCD-n7i7-Y4DT-U5PE-tjHK-B9Z3CL #再建VG.由於是直接使用整個劃分的區塊,所以直接跟區塊名 /dev/vdb1,前面接的是vg名稱,這個隨便命名的. [root@iZ23h637rtdZ ~]# vgcreate mailbox_vg /dev/vdb1 Volume group "mailbox_vg" successfully created [root@iZ23h637rtdZ ~]# vgscan Reading all physical volumes. This may take a while... Found volume group "mailbox_vg" using metadata type lvm2 [root@iZ23h637rtdZ ~]# pvscan PV /dev/vdb1 VG mailbox_vg lvm2 [499.99 GiB / 499.99 GiB free] Total: 1 [499.99 GiB] / in use: 1 [499.99 GiB] / in no VG: 0 [0 ] [root@iZ23h637rtdZ ~]# vgdisplay --- Volume group --- VG Name mailbox_vg 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 499.99 GiB PE Size 4.00 MiB Total PE 127998 Alloc PE / Size 0 / 0 Free PE / Size 127998 / 499.99 GiB VG UUID JjdDER-Y1OK-ICwZ-3FgC-cry2-bZYl-SqD3RP #下麵需要創建LV.-l後面接的是pe的數量.這個可使用上面的vgdisplay的命令來查看. #然後後面接lv的名稱.也是可以隨便命名,但是個人建議這裡寫個可以區分的.要不到時難分清楚. [root@iZ23h637rtdZ ~]# lvcreate -l 127998 -n mailbox_lv mailbox_vg Logical volume "mailbox_lv" created [root@iZ23h637rtdZ ~]# lvdisplay --- Logical volume --- LV Path /dev/mailbox_vg/mailbox_lv LV Name mailbox_lv VG Name mailbox_vg LV UUID VPA4HE-22B4-gZc0-Qo8V-TO1C-tKaF-AT8s5T LV Write Access read/write LV Creation host, time iZ23h637rtdZ, 2016-09-13 09:25:34 +0800 LV Status available # open 0 LV Size 499.99 GiB Current LE 127998 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 [root@iZ23h637rtdZ ~]# fdisk -l Disk /dev/vda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 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: 0x00078f9c Device Boot Start End Blocks Id System /dev/vda1 * 1 7833 62912512 83 Linux Disk /dev/vdb: 536.9 GB, 536870912000 bytes 255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb Device Boot Start End Blocks Id System /dev/vdb1 1 65270 524281243+ 8e Linux LVM Disk /dev/mapper/mailbox_vg-mailbox_lv: 536.9 GB, 536862523392 bytes 255 heads, 63 sectors/track, 65269 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: 0x00000000 #建好了.進行格式化 [root@iZ23h637rtdZ ~]# mkfs -t ext4 /dev/mailbox_vg/mailbox_lv 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 32768000 inodes, 131069952 blocks 6553497 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 4000 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, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. #創建掛載目錄,進行掛載. [root@iZ23h637rtdZ ~]# mkdir /mail_mailbox [root@iZ23h637rtdZ ~]# mount /dev/ Display all 179 possibilities? (y or n) [root@iZ23h637rtdZ ~]# mount /dev/mailbox_vg/mailbox_lv /mail_mailbox/ [root@iZ23h637rtdZ ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 59G 1.9G 55G 4% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/mapper/mailbox_vg-mailbox_lv 493G 70M 467G 1% /mail_mailbox #使用vim修改fstab的文件.讓其開機自動的掛載 . 以下是後面cat /etc/fstab的內容補上,這裡vim沒有記錄 -------------------------------------------------------------------------------------- [root@iZ23h637rtdZ ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Aug 14 21:16:42 2014 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=94e4e384-0ace-437f-bc96-057dd64f42ee / ext4 defaults,barrier=0 1 1 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/mailbox_vg/mailbox_lv /mail_mailbox ext4 defaults 1 2 [root@iZ23h637rtdZ ~]# -------------------------------------------------------------------------------------- [root@iZ23h637rtdZ ~]# vim /etc/fstab #下麵進行umount然後再mount -a測試一下fstab是否正常寫 [root@iZ23h637rtdZ ~]# umount /mail_mailbox/ [root@iZ23h637rtdZ ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 59G 1.9G 55G 4% / tmpfs 3.9G 0 3.9G 0% /dev/shm [root@iZ23h637rtdZ ~]# mount -a [root@iZ23h637rtdZ ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 59G 1.9G 55G 4% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/mapper/mailbox_vg-mailbox_lv 493G 70M 467G 1% /mail_mailbox [END] 2016/9/13 9:32:31

這裡到此就結束的.整合一下相關的一些步驟:

#fdisk /dev/vdb 
#pvcreate /dev/vdb1
#vgcreate mailbox_vg /dev/vdb1
#lvcreate -l 127998 -n mailbox_lv mailbox_vg
#mkfs -t ext4 /dev/mailbox_vg/mailbox_lv 
#mkdir /mail_mailbox
#mount /dev/mailbox_vg/mailbox_lv /mail_mailbox/

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • I/O: 系統設定 預設輸入設備:標準輸入,STDIN,0 預設輸出設備:標準輸出,STDOUT,1 標準錯誤輸出:STDERR,2 屬於不同的數據流 標準輸入:鍵盤 標準輸出和錯誤輸出:顯示器 I/O重定向: 輸出重定向: > :覆蓋輸出 >> :追加輸出 2>:錯誤輸出 2>>:追加錯誤輸出 正 ...
  • Nginx("engine x")是一款輕量級的HTTP和反向代理伺服器。相比於Apache、lighttpd等,它具有占有記憶體少、併發能力強、穩定性高等優勢。它最常見的用途就是提供反向代理服務。 在Linux下我們需要下載Nginx的源代碼包並且手動編譯,而不是用包管理工具,例如Yum、Aptit ...
  • 一、在伺服器上打開 22、80、9011埠: iptables -A INPUT -p tcp --dport 9011 -j ACCEPT iptables -A OUTPUT -p tcp --sport 9011 -j ACCEPT iptables -A INPUT -p tcp --dp ...
  • 本來是開始分析uboot代碼的,但是無論是教材還是網上資料都對於我最新下的 uboot原碼結構不同,對於還是小白的我不容易找到相應的文件,下麵是uboot版本中文件組織結構的改變,,,,, u-boot版本情況 網站:http://ftp.denx.de/pub/u-boot/ 1、版本號變化: 2 ...
  • Linux系統實戰項目——sudo日誌審計 由於企業內部許可權管理啟用了sudo許可權管理,但是還是有一定的風險因素,畢竟運維、開發等各個人員技術水平、操作習慣都不相同,也會因一時失誤造成誤操作,從而影響系統運行 因此,徵對sudo提權的操作,便於管理與後續維護,開啟sudo日誌審計功能對用戶執行 su ...
  • 本文是Linux Shell系列教程的第(十五)篇,更多Linux Shell教程請看:Linux Shell系列教程 函數可以將一個複雜功能劃分成若幹模塊,從而使程式結構更加清晰,代碼重覆利用率更高。 高級語言都支持函數,Shell也不例外。今天就為大家介紹下Shell中函數相關用法。 一、She ...
  • 本文是Linux Shell系列教程的第(十二)篇,更多Linux Shell教程請看:Linux Shell系列教程 在上兩篇文章Linux Shell系列教程之(十)Shell for迴圈和Linux Shell系列教程之(十一)Shell while迴圈中,我們已經對Shell 迴圈語句的fo ...
  • 1. 查看svn 的用戶名,密碼: 找到用戶名,密碼文件,都是明文的,你可以看到 例:linux hjj@hjj-ubuntu:~/.subversion/auth/svn.simple$ ls 9aad7e9f713353a655cf4365926120c7 hjj@hjj-ubuntu:~/.s ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...