Storage device management in Linux

From V5wiki

Jump to: navigation, search

Contents

UUID, mounting, fstab and etc.

blkid
kohn:/# blkid
/dev/sda1: TYPE="swap"
/dev/sda2: LABEL="BOOT" UUID="d3fe5cb0-5924-4071-8fba-f42fa30efd0b" TYPE="ext3"
/dev/sda3: UUID="b11d2120-1c22-4676-8103-aa3ee4f433e7" LABEL="ROOT" TYPE="reiserfs"
/dev/sda5: UUID="b23882be-6c02-427a-8923-0be8d8583dc9" LABEL="HOME" TYPE="reiserfs"
/dev/sda6: LABEL="SCRATCH" UUID="1aed4b11-ee0e-40b9-9a01-c4882487cfc5" TYPE="xfs"
/dev/sdb: UUID="5fab7894-5b91-f027-9195-f40acba1f793" TYPE="mdraid"
/dev/sdc: UUID="5fab7894-5b91-f027-9195-f40acba1f793" TYPE="mdraid"
/dev/sdd: UUID="5fab7894-5b91-f027-9195-f40acba1f793" TYPE="mdraid"
/dev/sde: UUID="5fab7894-5b91-f027-9195-f40acba1f793" TYPE="mdraid"
/dev/md0: UUID="2f6e4b14-9425-42b0-aa9d-d2c6f9648cd7" TYPE="xfs"

Здесь видно, что устройства /dev/sd[b-e] имеют один и тот же UUID и тем самым определяется их принадлежность к одному MD-устройству.

MD

Что происходит?

cat /proc/mdstat
   kohn:/etc# cat /proc/mdstat
   Personalities : [raid0]
   md0 : active raid0 sdb[0] sdd[3] sdc[2] sde[1]
         1953545856 blocks 64k chunks
   
   unused devices: <none>
mdadm -D /dev/md0

Выводит детальную информацию об одном или нескольких MD-устройствах

kohn:/# mdadm -D /dev/md0
/dev/md0:
        Version : 00.90
  Creation Time : Tue Oct 27 23:40:59 2009
     Raid Level : raid0
     Array Size : 1953545856 (1863.05 GiB 2000.43 GB)
   Raid Devices : 4
  Total Devices : 4
Preferred Minor : 0
    Persistence : Superblock is persistent
 
    Update Time : Mon Mar 29 14:15:29 2010
          State : active
 Active Devices : 4
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 0
 
     Chunk Size : 64K

           UUID : 9478ab5f:27f0915b:0af49591:93f7a1cb (local to host kohn)
         Events : 0.5

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       64        1      active sync   /dev/sde
       2       8       32        2      active sync   /dev/sdc
       3       8       48        3      active sync   /dev/sdd

Расширение MD-устройства

Удаление MD-устройства

Останавливаем массив.

mdadm -S /dev/md0

Очищаем суперблоки RAID на разделах, из которых собран массив.

mdadm --zero-superblock /dev/sd[a-e]1

Перенос дисков с одного хоста на другой

При переносе MD-устройств с одной машины на другую, сборка (assemble) не удастся, т.к. устройства ранее были созданы для другого хоста. Это видно по выводу следующей команды:

   kohn:/etc# mdadm --assemble --scan -v                                         
   mdadm: looking for devices for further assembly                               
   mdadm: /dev/sde is not built for host kohn.                                   
   mdadm: /dev/sdd is not built for host kohn.                                   
   mdadm: /dev/sdc is not built for host kohn.                                   
   mdadm: /dev/sdb is not built for host kohn.                                  
   mdadm: no recogniseable superblock on /dev/sda6                               
   mdadm: cannot open device /dev/sda5: Device or resource busy                  
   mdadm: no recogniseable superblock on /dev/sda4                               
   mdadm: cannot open device /dev/sda3: Device or resource busy                  
   mdadm: cannot open device /dev/sda2: Device or resource busy                  
   mdadm: cannot open device /dev/sda1: Device or resource busy                  
   mdadm: cannot open device /dev/sda: Device or resource busy                   
   mdadm: No arrays found in config file or automatically

