Linux磁盘管理

一、关于硬盘

硬盘最小储存单位是:扇区

文件系统最小储存单位是:block (1kb or 4kb)

操作系统读取硬盘时,不会一个个扇区地去读取,这样效率太低,而是一次性读取多个扇区,即一次性读取一个“块”(block)。这种由多个扇区组成的“块”,是文件存取的最小单位,block的大小。最常见是1kb ,即连2个扇区组成一个block。(4K=8扇区)

硬盘类型:

SAS、SATA、SSD、SCSI、IDE

MBR与GPT分区表:

a) MBR,主引导记录(Master Boot Record)现有硬盘分区模式,MBR分区的标准决定了MBR只支持在2TB以内的硬盘,超过2TB的硬盘也只能管理2TB

磁盘的0柱面、0磁头、1扇区称为主引导扇区(也叫主引导记录MBR),它由三个部分组成,主引导程序、硬盘分区表DPT(Disk Partition table)和分区有效标志(55AA).

在总共512字节的主引导扇区里主引导程序(boot loader)占446个字节,第二部分是partition table区(分区表),即DPT,占64个字节,硬盘中分区有多少以及没一分区的大小都记在其中。第三部分magic number ,占2个字节,固定为55AA

b) GPT,全局唯一标识分区表(GUID Partition Table),GUID全局唯一标识符(Globally Unique Identifier)。与MBR最大4个分区 表项的限制相比,GPT对分区数量没有限制。GPT可管理硬盘大小达到18EB(1EB=1024PB=1048576TB)

二、fdisk分区工具

先查看磁盘,sdb、sdc、sdd、sde、sdf、五个磁盘还没有分区

使用fdisk工具分区:一块磁盘可以分成4个主分区(4P)或者3个主分区加一个扩展分区(3p+1e)

[root@ip-lab_client ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom  
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    3G  0 part [SWAP]
└─sda3   8:3    0 16.8G  0 part /
sdb      8:16   0   20G  0 disk 
sdd      8:48   0   20G  0 disk 
sdc      8:32   0   20G  0 disk 
sdf      8:80   0  4.9T  0 disk 
sde      8:64   0   20G  0 disk 

现在开始分区(4p):

[root@ip-lab_client ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4c4254db.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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): help #输入help可以查看相应的命令
h: unknown command
Command action
 a   toggle a bootable flag
 b   edit bsd disklabel
 c   toggle the dos compatibility flag
 d   delete a partition
 l   list known partition types
 m   print this menu
 n   add a new partition
 o   create a new empty DOS partition table
 p   print the partition table
 q   quit without saving changes
 s   create a new empty Sun disklabel
 t   change a partition's system id
 u   change display/entry units
 v   verify the partition table
 w   write table to disk and exit
 x   extra functionality (experts only)
Command (m for help): n #输入n,增加一个分区
Command action
 e   extended
 p   primary partition (1-4)
p  #输入p,为主分区
Partition number (1-4): 1 #输入1,表示第一个主分区
First cylinder (1-2610, default 1): 1  #默认从第一个分区表开始
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):+5G  #+5G 表示第一个分区大小为5GB
Command (m for help): n #输入n,新增加一个分区
Command action
 e   extended
 p   primary partition (1-4)
p  #输入p,为主分区
Partition number (1-4): 2 #输入2,表示第二个主分区
First cylinder (655-2610, default 655):  直接回车
Using default value 655
Last cylinder, +cylinders or +size{K,M,G} (655-2610, default 2610):+5G# +5G 表示第二个分区大小为5GB
Command (m for help): n  #输入n,新增加一个分区
Command action
 e   extended
 p   primary partition (1-4)
p  #输入p,为主分区
Partition number (1-4): 3  #输入3,表示第三个主分区
First cylinder (1309-2610, default 1309):  直接回车
Using default value 1309
Last cylinder, +cylinders or +size{K,M,G} (1309-2610, default 2610):+5G #+5G 表示第二个分区大小为5GB
Command (m for help): n  #输入n,新增加一个分区
Command action
 e   extended
 p   primary partition (1-4)
