# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 29.8G 0 part
├─vmt--ubuntu--base-root (dm-0) 252:0 0 25.8G 0 lvm /
└─vmt--ubuntu--base-swap_1 (dm-1) 252:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 40G 0 disk
sdb обнаружился.
Добавляем файловую систему на sdb:
# echo ';' | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdb: 5221 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an MSDOS signature
/dev/sdb: unrecognised partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 0+ 5220 5221- 41937682 83 Linux
/dev/sdb2 0 - 0 0 0 Empty
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
# lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 40G 0 disk
└─sdb1 8:17 0 40G 0 part
# fdisk -l /dev/sdb
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 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: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 1 83875364 41937682 83 Linux
Проверяем текущее состояние VolumeGroup:
# vgdisplay
--- Volume group ---
VG Name vmt-ubuntu-base
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 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.76 GiB
PE Size 4.00 MiB
Total PE 7618
Alloc PE / Size 7618 / 29.76 GiB
Free PE / Size 0 / 0
VG UUID XrLTro-dew3-1tUO-koOw-XTyf-Ki3h-HwMNGp
Создаём новый PhysicalVolume на разделе /dev/sdb1:
# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Проверяем:
# pvdisplay -s
Device "/dev/sda5" has a capacity of 0
Device "/dev/sdb1" has a capacity of 39.99 GiB
Увиличиваем группу томов vmt-ubuntu-base:
# vgextend vmt-ubuntu-base /dev/sdb1
Volume group "vmt-ubuntu-base" successfully extended
Проверяем:
# vgdisplay
--- Volume group ---
VG Name vmt-ubuntu-base
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 69.75 GiB
PE Size 4.00 MiB
Total PE 17856
Alloc PE / Size 7618 / 29.76 GiB
Free PE / Size 10238 / 39.99 GiB
VG UUID XrLTro-dew3-1tUO-koOw-XTyf-Ki3h-HwMNGp
Проверяем ткущее состояние LogicalVolume:
# lvdisplay /dev/vmt-ubuntu-base/root
--- Logical volume ---
LV Name /dev/vmt-ubuntu-base/root
VG Name vmt-ubuntu-base
LV UUID toI6Qv-ANaY-dDlp-4xXu-3fTy-In2j-9uRzNc
LV Write Access read/write
LV Status available
# open 1
LV Size 25.76 GiB
Current LE 6594
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
Текущий размер — 26 гигабайт:
# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vmt--ubuntu--base-root 26G 1.9G 23G 8% /
Увеличиваем размер LogicalVolume до 100% VolumeGroup:
# lvextend -l +100%FREE -rn /dev/vmt-ubuntu-base/root
Extending logical volume root to 65.75 GiB
Logical volume root successfully resized
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/dm-0 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 5
Performing an on-line resize of /dev/dm-0 to 17235968 (4k) blocks.
The filesystem on /dev/dm-0 is now 17235968 blocks long.
Опции:
-n, --nofsck — не выполнять fsck перед увеличением файловой системы;
-r, --resizefs — изменить размер файловой системы вместе увеличением LogicalVolume, используя fsadm.
# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vmt--ubuntu--base-root 66G 1.9G 60G 3% /
И сам LogicalVolume:
# lvdisplay /dev/vmt-ubuntu-base/root
--- Logical volume ---
LV Name /dev/vmt-ubuntu-base/root
VG Name vmt-ubuntu-base
LV UUID toI6Qv-ANaY-dDlp-4xXu-3fTy-In2j-9uRzNc
LV Write Access read/write
LV Status available
# open 1
LV Size 65.75 GiB
Current LE 16832
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0