Linux可以挂接“本地磁盘”或者通过光纤(FC SAN)、网络挂载(ISCSI)外部磁盘设备,这类一般为块设备;还可以通过NFS挂载文件系统。
磁盘及分区标识
一般/dev/disk目录中有:by-path, by-id, by-uuid, by-label, by-partuuid子目录,里面存放了对应的标识,并且被连接到真实的设备符号。
1) by-path目录
“列举出所有连接到本机器上的块设备及分区”,这个机器是使用了两路光纤连接到一套主备存储设备上(存储设备上给分配了两个LUN,被本机映射为sdb~sdu,每条路径都会被列出来),有两块组成RAID1的本机磁盘(这里被分配为sda)。
路径被连接到一个/dev目录的设备符号。
[root@ora11gstandby ~]# ls -l /dev/disk/by-path/ total 0 lrwxrwxrwx 1 root root 9 Apr 15 2013 ide-0:0 -> ../../hda lrwxrwxrwx 1 root root 9 May 6 2013 pci-0000:00:1d.2-usb-0:2.2:1.0-scsi-0:0:0:0 -> ../../sr0 lrwxrwxrwx 1 root root 9 May 6 2013 pci-0000:00:1d.2-usb-0:2.2:1.1-scsi-0:0:0:0 -> ../../sdv lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:09:00.0-scsi-0:2:0:0 -> ../../sda lrwxrwxrwx 1 root root 10 Apr 15 2013 pci-0000:09:00.0-scsi-0:2:0:0-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Apr 15 2013 pci-0000:09:00.0-scsi-0:2:0:0-part2 -> ../../sda2 lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x500601643ee020ff:0x0000000000000000 -> ../../sdj lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x500601653ee02138:0x0000000000000000 -> ../../sdb lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x500601653ee02138:0x0001000000000000 -> ../../sdc lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x500601653ee02138:0x0002000000000000 -> ../../sdd lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x500601653ee02138:0x0003000000000000 -> ../../sde lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x5006016c3ee020ff:0x0000000000000000 -> ../../sdk lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x5006016d3ee02138:0x0000000000000000 -> ../../sdf lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x5006016d3ee02138:0x0001000000000000 -> ../../sdg lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x5006016d3ee02138:0x0002000000000000 -> ../../sdh lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:86:00.0-fc-0x5006016d3ee02138:0x0003000000000000 -> ../../sdi lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x500601643ee02138:0x0000000000000000 -> ../../sdp lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x500601643ee02138:0x0001000000000000 -> ../../sdq lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x500601643ee02138:0x0002000000000000 -> ../../sdr lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x500601643ee02138:0x0003000000000000 -> ../../sds lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x500601653ee020ff:0x0000000000000000 -> ../../sdt lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x5006016c3ee02138:0x0000000000000000 -> ../../sdl lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x5006016c3ee02138:0x0001000000000000 -> ../../sdm lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x5006016c3ee02138:0x0002000000000000 -> ../../sdn lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x5006016c3ee02138:0x0003000000000000 -> ../../sdo lrwxrwxrwx 1 root root 9 Apr 15 2013 pci-0000:8b:00.0-fc-0x5006016d3ee020ff:0x0000000000000000 -> ../../sdu
2)by-id目录
每个块设备都被分配一个唯一的ID,设备被连接到一个/dev目录的设备符号。同一个设备有可能因为设备的插拔被分配到不同的设备符号,但是它的唯一ID不会发生变更 ,在grub和fstab中可以直接使用全路径进行挂载。
[root@ora11gstandby ~]# ls -l /dev/disk/by-id/ total 0 lrwxrwxrwx 1 root root 9 Apr 15 2013 ata-IBM_SATA_DEVICE_81Y3673_YP15_001196 -> ../../hda lrwxrwxrwx 1 root root 9 Apr 15 2013 scsi-350060160bee020ff50060160bee020ff -> ../../sdk lrwxrwxrwx 1 root root 9 Apr 15 2013 scsi-3600601606c0033002a2eb59b7ca5e211 -> ../../sdb lrwxrwxrwx 1 root root 9 Apr 15 2013 scsi-3600601606c0033009afcdb86a9a5e211 -> ../../sdi lrwxrwxrwx 1 root root 9 Apr 15 2013 scsi-3600601606c0033009c36f072a9a5e211 -> ../../sdd lrwxrwxrwx 1 root root 9 Apr 15 2013 scsi-3600601606c003300ccd3b2ab7ca5e211 -> ../../sdc lrwxrwxrwx 1 root root 9 Apr 15 2013 scsi-3600605b005961a6018d05713155e9bc8 -> ../../sda lrwxrwxrwx 1 root root 10 Apr 15 2013 scsi-3600605b005961a6018d05713155e9bc8-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Apr 15 2013 scsi-3600605b005961a6018d05713155e9bc8-part2 -> ../../sda2 lrwxrwxrwx 1 root root 9 May 6 2013 usb-KVM_vmDisk_212052084400 -> ../../sdv lrwxrwxrwx 1 root root 9 May 6 2013 usb-KVM_vmDisk-CD_212052084400 -> ../../sr0
使用了LVM卷的机器,
root@cs1:/home/jilili# ls -l /dev/disk/by-id/ total 0 lrwxrwxrwx 1 root root 9 Nov 20 10:28 ata-UJDA782_DVD_CDRW_HE55_147520 -> ../../sr0 lrwxrwxrwx 1 root root 10 Nov 20 10:59 dm-name-cs1-root -> ../../dm-0 lrwxrwxrwx 1 root root 10 Nov 20 10:59 dm-name-cs1-swap_1 -> ../../dm-1 lrwxrwxrwx 1 root root 10 Nov 20 10:59 dm-uuid-LVM-AYJByldGz8bviRBoC6vdB3zy505Cyzs7almOKXJYsAT4RsoDgYkDJ0CkR9a81t7H -> ../../dm-1 lrwxrwxrwx 1 root root 10 Nov 20 10:59 dm-uuid-LVM-AYJByldGz8bviRBoC6vdB3zy505Cyzs7BLUAvnFtRzxvUZQoBDKJbgfgpb0WCufv -> ../../dm-0 lrwxrwxrwx 1 root root 9 Nov 20 10:59 scsi-3600605b00426c4f0195a7a661957bbfe -> ../../sda lrwxrwxrwx 1 root root 10 Nov 20 10:28 scsi-3600605b00426c4f0195a7a661957bbfe-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Nov 20 10:28 scsi-3600605b00426c4f0195a7a661957bbfe-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Nov 20 10:28 scsi-3600605b00426c4f0195a7a661957bbfe-part3 -> ../../sda3 lrwxrwxrwx 1 root root 9 Nov 20 10:59 wwn-0x600605b00426c4f0195a7a661957bbfe -> ../../sda lrwxrwxrwx 1 root root 10 Nov 20 10:28 wwn-0x600605b00426c4f0195a7a661957bbfe-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Nov 20 10:28 wwn-0x600605b00426c4f0195a7a661957bbfe-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Nov 20 10:28 wwn-0x600605b00426c4f0195a7a661957bbfe-part3 -> ../../sda3
3)by-uuid目录
UUID是区分磁盘设备“分区”的唯一标识,可以根据UUID mount设备,不会因设备符号发生变化而改变。可以在grub中使用这个标识,Ubuntu请查看/boot/grub/grub.cfg
[root@ora11gstandby ~]# ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 Apr 15 2013 9cd810eb-1abf-4bcb-a05e-03d97637f13a -> ../../sda1
使用了LVM卷的机器
root@cs1:/home/jilili# ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 Nov 20 10:28 2b0714b2-c742-44b1-befd-a691c0d9aed5 -> ../../sda2 lrwxrwxrwx 1 root root 10 Nov 20 10:59 33a288b0-6319-4d76-84a8-45b399d7ab5d -> ../../dm-0 lrwxrwxrwx 1 root root 10 Nov 20 10:59 97c6b7ff-df12-4c60-8ad5-cfe5515a896e -> ../../dm-1 lrwxrwxrwx 1 root root 10 Nov 20 10:28 D3B7-7CE8 -> ../../sda1
也可以使用blkid查看uuid
root@cs1:/home/jilili# blkid /dev/sda2 /dev/sda2: UUID="2b0714b2-c742-44b1-befd-a691c0d9aed5" TYPE="ext2"
可以使用tune2fs修改uuid
# tune2fs -U c1b9d5a2-f162-11cf-9ece-0020afc76f16 /dev/sda5 或者 # genuuid | xargs tune2fs /dev/sda5 -U
4)by-label目录
也可以给分区添加标签,根基标签mount设备,分配的标签必须唯一。
[root@ora11gstandby ~]# ls -l /dev/disk/by-label/ total 0 lrwxrwxrwx 1 root root 10 Apr 15 2013 boot -> ../../sda1
通过e2label查看标签
[root@hdfs01 ~]# e2label /dev/vda1 boot
使用e2label设置分区标签
[root@hdfs01 ~]# e2label /dev/vda1 boot
使用tune2fs设置分区标签
[root@hdfs01 ~]# tune2fs -L boot /dev/vda1
格式化时设置分区标签
[root@hdfs01 ~]# mkfs -t ext3 -L data01 /dev/sdb1
5)by-partuuid
如果是gpt分区则会在此路径分配标识。
root@cs1:/home/jilili# ls -l /dev/disk/by-partuuid/ total 0 lrwxrwxrwx 1 root root 10 Nov 20 10:28 9b59b712-9f46-42cf-9db2-666f8555f381 -> ../../sda1 lrwxrwxrwx 1 root root 10 Nov 20 10:28 9c5903ea-8c1b-4b3d-ad56-efa2d438bce1 -> ../../sda3 lrwxrwxrwx 1 root root 10 Nov 20 10:28 b3a8a836-d580-4ca8-bfac-624492774fee -> ../../sda2
磁盘分区及空间分配信息
fdisk适用于非gpt磁盘,parted可以对非gpt和gpt磁盘进行操作。
Redhat/CentOS 最小化安装不会安装这个工具,需要自己安装。
磁盘挂载及空间使用情况
使用df命令可以查看磁盘挂载路基和空间使用情况。
root@cs1:/home/jilili# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cs1-root 1.1T 718G 263G 74% / udev 32G 4.0K 32G 1% /dev tmpfs 13G 492K 13G 1% /run none 5.0M 0 5.0M 0% /run/lock none 32G 0 32G 0% /run/shm cgroup 32G 0 32G 0% /sys/fs/cgroup /dev/sda2 229M 27M 190M 13% /boot /dev/sda1 190M 128K 190M 1% /boot/efi 192.168.2.150:/export/primary 1.1T 718G 263G 74% /mnt/09c26459-d9b9-3705-863a-aa2092f17706
相关内容
· ZFS更换磁盘