[1] Installing Slackware on Logical volumes
[2] Logical volume management
Presupunem urmatorul scenariu: ati instalat Linux si dupa un timp, hard-disk-ul s-a umplut. Doriti sa puteti adauga fara probleme un nou hardisk si sa il adaugati la unul dintre directoarele existente; un exemplu foarte frecvent este acela in care aveti o partitie a hard-disk-ului montata pe sistemul de fisiere /home.
Ca sa puteti realiza aceasta sarcina trebuie sa utilizati LVM. Nu este posibila adaugarea de noi partitii (nou spatiu), la unul din directoarele existente (/, /home etc), fara utilizarea LVM. Iata exemplul concret - poate fi usor adaptat la nevoile si cerintele voastre, daca l-ati inteles si ati mai si citit documentatia indicata:
sh-4.2$ su - Password: root@yeti:~# mkdir LVM-test root@yeti:~# cd LVM-test/ root@yeti:~/LVM-test# dd if=/dev/urandom of=lvm.test1 bs=1k count=20480 20480+0 records in 20480+0 records out 20971520 bytes (21 MB) copied, 3.22633 s, 6.5 MB/s root@yeti:~/LVM-test# losetup -f --show lvm.test1 /dev/loop0 root@yeti:~/LVM-test# fdisk /dev/loop0 Welcome to fdisk (util-linux 2.21.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x63fcbdb7. Command (m for help): p Disk /dev/loop0: 20 MB, 20971520 bytes 255 heads, 63 sectors/track, 2 cylinders, total 40960 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x63fcbdb7 Device Boot Start End Blocks Id System Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-40959, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-40959, default 40959): Using default value 40959 Partition 1 of type Linux and of size 19 MiB is set Command (m for help): p Disk /dev/loop0: 20 MB, 20971520 bytes 255 heads, 63 sectors/track, 2 cylinders, total 40960 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x63fcbdb7 Device Boot Start End Blocks Id System /dev/loop0p1 2048 40959 19456 83 Linux Command (m for help): t Selected partition 1 Hex code (type L to list codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ 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 1e Hidden W95 FAT1 80 Old Minix Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): p Disk /dev/loop0: 20 MB, 20971520 bytes 255 heads, 63 sectors/track, 2 cylinders, total 40960 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x63fcbdb7 Device Boot Start End Blocks Id System /dev/loop0p1 2048 40959 19456 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 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. root@yeti:~/LVM-test# pvcreate /dev/loop0 Physical volume "/dev/loop0" successfully created root@yeti:~/LVM-test# vgcreate vg-test /dev/loop0 Volume group "vg-test" successfully created root@yeti:~/LVM-test# lvcreate -L 4M -n discul1 vg-test Logical volume "discul1" created root@yeti:~/LVM-test# lvcreate -l 100%FREE -n discul2 vg-test Logical volume "discul2" created root@yeti:~/LVM-test# lvdisplay --- Logical volume --- LV Path /dev/vg-test/discul1 LV Name discul1 VG Name vg-test LV UUID iYp3EO-ygAm-D0a3-Qfaq-GPOc-GDAy-Hcyri2 LV Write Access read/write LV Creation host, time yeti, 2012-11-01 15:52:09 +0200 LV Status available # open 0 LV Size 4.00 MiB Current LE 1 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg-test/discul2 LV Name discul2 VG Name vg-test LV UUID NiyOd1-15eW-nn7d-ksZq-Fe5r-46pT-rW18j6 LV Write Access read/write LV Creation host, time yeti, 2012-11-01 15:53:49 +0200 LV Status available # open 0 LV Size 12.00 MiB Current LE 3 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 root@yeti:~/LVM-test# vgdisplay --- Volume group --- VG Name vg-test System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 16.00 MiB PE Size 4.00 MiB Total PE 4 Alloc PE / Size 4 / 16.00 MiB Free PE / Size 0 / 0 VG UUID Ill8va-3lTi-3PwF-e80d-czg7-YjZw-AQDWjD root@yeti:~/LVM-test# pvdisplay --- Physical volume --- PV Name /dev/loop0 VG Name vg-test PV Size 20.00 MiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 4 Free PE 0 Allocated PE 4 PV UUID lBPYko-wmlj-eg9B-slbh-Iwr9-ODBv-Z9YnRT root@yeti:~/LVM-test# mkfs.ext3 -m 0 /dev/vg-test/discul1 mke2fs 1.42.6 (21-Sep-2012) Discarding device blocks: done Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 1024 inodes, 4096 blocks 0 blocks (0.00%) reserved for the super user First data block=1 Maximum filesystem blocks=4194304 1 block group 8192 blocks per group, 8192 fragments per group 1024 inodes per group Allocating group tables: done Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done root@yeti:~/LVM-test# tune2fs -i 0 /dev/vg-test/discul1 tune2fs 1.42.6 (21-Sep-2012) Setting interval between checks to 0 seconds root@yeti:~/LVM-test# mkfs.ext3 -m 0 /dev/vg-test/discul2 mke2fs 1.42.6 (21-Sep-2012) Discarding device blocks: done Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 3072 inodes, 12288 blocks 0 blocks (0.00%) reserved for the super user First data block=1 Maximum filesystem blocks=12582912 2 block groups 8192 blocks per group, 8192 fragments per group 1536 inodes per group Superblock backups stored on blocks: 8193 Allocating group tables: done Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done root@yeti:~/LVM-test# tune2fs -i 0 /dev/vg-test/discul2 tune2fs 1.42.6 (21-Sep-2012) Setting interval between checks to 0 seconds root@yeti:~/LVM-test# mount /dev/vg-test/discul1 /mnt/LVM/disc1/ -t ext3 -o rw root@yeti:~/LVM-test# mount /dev/vg-test/discul2 /mnt/LVM/disc2/ -t ext3 -o rw root@yeti:~/LVM-test# mount /dev/root on / type ext4 (rw,commit=0) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) /dev/sda1 on /mnt/WindowsXP type fuseblk (rw,allow_other,blksize=4096,default_permissions) tmpfs on /dev/shm type tmpfs (rw) /dev/sdb5 on /mnt/E type fuseblk (rw,allow_other,blksize=4096,default_permissions) gvfs-fuse-daemon on /home/tri/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=tri) /dev/mapper/vg--test-discul1 on /mnt/LVM/disc1 type ext3 (rw) /dev/mapper/vg--test-discul2 on /mnt/LVM/disc2 type ext3 (rw) root@yeti:~/LVM-test# echo "scriem intr-un fisier" > /mnt/LVM/disc2/fisier root@yeti:~/LVM-test# dd if=/dev/urandom of=lvm.test2 bs=1k count=30960 30960+0 records in 30960+0 records out 31703040 bytes (32 MB) copied, 4.86575 s, 6.5 MB/s root@yeti:~/LVM-test# losetup -f --show lvm.test2 /dev/loop1 root@yeti:~/LVM-test# mkfs.ext3 -m 0 /dev/loop1 mke2fs 1.42.6 (21-Sep-2012) Discarding device blocks: done Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 7744 inodes, 30960 blocks 0 blocks (0.00%) reserved for the super user First data block=1 Maximum filesystem blocks=31719424 4 block groups 8192 blocks per group, 8192 fragments per group 1936 inodes per group Superblock backups stored on blocks: 8193, 24577 Allocating group tables: done Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done root@yeti:~/LVM-test# tune2fs -i 0 /dev/loop1 tune2fs 1.42.6 (21-Sep-2012) Setting interval between checks to 0 seconds root@yeti:~/LVM-test# pvcreate /dev/loop1 Physical volume "/dev/loop1" successfully created root@yeti:~/LVM-test# vgextend vg-test /dev/loop1 Volume group "vg-test" successfully extended root@yeti:~/LVM-test# vgdisplay --- Volume group --- VG Name vg-test System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 44.00 MiB PE Size 4.00 MiB Total PE 11 Alloc PE / Size 4 / 16.00 MiB Free PE / Size 7 / 28.00 MiB VG UUID Ill8va-3lTi-3PwF-e80d-czg7-YjZw-AQDWjD root@yeti:~/LVM-test# df -h /mnt/LVM/disc1/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg--test-discul1 3.9M 1.1M 2.9M 27% /mnt/LVM/disc1 root@yeti:~/LVM-test# df -h /mnt/LVM/disc2/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg--test-discul2 12M 1.2M 11M 10% /mnt/LVM/disc2 root@yeti:~/LVM-test# lvextend -L +4 /dev/vg-test/discul2 /dev/loop1 Extending logical volume discul2 to 16.00 MiB Logical volume discul2 successfully resized root@yeti:~/LVM-test# resize2fs /dev/vg-test/discul2 resize2fs 1.42.6 (21-Sep-2012) Filesystem at /dev/vg-test/discul2 is mounted on /mnt/LVM/disc2; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/vg-test/discul2 to 16384 (1k) blocks. The filesystem on /dev/vg-test/discul2 is now 16384 blocks long. root@yeti:~/LVM-test# df -h /mnt/LVM/disc2/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg--test-discul2 16M 1.2M 15M 8% /mnt/LVM/disc2 root@yeti:~/LVM-test# ls -l /mnt/LVM/disc2/ total 13 -rw-r--r-- 1 root root 47 Nov 1 15:59 fisier drwx------ 2 root root 12288 Nov 1 15:57 lost+found/ root@yeti:~/LVM-test# lvcreate -l 100%FREE -n discul3 vg-test Logical volume "discul3" created root@yeti:~/LVM-test# lvdisplay --- Logical volume --- LV Path /dev/vg-test/discul1 LV Name discul1 VG Name vg-test LV UUID iYp3EO-ygAm-D0a3-Qfaq-GPOc-GDAy-Hcyri2 LV Write Access read/write LV Creation host, time yeti, 2012-11-01 15:52:09 +0200 LV Status available # open 1 LV Size 4.00 MiB Current LE 1 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg-test/discul2 LV Name discul2 VG Name vg-test LV UUID NiyOd1-15eW-nn7d-ksZq-Fe5r-46pT-rW18j6libe LV Write Access read/write LV Creation host, time yeti, 2012-11-01 15:53:49 +0200 LV Status available # open 1 LV Size 16.00 MiB Current LE 4 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Path /dev/vg-test/discul3 LV Name discul3 VG Name vg-test LV UUID qACskv-Xkm1-3KiZ-R8QX-tw9c-vuV5-UDL5lH LV Write Access read/write LV Creation host, time yeti, 2012-11-01 16:11:51 +0200 LV Status available # open 0 LV Size 24.00 MiB Current LE 6 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 root@yeti:~/LVM-test# |
O comanda cheie este resize2fs, care utilizata corespunzator extinde sistemul de fisiere ext3 la noua dimensiune extinsa cu lvextend.
Niciun comentariu:
Trimiteți un comentariu