Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /dev/sdb
- root@jjuhasz-ThinkPad-L560:~# fdisk /dev/sdb
- Welcome to fdisk (util-linux 2.27.1).
- Changes will remain in memory only, until you decide to write them.
- Be careful before using the write command.
- Command (m for help): n
- Partition type
- p primary (0 primary, 0 extended, 4 free)
- e extended (container for logical partitions)
- Select (default p): p
- Partition number (1-4, default 1):
- First sector (2048-15131635, default 2048):
- Last sector, +sectors or +size{K,M,G,T,P} (2048-15131635, default 15131635): +1G
- Created a new partition 1 of type 'Linux' and of size 1 GiB.
- Command (m for help): t
- Selected partition 1
- Partition type (type L to list all types): 8e
- Changed type of partition 'Linux' to 'Linux LVM'.
- Command (m for help): w
- The partition table has been altered.
- Calling ioctl() to re-read partition table.
- Syncing disks.
- root@jjuhasz-ThinkPad-L560:~# pvcreate pv_test /dev/sdb1
- Device pv_test not found (or ignored by filtering).
- Physical volume "/dev/sdb1" successfully created
- root@jjuhasz-ThinkPad-L560:~# vgcreate vg_test /dev/sdb1
- Volume group "vg_test" successfully created
- root@jjuhasz-ThinkPad-L560:~# lvcreate -l +100%FREE vg_test
- Logical volume "lvol0" created.
- # result
- root@jjuhasz-ThinkPad-L560:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdb1 vg_test lvm2 a-- 1020,00m 0
- root@jjuhasz-ThinkPad-L560:~# vgs
- VG #PV #LV #SN Attr VSize VFree
- vg_test 1 1 0 wz--n- 1020,00m 0
- root@jjuhasz-ThinkPad-L560:~# lvs
- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
- lvol0 vg_test -wi-a----- 1020,00m
- #mkfs.ext4
- root@jjuhasz-ThinkPad-L560:~# mkfs.ext4 /dev/vg_test/lvol0
- mke2fs 1.42.13 (17-May-2015)
- Creating filesystem with 261120 4k blocks and 65280 inodes
- Filesystem UUID: d87b962f-3cf3-4ff5-b475-62e980869c62
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376
- Allocating group tables: done
- Writing inode tables: done
- Creating journal (4096 blocks): done
- Writing superblocks and filesystem accounting information: lvm
- done
- #place content onto the LVM
- root@jjuhasz-ThinkPad-L560:~# mount /dev/vg_test/lvol0 /mnt
- root@jjuhasz-ThinkPad-L560:~# echo "Content on the lvm" > /mnt/test.txt
- root@jjuhasz-ThinkPad-L560:~# cat /mnt/test.txt
- Content on the lvm
- #This is the result
- root@jjuhasz-ThinkPad-L560:~# df -h
- Filesystem Size Used Avail Use% Mounted on
- udev 3,8G 0 3,8G 0% /dev
- tmpfs 776M 9,6M 767M 2% /run
- /dev/sda1 227G 18G 199G 8% /
- tmpfs 3,8G 6,5M 3,8G 1% /dev/shm
- tmpfs 5,0M 4,0K 5,0M 1% /run/lock
- tmpfs 3,8G 0 3,8G 0% /sys/fs/cgroup
- cgmfs 100K 0 100K 0% /run/cgmanager/fs
- tmpfs 776M 72K 776M 1% /run/user/1000
- /dev/mapper/vg_test-lvol0 988M 1,3M 920M 1% /mnt
- root@jjuhasz-ThinkPad-L560:~# umount /mnt
- #resize partition
- root@jjuhasz-ThinkPad-L560:~# fdisk /dev/sdb
- Welcome to fdisk (util-linux 2.27.1).
- Changes will remain in memory only, until you decide to write them.
- Be careful before using the write command.
- Command (m for help): d
- Selected partition 1
- Partition 1 has been deleted.
- Command (m for help): n
- Partition type
- p primary (0 primary, 0 extended, 4 free)
- e extended (container for logical partitions)
- Select (default p): p
- Partition number (1-4, default 1):
- First sector (2048-15131635, default 2048):
- Last sector, +sectors or +size{K,M,G,T,P} (2048-15131635, default 15131635): +2G
- Created a new partition 1 of type 'Linux' and of size 2 GiB.
- Command (m for help): t
- Selected partition 1
- Partition type (type L to list all types): 8e
- Changed type of partition 'Linux' to 'Linux LVM'.
- Command (m for help): w
- The partition table has been altered.
- Calling ioctl() to re-read partition table.
- Re-reading the partition table failed.: Device or resource busy
- 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).
- root@jjuhasz-ThinkPad-L560:~# resize2fs /dev/vg_test/lvol0
- resize2fs 1.42.13 (17-May-2015)
- Please run 'e2fsck -f /dev/vg_test/lvol0' first.
- root@jjuhasz-ThinkPad-L560:~# e2fsck -f /dev/vg_test/lvol0
- e2fsck 1.42.13 (17-May-2015)
- Pass 1: Checking inodes, blocks, and sizes
- Pass 2: Checking directory structure
- Pass 3: Checking directory connectivity
- Pass 4: Checking reference counts
- Pass 5: Checking group summary information
- /dev/vg_test/lvol0: 12/65280 files (0.0% non-contiguous), 8524/261120 blocks
- root@jjuhasz-ThinkPad-L560:~# resize2fs /dev/vg_test/lvol0
- resize2fs 1.42.13 (17-May-2015)
- The filesystem is already 261120 (4k) blocks long. Nothing to do!
- root@jjuhasz-ThinkPad-L560:~# lsblk
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sdb 8:16 1 7,2G 0 disk
- └─sdb1 8:17 1 2G 0 part
- └─vg_test-lvol0 253:0 0 1020M 0 lvm
- sr0 11:0 1 1024M 0 rom
- sda 8:0 0 238,5G 0 disk
- ├─sda5 8:5 0 7,8G 0 part [SWAP]
- └─sda1 8:1 0 230,7G 0 part /
- # resize pv
- root@jjuhasz-ThinkPad-L560:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdb1 vg_test lvm2 a-- 1020,00m 0
- root@jjuhasz-ThinkPad-L560:~# partprobe
- root@jjuhasz-ThinkPad-L560:~# pvresize /dev/sdb1
- Physical volume "/dev/sdb1" changed
- 1 physical volume(s) resized / 0 physical volume(s) not resized
- root@jjuhasz-ThinkPad-L560:~# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sdb1 vg_test lvm2 a-- 2,00g 1,00g
- root@jjuhasz-ThinkPad-L560:~# lvextend -l +100%FREE /dev/vg_test/lvol0
- Size of logical volume vg_test/lvol0 changed from 1020,00 MiB (255 extents) to 2,00 GiB (511 extents).
- Logical volume lvol0 successfully resized.
- root@jjuhasz-ThinkPad-L560:~# lsblk
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sdb 8:16 1 7,2G 0 disk
- └─sdb1 8:17 1 2G 0 part
- └─vg_test-lvol0 253:0 0 2G 0 lvm
- sr0 11:0 1 1024M 0 rom
- sda 8:0 0 238,5G 0 disk
- ├─sda5 8:5 0 7,8G 0 part [SWAP]
- └─sda1 8:1 0 230,7G 0 part /
- root@jjuhasz-ThinkPad-L560:~# resize2fs /dev/vg_test/lvol0
- resize2fs 1.42.13 (17-May-2015)
- Filesystem at /dev/vg_test/lvol0 is mounted on /mnt; on-line resizing required
- old_desc_blocks = 1, new_desc_blocks = 1
- The filesystem on /dev/vg_test/lvol0 is now 523264 (4k) blocks long.
- root@jjuhasz-ThinkPad-L560:~# df -h
- Filesystem Size Used Avail Use% Mounted on
- udev 3,8G 0 3,8G 0% /dev
- tmpfs 776M 9,6M 767M 2% /run
- /dev/sda1 227G 18G 199G 8% /
- tmpfs 3,8G 19M 3,8G 1% /dev/shm
- tmpfs 5,0M 4,0K 5,0M 1% /run/lock
- tmpfs 3,8G 0 3,8G 0% /sys/fs/cgroup
- cgmfs 100K 0 100K 0% /run/cgmanager/fs
- tmpfs 776M 72K 776M 1% /run/user/1000
- /dev/mapper/vg_test-lvol0 2,0G 1,6M 1,9G 1% /mnt
- root@jjuhasz-ThinkPad-L560:~# cat /mnt/
- lost+found/ test.txt
- root@jjuhasz-ThinkPad-L560:~# cat /mnt/test.txt
- Content on the lvm
Add Comment
Please, Sign In to add comment