Guest User

Untitled

a guest
Nov 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1. /dev/sdb
  2.  
  3. root@jjuhasz-ThinkPad-L560:~# fdisk /dev/sdb
  4. Welcome to fdisk (util-linux 2.27.1).
  5. Changes will remain in memory only, until you decide to write them.
  6. Be careful before using the write command.
  7.  
  8. Command (m for help): n
  9. Partition type
  10. p primary (0 primary, 0 extended, 4 free)
  11. e extended (container for logical partitions)
  12. Select (default p): p
  13. Partition number (1-4, default 1):
  14. First sector (2048-15131635, default 2048):
  15. Last sector, +sectors or +size{K,M,G,T,P} (2048-15131635, default 15131635): +1G
  16.  
  17. Created a new partition 1 of type 'Linux' and of size 1 GiB.
  18.  
  19. Command (m for help): t
  20. Selected partition 1
  21. Partition type (type L to list all types): 8e
  22. Changed type of partition 'Linux' to 'Linux LVM'.
  23.  
  24. Command (m for help): w
  25. The partition table has been altered.
  26. Calling ioctl() to re-read partition table.
  27. Syncing disks.
  28.  
  29.  
  30. root@jjuhasz-ThinkPad-L560:~# pvcreate pv_test /dev/sdb1
  31. Device pv_test not found (or ignored by filtering).
  32. Physical volume "/dev/sdb1" successfully created
  33. root@jjuhasz-ThinkPad-L560:~# vgcreate vg_test /dev/sdb1
  34. Volume group "vg_test" successfully created
  35. root@jjuhasz-ThinkPad-L560:~# lvcreate -l +100%FREE vg_test
  36. Logical volume "lvol0" created.
  37.  
  38. # result
  39. root@jjuhasz-ThinkPad-L560:~# pvs
  40. PV VG Fmt Attr PSize PFree
  41. /dev/sdb1 vg_test lvm2 a-- 1020,00m 0
  42. root@jjuhasz-ThinkPad-L560:~# vgs
  43. VG #PV #LV #SN Attr VSize VFree
  44. vg_test 1 1 0 wz--n- 1020,00m 0
  45. root@jjuhasz-ThinkPad-L560:~# lvs
  46. LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
  47. lvol0 vg_test -wi-a----- 1020,00m
  48.  
  49. #mkfs.ext4
  50. root@jjuhasz-ThinkPad-L560:~# mkfs.ext4 /dev/vg_test/lvol0
  51. mke2fs 1.42.13 (17-May-2015)
  52. Creating filesystem with 261120 4k blocks and 65280 inodes
  53. Filesystem UUID: d87b962f-3cf3-4ff5-b475-62e980869c62
  54. Superblock backups stored on blocks:
  55. 32768, 98304, 163840, 229376
  56.  
  57. Allocating group tables: done
  58. Writing inode tables: done
  59. Creating journal (4096 blocks): done
  60. Writing superblocks and filesystem accounting information: lvm
  61. done
  62.  
  63. #place content onto the LVM
  64. root@jjuhasz-ThinkPad-L560:~# mount /dev/vg_test/lvol0 /mnt
  65. root@jjuhasz-ThinkPad-L560:~# echo "Content on the lvm" > /mnt/test.txt
  66. root@jjuhasz-ThinkPad-L560:~# cat /mnt/test.txt
  67. Content on the lvm
  68.  
  69. #This is the result
  70. root@jjuhasz-ThinkPad-L560:~# df -h
  71. Filesystem Size Used Avail Use% Mounted on
  72. udev 3,8G 0 3,8G 0% /dev
  73. tmpfs 776M 9,6M 767M 2% /run
  74. /dev/sda1 227G 18G 199G 8% /
  75. tmpfs 3,8G 6,5M 3,8G 1% /dev/shm
  76. tmpfs 5,0M 4,0K 5,0M 1% /run/lock
  77. tmpfs 3,8G 0 3,8G 0% /sys/fs/cgroup
  78. cgmfs 100K 0 100K 0% /run/cgmanager/fs
  79. tmpfs 776M 72K 776M 1% /run/user/1000
  80. /dev/mapper/vg_test-lvol0 988M 1,3M 920M 1% /mnt
  81.  
  82. root@jjuhasz-ThinkPad-L560:~# umount /mnt
  83.  
  84. #resize partition
  85.  
  86. root@jjuhasz-ThinkPad-L560:~# fdisk /dev/sdb
  87.  
  88. Welcome to fdisk (util-linux 2.27.1).
  89. Changes will remain in memory only, until you decide to write them.
  90. Be careful before using the write command.
  91.  
  92.  
  93. Command (m for help): d
  94. Selected partition 1
  95. Partition 1 has been deleted.
  96.  
  97. Command (m for help): n
  98. Partition type
  99. p primary (0 primary, 0 extended, 4 free)
  100. e extended (container for logical partitions)
  101. Select (default p): p
  102. Partition number (1-4, default 1):
  103. First sector (2048-15131635, default 2048):
  104. Last sector, +sectors or +size{K,M,G,T,P} (2048-15131635, default 15131635): +2G
  105.  
  106. Created a new partition 1 of type 'Linux' and of size 2 GiB.
  107.  
  108. Command (m for help): t
  109. Selected partition 1
  110. Partition type (type L to list all types): 8e
  111. Changed type of partition 'Linux' to 'Linux LVM'.
  112.  
  113. Command (m for help): w
  114. The partition table has been altered.
  115. Calling ioctl() to re-read partition table.
  116. Re-reading the partition table failed.: Device or resource busy
  117.  
  118. 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).
  119.  
  120. root@jjuhasz-ThinkPad-L560:~# resize2fs /dev/vg_test/lvol0
  121. resize2fs 1.42.13 (17-May-2015)
  122. Please run 'e2fsck -f /dev/vg_test/lvol0' first.
  123.  
  124. root@jjuhasz-ThinkPad-L560:~# e2fsck -f /dev/vg_test/lvol0
  125. e2fsck 1.42.13 (17-May-2015)
  126. Pass 1: Checking inodes, blocks, and sizes
  127. Pass 2: Checking directory structure
  128. Pass 3: Checking directory connectivity
  129. Pass 4: Checking reference counts
  130. Pass 5: Checking group summary information
  131. /dev/vg_test/lvol0: 12/65280 files (0.0% non-contiguous), 8524/261120 blocks
  132. root@jjuhasz-ThinkPad-L560:~# resize2fs /dev/vg_test/lvol0
  133. resize2fs 1.42.13 (17-May-2015)
  134. The filesystem is already 261120 (4k) blocks long. Nothing to do!
  135.  
  136. root@jjuhasz-ThinkPad-L560:~# lsblk
  137. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  138. sdb 8:16 1 7,2G 0 disk
  139. └─sdb1 8:17 1 2G 0 part
  140. └─vg_test-lvol0 253:0 0 1020M 0 lvm
  141. sr0 11:0 1 1024M 0 rom
  142. sda 8:0 0 238,5G 0 disk
  143. ├─sda5 8:5 0 7,8G 0 part [SWAP]
  144. └─sda1 8:1 0 230,7G 0 part /
  145.  
  146. # resize pv
  147. root@jjuhasz-ThinkPad-L560:~# pvs
  148. PV VG Fmt Attr PSize PFree
  149. /dev/sdb1 vg_test lvm2 a-- 1020,00m 0
  150. root@jjuhasz-ThinkPad-L560:~# partprobe
  151. root@jjuhasz-ThinkPad-L560:~# pvresize /dev/sdb1
  152. Physical volume "/dev/sdb1" changed
  153. 1 physical volume(s) resized / 0 physical volume(s) not resized
  154. root@jjuhasz-ThinkPad-L560:~# pvs
  155. PV VG Fmt Attr PSize PFree
  156. /dev/sdb1 vg_test lvm2 a-- 2,00g 1,00g
  157.  
  158. root@jjuhasz-ThinkPad-L560:~# lvextend -l +100%FREE /dev/vg_test/lvol0
  159. Size of logical volume vg_test/lvol0 changed from 1020,00 MiB (255 extents) to 2,00 GiB (511 extents).
  160. Logical volume lvol0 successfully resized.
  161. root@jjuhasz-ThinkPad-L560:~# lsblk
  162. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  163. sdb 8:16 1 7,2G 0 disk
  164. └─sdb1 8:17 1 2G 0 part
  165. └─vg_test-lvol0 253:0 0 2G 0 lvm
  166. sr0 11:0 1 1024M 0 rom
  167. sda 8:0 0 238,5G 0 disk
  168. ├─sda5 8:5 0 7,8G 0 part [SWAP]
  169. └─sda1 8:1 0 230,7G 0 part /
  170.  
  171. root@jjuhasz-ThinkPad-L560:~# resize2fs /dev/vg_test/lvol0
  172. resize2fs 1.42.13 (17-May-2015)
  173. Filesystem at /dev/vg_test/lvol0 is mounted on /mnt; on-line resizing required
  174. old_desc_blocks = 1, new_desc_blocks = 1
  175. The filesystem on /dev/vg_test/lvol0 is now 523264 (4k) blocks long.
  176.  
  177. root@jjuhasz-ThinkPad-L560:~# df -h
  178. Filesystem Size Used Avail Use% Mounted on
  179. udev 3,8G 0 3,8G 0% /dev
  180. tmpfs 776M 9,6M 767M 2% /run
  181. /dev/sda1 227G 18G 199G 8% /
  182. tmpfs 3,8G 19M 3,8G 1% /dev/shm
  183. tmpfs 5,0M 4,0K 5,0M 1% /run/lock
  184. tmpfs 3,8G 0 3,8G 0% /sys/fs/cgroup
  185. cgmfs 100K 0 100K 0% /run/cgmanager/fs
  186. tmpfs 776M 72K 776M 1% /run/user/1000
  187. /dev/mapper/vg_test-lvol0 2,0G 1,6M 1,9G 1% /mnt
  188.  
  189. root@jjuhasz-ThinkPad-L560:~# cat /mnt/
  190. lost+found/ test.txt
  191. root@jjuhasz-ThinkPad-L560:~# cat /mnt/test.txt
  192. Content on the lvm
Add Comment
Please, Sign In to add comment