Ampliar un RAID con discos de mayor capacidad sin perder datos
En algunas controladoras RAID podemos “expandir” un RAID si substituimos todos sus discos originales por otros de mayor capacidad. En el caso de controladoras mas sencillas no resulta tan simple, es el caso de:
# lspci (...) 01:00.0 SCSI storage controller: LSI Logic / Symbios Logic SAS1068E PCI-Express Fusion-MPT SAS (rev 08) (...)
Para extender el RAID deberemos ir substituyendo por pasos los discos. En un RAID1 hacemos primero uno por otro mayor capacidad y cuando este reconstruido el otro.
Una vez tenemos los dos discos de mayor capacidad cambiados, el RAID seguirá siendo de menor capacidad, por lo que al no darnos opción de extenderlo la controladora deberemos eliminar el RAID y volver a crearlo.
En este caso, la controladora inicializa los discos destruyendo una parte del disco, por lo que primero deberemos iniciar con alguna live y almacenar en un pendrive o algún sitio externo la tabla de particiones. Al no tener claro cuantos datos elimina la controladora del inicio del disco, podemos guardar un número suficientemente alto:
# dd if=/dev/sda of=/mnt/sda.mbr bs=512 count=409600
A continuación deberemos indicar a la controladora (Al iniciar el sistema indica que podemos entrar a configurarla mediante Control-C) que queremos destruir el RAID1 y lo volvemos a crear.
Al volver a arrancar con el Live veremos que ya no tiene particiones el disco, pero para el caso de esta controladora solo ha eliminado una parte del contenido. Ahora deberemos hacer el paso inverso:
# dd if=/mnt/sda.mbr of=/dev/sda bs=512 count=409600
A continuación releemos la tabla de particiones con partprobe:
# partprobe
Podremos ver que tenemos ya las particiones y podemos montar el sistema de ficheros. Al reiniciar ya volveremos a tener el sistema disponible, por lo que podríamos tirar por lo fácil y crear una partición nueva con el espacio que sobra:
# fdisk /dev/sda The number of cylinders for this disk is set to 121534. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 18340 147316018+ 83 Linux /dev/sda2 18341 19384 8385930 82 Linux swap / Solaris Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (19385-121534, default 19385): Using default value 19385 Last cylinder or +size or +sizeM or +sizeK (19385-121534, default 121534): Using default value 121534 Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 8e Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 18340 147316018+ 83 Linux /dev/sda2 18341 19384 8385930 82 Linux swap / Solaris /dev/sda3 19385 121534 820519875 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. # partprobe
O hacer el “más difícil todavía” ampliando el sistema de ficheros existente:
# fdisk -l /dev/sda Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 18340 147316018+ 83 Linux /dev/sda2 18341 19384 8385930 82 Linux swap / Solaris
Al tener la swap detrás del sistema de ficheros deberemos eliminarla:
# free -m
total used free shared buffers cached
Mem: 7985 1906 6078 0 17 1438
-/+ buffers/cache: 450 7534
Swap: 8189 0 8189
Primero la desactivamos:
# swapoff -a
A continuación eliminamos la partición:
# fdisk /dev/sda (...) Command (m for help): d Partition number (1-4): 2
Seguimos eliminando la partición del sistema de ficheros actual:
Command (m for help): d Selected partition 1
Y la volvemos a crear con un mayor tamaño:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-121534, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-121534, default 121534):
Para calcular el tamaño de la swap usamos el cilindro de inicio y final para calcular los que ocupaba:
$ echo "18341-19384" | bc -l -1043
A continuación se lo restamos a los disponibles para tener el número de cilindros que asignamos al sistema de ficheros:
$ echo "121534-1043" | bc -l 120491
Y se lo indicamos al fdisk:
Last cylinder or +size or +sizeM or +sizeK (1-121534, default 121534): 120491
Seguimos creando la partición de swap con el espacio que hemos dejado y le asignamos el tipo:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (120492-121534, default 120492): Using default value 120492 Last cylinder or +size or +sizeM or +sizeK (120492-121534, default 121534): Using default value 121534 Command (m for help): p Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 120491 967843926 83 Linux /dev/sda2 120492 121534 8377897+ 83 Linux Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): L 0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris 1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 82 Linux swap / So c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c7 Syrinx 5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data 6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility 8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df BootIt 9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap / Solaris) Command (m for help): p Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 120491 967843926 83 Linux /dev/sda2 120492 121534 8377897+ 82 Linux swap / Solaris Command (m for help):
Finalmente aplicamos los cambios:
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
A continuación deberemos ampliar el sistema de ficheros, pero aunque usemos el partprobe no nos va a dejar ampliarlo:
# partprobe # resize2fs /dev/sda1 resize2fs 1.39 (29-May-2006) The filesystem is already 36829004 blocks long. Nothing to do!
Por lo que deberemos reiniciar el equipo. Una vez reiniciado ya podremos extenderlo:
[root@foxy ~]# resize2fs /dev/sda1 resize2fs 1.39 (29-May-2006) Filesystem at /dev/sda1 is mounted on /; on-line resizing required Performing an on-line resize of /dev/sda1 to 241960981 (4k) blocks. The filesystem on /dev/sda1 is now 241960981 blocks long. [root@foxy ~]# df -hP Filesystem Size Used Avail Use% Mounted on /dev/sda1 895G 115G 734G 14% / tmpfs 3.9G 0 3.9G 0% /dev/shm
Para acabar la ampliación del disco deberemos crear y habilitar la nueva partición de swap:
# mkswap -L 'SWAP-sda2' /dev/sda2
Setting up swapspace version 1, size = 8578961 kB
LABEL=SWAP-sda2, no uuid
# swapon -a
# free -m
total used free shared buffers cached
Mem: 7985 7938 46 0 5904 1083
-/+ buffers/cache: 951 7033
Swap: 8181 0 8181
Relacionados
Imprimir
Deja un comentario: