天天看點

關于linux下raid的裝置檔案和格式化

概述

今天給dell t20裝了zstack,沒錯zstack鏡像底層其實就是centos,伺服器裡面有四塊硬碟,一塊300g的我是做系統盤的,三塊1T的硬碟我是打算用來存資料的,還可以做dell r410的存儲,因為dell t20是隻有軟raid的,我給這三塊硬碟做的是raid0,做完raid之後安裝完系統之後,我才發現我沒有給這個raid格式化,我百度了一下找到了檢視raid的方式,下面是操作

操作

首先我的dev目錄是下面這樣子的

[root@MiWiFi-R1CM-srv ~]# ls /dev
autofs         cpu              fd         kvm           mei                 oldmem  rfkill  sdc3      snd     tty11  tty19  tty26  tty33  tty40  tty48  tty55  tty62  ttyS3    usbmon4  vcsa3        zstack
block          cpu_dma_latency  full       log           mem                 port    rtc     sdd       stderr  tty12  tty2   tty27  tty34  tty41  tty49  tty56  tty63  uhid     vcs      vfio
bsg            crash            fuse       loop-control  mqueue              ppp     rtc0    sg0       stdin   tty13  tty20  tty28  tty35  tty42  tty5   tty57  tty7   uinput   vcs1     vga_arbiter
btrfs-control  disk             hpet       mapper        net                 ptmx    sda     sg1       stdout  tty14  tty21  tty29  tty36  tty43  tty50  tty58  tty8   urandom  vcs2     vhost-net
bus            dm-0             hugepages  mcelog        network_latency     ptp0    sdb     sg2       tty     tty15  tty22  tty3   tty37  tty44  tty51  tty59  tty9   usbmon0  vcs3     watchdog
char           dm-1             initctl    md            network_throughput  pts     sdc     sg3       tty0    tty16  tty23  tty30  tty38  tty45  tty52  tty6   ttyS0  usbmon1  vcsa     watchdog0
console        dri              input      md126         null                random  sdc1    shm       tty1    tty17  tty24  tty31  tty39  tty46  tty53  tty60  ttyS1  usbmon2  vcsa1    watchdog1
core           fb0              kmsg       md127         nvram               raw     sdc2    snapshot  tty10   tty18  tty25  tty32  tty4   tty47  tty54  tty61  ttyS2  usbmon3  vcsa2    zero           

重點是下面幾個 sda,sdb,sdc,sdc1,sdc2,sdc3,sdd

很明顯sdc是系統盤,sda和sdb,sdd是沒有分區的,是以他們三個是組了raid,然後我們看一下raid資訊

cat /proc/mdstat

[root@MiWiFi-R1CM-srv disk]#  cat /proc/mdstat
Personalities : [raid0] 
md126 : active raid0 sda[2] sdb[1] sdd[0]
      2930245632 blocks super external:/md127/0 32k chunks
      
md127 : inactive sda[2](S) sdb[1](S) sdd[0](S)
      9459 blocks super external:imsm
       
unused devices: <none>           

可以看到裝置檔案是md126和md127,是以我們隻要格式化md126就可以了,但是因為是大于2T的,是以我們要把他格式化成gpt分區表才可以,是以不能使用fdisk格式化,要使用gdisk,具體流程如下

[root@MiWiFi-R1CM-srv disk]# gdisk /dev/md126
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): ?
b    back up GPT data to a file
c    change a partition's name
d    delete a partition
i    show detailed information on a partition
l    list known partition types
n    add a new partition
o    create a new empty GUID partition table (GPT)
p    print the partition table
q    quit without saving changes
r    recovery and transformation options (experts only)
s    sort partitions
t    change a partition's type code
v    verify disk
w    write table to disk and exit
x    extra functionality (experts only)
?    print this menu

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-5860491230, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-5860491230, default = 5860491230) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): L
0700 Microsoft basic data  0c01 Microsoft reserved    2700 Windows RE          
4200 Windows LDM data      4201 Windows LDM metadata  7501 IBM GPFS            
7f00 ChromeOS kernel       7f01 ChromeOS root         7f02 ChromeOS reserved   
8200 Linux swap            8300 Linux filesystem      8301 Linux reserved      
8e00 Linux LVM             a500 FreeBSD disklabel     a501 FreeBSD boot        
a502 FreeBSD swap          a503 FreeBSD UFS           a504 FreeBSD ZFS         
a505 FreeBSD Vinum/RAID    a580 Midnight BSD data     a581 Midnight BSD boot   
a582 Midnight BSD swap     a583 Midnight BSD UFS      a584 Midnight BSD ZFS    
a585 Midnight BSD Vinum    a800 Apple UFS             a901 NetBSD swap         
a902 NetBSD FFS            a903 NetBSD LFS            a904 NetBSD concatenated 
a905 NetBSD encrypted      a906 NetBSD RAID           ab00 Apple boot          
af00 Apple HFS/HFS+        af01 Apple RAID            af02 Apple RAID offline  
af03 Apple label           af04 AppleTV recovery      af05 Apple Core Storage  
be00 Solaris boot          bf00 Solaris root          bf01 Solaris /usr & Mac Z
bf02 Solaris swap          bf03 Solaris backup        bf04 Solaris /var        
bf05 Solaris /home         bf06 Solaris alternate se  bf07 Solaris Reserved 1  
bf08 Solaris Reserved 2    bf09 Solaris Reserved 3    bf0a Solaris Reserved 4  
bf0b Solaris Reserved 5    c001 HP-UX data            c002 HP-UX service       
ed00 Sony system partitio  ef00 EFI System            ef01 MBR partition scheme
ef02 BIOS boot partition   fb00 VMWare VMFS           fb01 VMWare reserved     
fc00 VMWare kcore crash p  fd00 Linux RAID            
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/md126.
The operation has completed successfully.           

之後我們要做的就是格式化分區

mkfs.ext4 /dev/md126p1

格式化成ext4分區之後挂載

因為是共享存儲,是以我就在根目錄建立一個檔案夾

mkdir /data

挂載

sudo mount /dev/md126p1 /data/

之後檢視挂載的情況

[root@MiWiFi-R1CM-srv data]# df -h
檔案系統                 容量  已用  可用 已用% 挂載點
/dev/mapper/zstack-root  290G  5.9G  284G    3% /
devtmpfs                 7.8G     0  7.8G    0% /dev
tmpfs                    7.8G  4.0K  7.8G    1% /dev/shm
tmpfs                    7.8G  8.7M  7.8G    1% /run
tmpfs                    7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/sdc2                477M   99M  349M   23% /boot
/dev/sdc1                200M  9.5M  191M    5% /boot/efi
tmpfs                    1.6G     0  1.6G    0% /run/user/0
tmpfs                    1.6G     0  1.6G    0% /run/user/1000
/dev/md126p1             2.7T   89M  2.6T    1% /data           

沒錯,有2.7個T

歡迎關注Bboysoul的部落格

www.bboysoul.com

Have Fun

繼續閱讀