Исправляет ситуацию команда mdadm --assemble --scan --auto-update-homehost

   kohn:/etc# mdadm --assemble --scan --auto-update-homehost -v
   mdadm: looking for devices for further assembly             
   mdadm: /dev/sde is not built for host kohn.                 
   mdadm: /dev/sdd is not built for host kohn.                 
   mdadm: /dev/sdc is not built for host kohn.                 
   mdadm: /dev/sdb is not built for host kohn.                 
   mdadm: no recogniseable superblock on /dev/sda6             
   mdadm: cannot open device /dev/sda5: Device or resource busy
   mdadm: no recogniseable superblock on /dev/sda4             
   mdadm: cannot open device /dev/sda3: Device or resource busy
   mdadm: cannot open device /dev/sda2: Device or resource busy
   mdadm: cannot open device /dev/sda1: Device or resource busy
   mdadm: cannot open device /dev/sda: Device or resource busy 
   mdadm: looking for devices for further assembly             
   mdadm: no RAID superblock on /dev/sda6                      
   mdadm: cannot open device /dev/sda5: Device or resource busy
   mdadm: no RAID superblock on /dev/sda4                      
   mdadm: cannot open device /dev/sda3: Device or resource busy
   mdadm: cannot open device /dev/sda2: Device or resource busy
   mdadm: cannot open device /dev/sda1: Device or resource busy
   mdadm: cannot open device /dev/sda: Device or resource busy 
   mdadm: /dev/sde is identified as a member of /dev/md/0, slot 1.
   mdadm: /dev/sdd is identified as a member of /dev/md/0, slot 3.
   mdadm: /dev/sdc is identified as a member of /dev/md/0, slot 2.
   mdadm: /dev/sdb is identified as a member of /dev/md/0, slot 0.
   mdadm: added /dev/sde to /dev/md/0 as 1                        
   mdadm: added /dev/sdc to /dev/md/0 as 2                        
   mdadm: added /dev/sdd to /dev/md/0 as 3                        
   mdadm: added /dev/sdb to /dev/md/0 as 0                        
   mdadm: /dev/md/0 has been started with 4 drives.
   mdadm: looking for devices for further assembly                
   mdadm: no recogniseable superblock on /dev/md/0
   mdadm: cannot open device /dev/sde: Device or resource busy    
   mdadm: cannot open device /dev/sdd: Device or resource busy    
   mdadm: cannot open device /dev/sdc: Device or resource busy    
   mdadm: cannot open device /dev/sdb: Device or resource busy    
   mdadm: no recogniseable superblock on /dev/sda6                
   mdadm: cannot open device /dev/sda5: Device or resource busy   
   mdadm: no recogniseable superblock on /dev/sda4                
   mdadm: cannot open device /dev/sda3: Device or resource busy   
   mdadm: cannot open device /dev/sda2: Device or resource busy   
   mdadm: cannot open device /dev/sda1: Device or resource busy   
   mdadm: cannot open device /dev/sda: Device or resource busy    
   mdadm: looking for devices for further assembly                
   mdadm: no recogniseable superblock on /dev/md/0                
   mdadm: cannot open device /dev/sde: Device or resource busy    
   mdadm: cannot open device /dev/sdd: Device or resource busy    
   mdadm: cannot open device /dev/sdc: Device or resource busy    
   mdadm: cannot open device /dev/sdb: Device or resource busy    
   mdadm: no recogniseable superblock on /dev/sda6                
   mdadm: cannot open device /dev/sda5: Device or resource busy   
   mdadm: no recogniseable superblock on /dev/sda4                
   mdadm: cannot open device /dev/sda3: Device or resource busy   
   mdadm: cannot open device /dev/sda2: Device or resource busy   
   mdadm: cannot open device /dev/sda1: Device or resource busy   
   mdadm: cannot open device /dev/sda: Device or resource busy

Перенос системного диска на RAID1 с LVM

Перенос системного диска на RAID1 с LVM

Re-read The Partition Table Without Rebooting Linux System

partprobe

http://www.cyberciti.biz/tips/re-read-the-partition-table-without-rebooting-linux-system.html

Rescan disk size after disk resizing

После увеличения размера диска (например, у виртуальной машины) гостевая система не знает о новом размере диска. При этом

# smartctl --all /dev/sdb

показывает новый размер устройства, а fdisk (и т.п.) - старый.


Необходимо инициировать сканирование диска следующей командой:

# echo 1 > /sys/block/sdb/device/rescan

После этого можно изменять таблицу разделов (если она есть) или изменить PV, если он сразу на диске:

# pvresize /dev/sdb
Personal tools