p   #输入p,为主分区
Selected partition 4 自动会默认为4
First cylinder (1963-2610, default 1963): 回车
Using default value 1963
Last cylinder, +cylinders or +size{K,M,G} (1963-2610, default 2610): #回车,把剩下空间全部发给第四个主分区
Using default value 2610
Command (m for help): p #输入p 打印所有已经分好的分区

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xf6c94b22

 Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         654     5253223+  83  Linux
/dev/sdb2             655        1308     5253255   83  Linux
/dev/sdb3            1309        1962     5253255   83  Linux
/dev/sdb4            1963        2610     5205060   83  Linux
Command (m for help): w  最后一步,输入W 保存所有分区
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

现在为止磁盘sdb已经分好了四个主分区,接下来要把分区全部格式化后,挂载到相应目录,
让磁盘开机自动挂载。挂载好磁盘才可以进行读写操作

将sdb1,sdb2,sdb3,sdb4格式化成ext3文件系统

[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdb1
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdb2
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdb3
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdb4

然后将sdb1挂载在/home目录下,sdb2,sdb3,sdb4,分别挂载到/home/disk0, /home/disk1
, /home/disk2下

[root@ip-lab_client ~]# mkdir bak
[root@ip-lab_client ~]# cd bak
[root@ip-lab_client home]# mkdir disk0
[root@ip-lab_client home]# mkdir disk1
[root@ip-lab_client home]# mkdir disk2

编辑配置文件 /etc/fstab

[root@ip-lab_client home]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Mar 15 20:06:16 2017
#
# 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=d142517f-ad58-4f98-9cd8-558f6cf6c0be /                       ext4    defaults        1 1
UUID=4ff6775f-7726-4104-9ad2-6ec78925ee45 /boot                   ext4    defaults        1 2
UUID=46489792-1d2c-4c3c-965c-ababd0a57d87 swap                    swap    defaults        0 0

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/sdb1   /home                        ext3    defaults        0 0
/dev/sdb2   /home/disk0                  ext3    defaults        0 0
/dev/sdb3   /home/disk1                  ext3    defaults        0 0
/dev/sdb4   /home/disk2                  ext3    defaults        0 0

保存配置退出后,挂载一下全部分区

[root@ip-lab_client ~]# mount -a

查看挂载

[root@ip-lab_client ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdb1 on /home type ext3 (rw)
/dev/sdb2 on /home/disk0 type ext3 (rw)
/dev/sdb3 on /home/disk1 type ext3 (rw)
/dev/sdb4 on /home/disk2 type ext3 (rw)

 OR
[root@ip-lab_client ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom  
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    3G  0 part [SWAP]
└─sda3   8:3    0 16.8G  0 part /
sdb      8:16   0   20G  0 disk 
├─sdb1   8:17   0    5G  0 part /home
├─sdb2   8:18   0    5G  0 part /home/disk0
├─sdb3   8:19   0    5G  0 part /home/disk1
└─sdb4   8:20   0    5G  0 part /home/disk2

挂载有两种方式,一种使用分区对应的UUID 或者块设备如 /sdb1

查看分区对应UUID

[root@ip-lab_client ~]# blkid
/dev/sda1: UUID="4ff6775f-7726-4104-9ad2-6ec78925ee45" TYPE="ext4" 
/dev/sda2: UUID="46489792-1d2c-4c3c-965c-ababd0a57d87" TYPE="swap" 
/dev/sda3: UUID="d142517f-ad58-4f98-9cd8-558f6cf6c0be" TYPE="ext4" 
/dev/sdb1: UUID="2a297f59-8bd9-48b5-99c9-1a420e271ada" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb2: UUID="a5517b1c-9c89-40cf-aca8-b748e866dd8a" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb3: UUID="a77f5d27-8313-442d-9367-2b225f4cdcbf" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb4: UUID="36bf0458-c221-4bc3-a060-8912a97be07b" SEC_TYPE="ext2" TYPE="ext3" 

分区完成就可以对磁盘进行读写操作了~。

在对sdc磁盘进行分区这一次(3p+1e),然后采用UUid方式挂载。

[root@ip-lab_client ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5cf6f80f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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
Command action
 e   extended
 p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +5G

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

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

Command (m for help):n
Command action
 e   extended
 p   primary partition (1-4)
e e为扩展分区,第四个为扩展分区
Selected partition 4
First cylinder (1963-2610, default 1963): 回车
Using default value 1963
Last cylinder, +cylinders or +size{K,M,G} (1963-2610, default 2610): 回车,剩下都为扩展分区
Using default value 2610

Command (m for help): n #在扩展分区中在分逻辑分区
First cylinder (1963-2610, default 1963): 
Using default value 1963
Last cylinder, +cylinders or +size{K,M,G} (1963-2610, default 2610): 
Using default value 2610

Command (m for help): p 打印分区表

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x5cf6f80f

 Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         654     5253223+  83  Linux
/dev/sdc2             655        1308     5253255   83  Linux
/dev/sdc3            1309        1962     5253255   83  Linux
/dev/sdc4            1963        2610     5205060    5  Extended
/dev/sdc5            1963        2610     5205028+  83  Linux

Command (m for help): w  #保存分区

将分区格式

[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdc1
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdc2
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdc3
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdc5

查看uuid

[root@ip-lab_client ~]# blkid
/dev/sda1: UUID="4ff6775f-7726-4104-9ad2-6ec78925ee45" TYPE="ext4" 
/dev/sda2: UUID="46489792-1d2c-4c3c-965c-ababd0a57d87" TYPE="swap" 
/dev/sda3: UUID="d142517f-ad58-4f98-9cd8-558f6cf6c0be" TYPE="ext4" 
/dev/sdb1: UUID="2a297f59-8bd9-48b5-99c9-1a420e271ada" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb2: UUID="a5517b1c-9c89-40cf-aca8-b748e866dd8a" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb3: UUID="a77f5d27-8313-442d-9367-2b225f4cdcbf" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb4: UUID="36bf0458-c221-4bc3-a060-8912a97be07b" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc1: UUID="98a45b99-f7b4-4c1d-9263-5099058b49cd" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc2: UUID="1707af59-7e03-48f7-a884-fd88294f821c" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc3: UUID="a16d8850-ea9d-4ec4-89ec-13001e9f3b3c" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc5: UUID="0be10fe0-525f-4f14-ada5-7f1dcc3bf5b0" SEC_TYPE="ext2" TYPE="ext3"

创建目录

[root@ip-lab_client ~]# cd /home
[root@ip-lab_client home]# mkdir disk3
[root@ip-lab_client home]# mkdir disk4
[root@ip-lab_client home]# mkdir disk5
[root@ip-lab_client home]# mkdir disk6

编辑/etc/fstab把分区挂载到/home/disk3, /home/disk4 , /home/disk5 , /home/disk6, 采用uuid的方式

[root@ip-lab_client ~]# vi /etc/fstab

#
# 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=d142517f-ad58-4f98-9cd8-558f6cf6c0be /                       ext4    defaults        1 1
UUID=4ff6775f-7726-4104-9ad2-6ec78925ee45 /boot                   ext4    defaults        1 2
UUID=46489792-1d2c-4c3c-965c-ababd0a57d87 swap                    swap    defaults        0 0
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/sdb1   /home                        ext3    defaults        0 0
/dev/sdb2   /home/disk0                  ext3    defaults        0 0
/dev/sdb3   /home/disk1                  ext3    defaults        0 0
/dev/sdb4   /home/disk2                  ext3    defaults        0 0
UUID=98a45b99-f7b4-4c1d-9263-5099058b49cd  /home/disk3   ext3    defaults        0 0
UUID=1707af59-7e03-48f7-a884-fd88294f821c  /home/disk4   ext3    defaults        0 0
UUID=a16d8850-ea9d-4ec4-89ec-13001e9f3b3c  /home/disk5   ext3    defaults        0 0
UUID=0be10fe0-525f-4f14-ada5-7f1dcc3bf5b0  /home/disk6   ext3    defaults        0 0

保存配置退出

重新挂载一下全部分区

[root@ip-lab_client home]# mount -a

查看挂载

[root@ip-lab_client home]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdb1 on /home type ext3 (rw)
/dev/sdb2 on /home/disk0 type ext3 (rw)
/dev/sdb3 on /home/disk1 type ext3 (rw)
/dev/sdb4 on /home/disk2 type ext3 (rw)
/dev/sdc1 on /home/disk3 type ext3 (rw)
/dev/sdc2 on /home/disk4 type ext3 (rw)
/dev/sdc3 on /home/disk5 type ext3 (rw)
/dev/sdc5 on /home/disk6 type ext3 (rw)
[root@ip-lab_client home]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom  
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    3G  0 part [SWAP]
└─sda3   8:3    0 16.8G  0 part /
sdb      8:16   0   20G  0 disk 
├─sdb1   8:17   0    5G  0 part /home
├─sdb2   8:18   0    5G  0 part /home/disk0
├─sdb3   8:19   0    5G  0 part /home/disk1
└─sdb4   8:20   0    5G  0 part /home/disk2
sdd      8:48   0   20G  0 disk 
sdc      8:32   0   20G  0 disk 
├─sdc1   8:33   0    5G  0 part /home/disk3
├─sdc2   8:34   0    5G  0 part /home/disk4
├─sdc3   8:35   0    5G  0 part /home/disk5
├─sdc4   8:36   0    1K  0 part 
└─sdc5   8:37   0    5G  0 part /home/disk6
sdf      8:80   0  4.9T  0 disk 
sde      8:64   0   20G  0 disk 

分区挂载已经全部完成

三、parted分区工具

接下来对sdf(5T)硬盘进行分区

[root@ip-lab_client ~]# parted /dev/sdf
GNU Parted 2.1
使用 /dev/sdf
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help #输入help可以查看分区的命令
align-check TYPE N                        check partition N for TYPE(min|opt) alignment
check NUMBER                             do a simple check on the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition
help [COMMAND]                           print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partition NUMBER
mkpart PART-TYPE [FS-TYPE] START END     make a partition
mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system
move NUMBER START END                    move partition NUMBER
name NUMBER NAME                         name partition NUMBER as NAME
print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions,
    or a particular partition
quit                                     exit program
rescue START END                         rescue a lost partition near START and END
resize NUMBER START END                  resize partition NUMBER and its file system
rm NUMBER                                delete partition NUMBER
select DEVICE                            choose the device to edit
set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
unit UNIT                                set the default unit to UNIT
version                                  display the version number and copyright information of GNU Parted
(parted)  mklabel      #mklable 新建一个分区表                                                   
新的磁盘标签类型? GPT   #分区表的类型为GPT
(parted) mkpart        #mkpart,新建一个分区                                                     
分区名称?  []? 1       #给分区命名
文件系统类型?  [ext2]? ext3        #现在文件系统类型 ,这个可以在后续格式化选择想要的
起始点? 1             #从第一个扇区开始分                                                           
结束点? 500G          #设置500G大小
(parted) mkpart       #mklable 新建一个分区表                                                        
分区名称?  []? 2      #给分区命名                                                
文件系统类型?  [ext2]? ext3   #现在文件系统类型 ,这个可以在后续格式化选择想要的                                           
起始点? 500G   #从上一次分区结束开始                                                         
结束点? 1000G  #设置500G大小
(parted) mkpart                                                           
分区名称?  []? 3                                                         
文件系统类型?  [ext2]? ext3                                              
起始点? 1000G                                                            
结束点? 1500G
(parted) mkpart
分区名称?  []? 4                                                         
文件系统类型?  [ext2]? ext3                                              
起始点? 1500G                                                            
结束点? 2000G                                                            
(parted) mkpart
分区名称?  []? 5                                                         
文件系统类型?  [ext2]? ext3                                              
起始点? 2000G                                                            
结束点? 3000G
(parted) mkpart
分区名称?  []? 6                                                         
文件系统类型?  [ext2]? ext3                                              
起始点? 3000G                                                            
结束点? 5000G
(parted) P                                                                
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdf: 5369GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number   Start    End     Size    File system  Name  标志
  1      1049kB  500GB   500GB                1
  2      500GB   1000GB  500GB                2
  3      1000GB  1500GB  500GB                3
  4      1500GB  2000GB  500GB                4
  5      2000GB  3000GB  1000GB               5
  6      3000GB  5000GB  2000GB               6
 (parted) q    #退出                                                            
信息: You may need to update /etc/fstab.                                  

将分区格式化:

[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdf1
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdf2
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdf3
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdf4
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdf5
[root@ip-lab_client ~]# mkfs -t ext3 -c /dev/sdf6

先创建对应的目录

[root@ip-lab_client ~]# mkdir /bak
[root@ip-lab_client ~]# cd /bak
[root@ip-lab_client bak]# mkdir disk{0,1,2,3,4}

编辑/ect/fstab文件,把分区分别挂载到/bak ,/bak/disk0 , /bak/disk1 ,/bak/disk2 ,/bak/disk3 , /bak/disk4

[root@ip-lab_client bak]# vi /etc/fstab


#
# /etc/fstab
# Created by anaconda on Wed Mar 15 20:06:16 2017
UUID=4ff6775f-7726-4104-9ad2-6ec78925ee45 /boot                   ext4    defaults        1 2
UUID=46489792-1d2c-4c3c-965c-ababd0a57d87 swap                    swap    defaults        0 0
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/sdb1   /home                        ext3    defaults        0 0
/dev/sdb2   /home/disk0                  ext3    defaults        0 0
/dev/sdb3   /home/disk1                  ext3    defaults        0 0
/dev/sdb4   /home/disk2                  ext3    defaults        0 0
UUID=98a45b99-f7b4-4c1d-9263-5099058b49cd  /home/disk3   ext3    defaults        0 0
UUID=1707af59-7e03-48f7-a884-fd88294f821c  /home/disk4   ext3    defaults        0 0
UUID=a16d8850-ea9d-4ec4-89ec-13001e9f3b3c  /home/disk5   ext3    defaults        0 0
UUID=0be10fe0-525f-4f14-ada5-7f1dcc3bf5b0  /home/disk6   ext3    defaults        0 0
/dev/sdf1    /bak           ext3    defaults        0 0
/dev/sdf2    /bak/disk0     ext3    defaults        0 0
/dev/sdf3    /bak/disk1     ext3    defaults        0 0
/dev/sdf4    /bak/disk2     ext3    defaults        0 0
/dev/sdf5    /bak/disk3     ext3    defaults        0 0
/dev/sdf6    /bak/disk4     ext3    defaults        0 0

保存退出后重新挂载:

[root@ip-lab_client ~]# mount -a
[root@ip-lab_client ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdb1 on /home type ext3 (rw)
/dev/sdb2 on /home/disk0 type ext3 (rw)
/dev/sdb3 on /home/disk1 type ext3 (rw)
/dev/sdb4 on /home/disk2 type ext3 (rw)
/dev/sdc1 on /home/disk3 type ext3 (rw)
/dev/sdc2 on /home/disk4 type ext3 (rw)
/dev/sdc3 on /home/disk5 type ext3 (rw)
/dev/sdc5 on /home/disk6 type ext3 (rw)
/dev/sdf1 on /bak type ext3 (rw)
/dev/sdf2 on /bak/disk0 type ext3 (rw)
/dev/sdf3 on /bak/disk1 type ext3 (rw)
/dev/sdf4 on /bak/disk2 type ext3 (rw)
/dev/sdf5 on /bak/disk3 type ext3 (rw)
/dev/sdf6 on /bak/disk4 type ext3 (rw

分区完成可以进行读写操作~~~

[root@ip-lab_client ~]# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0     11:0    1  1024M  0 rom  
sda      8:0    0    20G  0 disk 
├─sda1   8:1    0   200M  0 part /boot
├─sda2   8:2    0     3G  0 part [SWAP]
└─sda3   8:3    0  16.8G  0 part /
sdb      8:16   0    20G  0 disk 
├─sdb1   8:17   0     5G  0 part /home
├─sdb2   8:18   0     5G  0 part /home/disk0
├─sdb3   8:19   0     5G  0 part /home/disk1
└─sdb4   8:20   0     5G  0 part /home/disk2
sdd      8:48   0    20G  0 disk 
sdc      8:32   0    20G  0 disk 
├─sdc1   8:33   0     5G  0 part /home/disk3
├─sdc2   8:34   0     5G  0 part /home/disk4
├─sdc3   8:35   0     5G  0 part /home/disk5
├─sdc4   8:36   0     1K  0 part 
└─sdc5   8:37   0     5G  0 part /home/disk6
sdf      8:80   0   4.9T  0 disk 
├─sdf1   8:81   0 465.7G  0 part /bak
├─sdf2   8:82   0 465.7G  0 part /bak/disk0
├─sdf3   8:83   0 465.7G  0 part /bak/disk1
├─sdf4   8:84   0 465.7G  0 part /bak/disk2
├─sdf5   8:85   0 931.3G  0 part /bak/disk3
└─sdf6   8:86   0   1.8T  0 part /bak/disk4
sde      8:64   0    20G  0 disk 

查看一下分区UUID

[root@ip-lab_client ~]# blkid
/dev/sda1: UUID="4ff6775f-7726-4104-9ad2-6ec78925ee45" TYPE="ext4" 
/dev/sda2: UUID="46489792-1d2c-4c3c-965c-ababd0a57d87" TYPE="swap" 
/dev/sda3: UUID="d142517f-ad58-4f98-9cd8-558f6cf6c0be" TYPE="ext4" 
/dev/sdb1: UUID="2a297f59-8bd9-48b5-99c9-1a420e271ada" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb2: UUID="a5517b1c-9c89-40cf-aca8-b748e866dd8a" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb3: UUID="a77f5d27-8313-442d-9367-2b225f4cdcbf" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb4: UUID="36bf0458-c221-4bc3-a060-8912a97be07b" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc1: UUID="98a45b99-f7b4-4c1d-9263-5099058b49cd" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc2: UUID="1707af59-7e03-48f7-a884-fd88294f821c" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc3: UUID="a16d8850-ea9d-4ec4-89ec-13001e9f3b3c" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdc5: UUID="0be10fe0-525f-4f14-ada5-7f1dcc3bf5b0" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdf1: UUID="a0c22db6-442b-4283-afc8-75de6102132c" TYPE="ext3" 
/dev/sdf2: UUID="d9216bae-fb4b-4f63-aecf-1f76e34d6429" TYPE="ext3" 
/dev/sdf3: UUID="894375c9-7c80-4c23-a869-ae2ae16807a6" TYPE="ext3" 
/dev/sdf4: UUID="93f2663a-ac59-4467-82cd-119d486dcac6" TYPE="ext3" 
/dev/sdf5: UUID="8d628d3e-6264-4880-9e30-e742bf345f00" TYPE="ext3" 
/dev/sdf6: UUID="ab1a2ba8-9df7-4e93-b5fa-37ba72433e72" TYPE="ext3" 

(~^ v ^~)

如果您觉得这篇文章对您有帮助,不妨支持我一下!
------ 本文结束 ------

版权声明

Stefanie'Notes by Stefanie is licensed under a Creative Commons BY-NC-ND 4.0 International License.
Stefanie创作并维护的Stefanie'Notes博客采用创作共用保留署名-非商业-禁止演绎4.0国际许可证
本文首发于Stefanie'Notes 博客( https://linshizhe.github.io/ ),版权所有,侵权必究。